View previous topic :: View next topic |
Author |
Message |
webgiorgio
Joined: 02 Oct 2009 Posts: 123 Location: Denmark
|
Programming a PIC like Arduino via serial port |
Posted: Tue Jan 10, 2017 4:23 am |
|
|
Hello all,
I have been programming my PIC 16F876A board with the ICD-U64 programmer and v5.034 PCWH and want to move to bootloader-RS232 programming.
The CCS example uses PIN_A4 to decide whether to start the program or wait for download the hex file from the serial port. I can see that when I power up the board with PIN_A4 low I see "Ready for download..." in the RS232 terminal (siow.exe). I can then send the .hex file to the board.
I then power off the board, switch the PIN_A4 to high, power up the board -> but the program is stuck and (as expected) I don't get the "Ready for download..." on the serial terminal.
With Arduino is very simple to program the microcontroller and I can issue the new firmware to the board whenever I want just using the RS232 interface (without need of a hardware pin change). This is very important for me because allows to program the board unattended.
Are you aware of a bootloader which I can use in combination with the CCS C IDE to program my uC just by pressing "build+run"?
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9250 Location: Greensville,Ontario
|
|
Posted: Tue Jan 10, 2017 7:30 am |
|
|
It's not the bootloader that needs to be modified, rather your 'main' code. It needs to have a 'test' within the serial receive code to 'see' your unique 'new download available' tag THEN jump to the bootloader routine.
I have to assume the Ardunio code is doing this, or a variation of it. If that code is in C, you could convert it into CCS C.
The BIG issue to to have a UNIQUE 'tag', otherwise some random set of characters might invoke the bootloader routine. There should be some 'checking' to confirm 'yes, new download' it true as well as a timer to cancel or abort a fake download !
Jay |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
Re: Programming a PIC like Arduino via serial port |
Posted: Tue Jan 10, 2017 5:58 pm |
|
|
webgiorgio wrote: |
With Arduino is very simple to program the microcontroller and I can issue the new firmware to the board whenever I want just using the RS232 interface (without need of a hardware pin change). This is very important for me because allows to program the board unattended. |
The Arduino uses the DTR pin to reset the processor. The processor on boot-up can then be captured by the bootloader app build into the IDE (or some other app). If not captured after a couple of seconds, control is passed to the application. So. strictly speaking the Arduino does require an external pin, it just happens to be the reset pin of the processor via a capacitor coupled to DTR. You could modify the CCS bootloader to behave in a similar manor. The problem with the Arduino approach is that whenever DTR transitions to asserted it resets the processor. For my our designs, I remove the capacitor to stop the Arduino being reset on DTR. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
|