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 support@ccsinfo.com

Starting with bootloader

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



Joined: 13 Apr 2011
Posts: 406

View user's profile Send private message

Starting with bootloader
PostPosted: Sun Dec 27, 2020 11:12 am     Reply with quote

Hello I'm trying to understand how bootloader works on PIC&CCS.
I already have a huge program with no bootloader running on a PIC18F67J50 and now I need to add a bootloader.

1) If the bootloader needs to access USB and a I2C memory the bootloader must have their owns routines?
I think yes, because the main program will be erased.

2)What about the interrupts vectors? How they works when the main program run and how when the bootloader runs?

Also I tried to move the program to a higher address without luck.

Code:
#include <18F67J50.h>
#fuses INTRC_PLL,PLL2,NOCPUDIV,NOIESO,NOFCMEN,STVREN,CCP2E7,NOWDT,WDT2048,PROTECT //WDT8Seg. No crystal

#build(reset=0x200:0x207, interrupt=0x208:0x2ff)
#build(memory=0x2000:0x2FFF)
//#ROM 0 = {0xFFFF}     // Insert NOP at address 0

void main()
{
   char buffer[64];
   
   setup_oscillator(OSC_PLL_ON|OSC_NORMAL);
   read_program_memory(0x0000, buffer, 64);
   delay_cycles(1);
   delay_cycles(1);
   write_program_memory(0x1000, buffer, 64);
   delay_cycles(1);
   delay_cycles(1);
   
   while(1)
   {
      delay_cycles(1);
      delay_cycles(1);
      
   }
   
}


Now I'm using a PIC18F67J50 but probably also will need to use the same bootloader with a PIC24FJ1024GB606.
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Sun Dec 27, 2020 12:09 pm     Reply with quote

Yes.

Normally you don't use interrupts in the bootloader. Instead poll
the interrupt flags. Otherwise it gets awkward.
The bootloader revectors the interrupts for the main code.

A program moved to a higher address, cannot run without the bootloader
loaded to handle jumping to it on boot and revectoring the interrupts.
E_Blue



Joined: 13 Apr 2011
Posts: 406

View user's profile Send private message

PostPosted: Sun Dec 27, 2020 12:35 pm     Reply with quote

How I can use USB CDC CCS library with the bootloader?

I mean it must have separated routines.
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Sun Dec 27, 2020 12:50 pm     Reply with quote

The USB CDC library, offers an option to poll rather than use the
interrupt. Look at the example USB bootloader.
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