View previous topic :: View next topic |
Author |
Message |
marcus.couceiro
Joined: 04 Jan 2012 Posts: 12 Location: Brazil
|
PICDEM FS USB bootloader and ex_usb_serial |
Posted: Wed Jul 04, 2012 10:48 am |
|
|
Gentlemen,
I had recently built a generic PICDEM FS USB board using the 18F4550.
The bootloader code provided by Microchip was loaded and everything is working fine. I was able to use the Bootloader functionality to load my own codes (simple ones, blink a led, generate PWM, read ADC, etc).
What I want to do now is to convert the ADC value to Volts and send it to Hyperterminal on my PC. To do that I thought I could use the CCS ex_usb_serial.
The question is: If I load the ex_usb_serial code on the memory dedicated to firmware (the same I was using with my simple programs) is it going to work? have you guys ever tried to do that?
Thank you for you advice. _________________ Marcus Couceiro |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Wed Jul 04, 2012 12:18 pm |
|
|
Well I know the ex_usb_serial program works...and is used in my remote data loggers,sending time/temperature data to a PC via USB.
note :There is a .inf file that needs to be installed on the PC.
I suggest you get the main program( adc->PC) up and running first, then add the bootloader afterwards.
That way you KNOW the main program works, you already KNOW your bootloader works, so it 'should' work. |
|
|
marcus.couceiro
Joined: 04 Jan 2012 Posts: 12 Location: Brazil
|
|
Posted: Wed Jul 04, 2012 12:34 pm |
|
|
Hi temtronic,
Thanks for your reply. Where can I get this .inf file you mentioned?
Regards _________________ Marcus Couceiro |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Wed Jul 04, 2012 1:55 pm |
|
|
It's in the examples folder that CCS supplies or maybe the devices, I forget, it's like 103 in the shade here there's 2 of them, for different OSes. |
|
|
marcus.couceiro
Joined: 04 Jan 2012 Posts: 12 Location: Brazil
|
|
Posted: Wed Jul 04, 2012 4:52 pm |
|
|
Hi temtronic,
Thank you once again. The .inf files could be found at Program Files\PICC\Drivers\...
When the software was loaded and the board was plugged on USB, Windows asked for the drivers and I just pointed to the path above. Right now I can see (COM4) USB to UART under the Device Manager.
Of course something else should happen .
Although I have everything set up correctly (at least I think) I can not see anything under HyperTerminal.
Hyperterminal is set to COM4, 9600, no parity, 1, no flow control and the same configuration can be seen under the tab Port Settings of COM4.
From the software below:
++++++++++++++++++++++
Code removed.
Reason: Forum Rule #10
10. Don't post the CCS example code or drivers.
http://www.ccsinfo.com/forum/viewtopic.php?t=26245
- Forum Moderator
++++++++++++++++++++++
I suppose I should see a message on Hyperterminal but the only thing I get is a Pop Up saying that "COM4 could not be opened" but I have both D1 and D2 lit.
I do not know how to include an image of the circuit in this post.
Could you give me a clue on what is wrong. I am using CCS version 4.078.
thanks _________________ Marcus Couceiro |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Thu Jul 05, 2012 12:37 pm |
|
|
Hi,
A couple of things. Number 1 is that you are violating the CCS copyright on that code by posting it on the forum. You stripped off the copyright info, and posted the code - you shouldn't do that! Number 2, you've modified the code to work with your bootloader. That code does work, but you need to try it first in it's unmodified form to ensure that your hardware is working correctly before undertaking the modifications to make it work with a bootloader.
John |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Thu Jul 05, 2012 2:21 pm |
|
|
ezflyer is right, first get your program running fine BEFORE adding the bootloader section or you'll spend a LOT of sleepless nights trying to figure out WHY it doesn't work.
Sounds like your bootloader section is OK so get 'main' to run right.
THEN merge the two and see what happens...
Also be sure to have copies of working code do NOT just add/merge code into a previously working attempt.
In my mind I see you having 3 programs
1) a working bootloader
2) a working 'main'
3) a merged version of 1 +2
that way you can always go back to a previously KNOWN WORKING code. |
|
|
marcus.couceiro
Joined: 04 Jan 2012 Posts: 12 Location: Brazil
|
|
Posted: Thu Jul 05, 2012 7:02 pm |
|
|
Hi Guys,
I am sorry for my mistake. I never meant to break any posting rules.
I will be more careful next time.
Following you suggestions, I've modified the code in order to turn on a led when TeraTerm is connected to the COM port created by the PIC and to turn off the same led when we disconnect TeraTerm.
The code is as follow
Code: | #include <18F4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock= 48000000)
// libraries ------------------------------------------------------------------------------
#include <usb_cdc.h>
// #include <usb_desc_cdc.h>
#define on output_high
#define off output_low
#define led (PIN_D0)
#define Connected (PIN_D2)
/* ------------------------------------------------------------------------- */
/* map reset vector and interrupt vector */
/* 0x000-0x7FF is used by the bootloader. The bootloader maps the original */
/* reset vector (0x000) to 0x800 and the interrupt vector (0x008) to 0x808. */
/* ------------------------------------------------------------------------- */
//#build (reset=0x800, interrupt=0x808)
/* ------------------------------------------------------------------------- */
/* reserve boot block area */
/* This memory range is used by the bootloader, so the application must not */
/* use this area. */
/* ------------------------------------------------------------------------- */
//#org 0, 0x7FF {}
void main()
{
char x;
on(led);
delay_ms(1000);
off(led);
usb_init();
usb_cdc_init();
while(1)
{
usb_task();
if (usb_CDC_connected())
{
on(Connected);
}
else
{
off(connected);
}
}
}
|
As we can see I had removed the bootloader and used a serial programmer to load the code into PIC.
When we connect the PIC we have led blinking once and nothing else (which is good). Then I open Teraterm and connect to the COM Port. When I do That I have the Connected led on.
The problem is that when I disconnect the TeraTerm the led does not turn off. To make everything happen again I have to reset PIC and start TeraTerm.
It seems to me that the program is executed only once and the while(1) is not executed continuously.
Just as information, I tried the same code with the bootloader and got the same results.
Thanks and sorry once again. _________________ Marcus Couceiro |
|
|
|