CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Programming a PIC like Arduino via serial port

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
webgiorgio



Joined: 02 Oct 2009
Posts: 123
Location: Denmark

View user's profile Send private message

Programming a PIC like Arduino via serial port
PostPosted: Tue Jan 10, 2017 4:23 am     Reply with quote

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"?
Question
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jan 10, 2017 7:30 am     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

Re: Programming a PIC like Arduino via serial port
PostPosted: Tue Jan 10, 2017 5:58 pm     Reply with quote

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!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group