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

PIC18F Flash routines

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







PIC18F Flash routines
PostPosted: Mon Aug 02, 2004 7:25 am     Reply with quote

Does anyone have some routines to read/write the flash memory on the PIC18F devices.

I have been trying to use the read/write program memory routines which come with the CCS compiler but have not been able to them to work correctly. Darren had mentioned possible bugs with these routines but nothing else has happened.

Thus I figured I am not the first to read/write flash so maybe someone else can help?

Thanks
Trampas
Ttelmah
Guest







Re: PIC18F Flash routines
PostPosted: Mon Aug 02, 2004 9:23 am     Reply with quote

Trampas wrote:
Does anyone have some routines to read/write the flash memory on the PIC18F devices.

I have been trying to use the read/write program memory routines which come with the CCS compiler but have not been able to them to work correctly. Darren had mentioned possible bugs with these routines but nothing else has happened.

Thus I figured I am not the first to read/write flash so maybe someone else can help?

Thanks
Trampas

The routines are basically the same as the ones that access the EEPROM. The key 'difference', is that the processor stops during the write, and that there must be no accesses to any hardware interupt during the write. A friend was having problems with the CCS code, and found that adding:
Code:

   disable_interrupts(GLOBAL);
   disable_interrupts(INT_RTCC);
   disable_interrupts(INT_TIMER0);           
   disable_interrupts(INT_TIMER1);               
   disable_interrupts(INT_TIMER2);               
   disable_interrupts(INT_TIMER3);               
   disable_interrupts(INT_EXT);                   
   disable_interrupts(INT_EXT1);                 
   disable_interrupts(INT_EXT2);                 
   disable_interrupts(INT_RB);                   
   disable_interrupts(INT_AD);                   
   disable_interrupts(INT_RDA);                   
   disable_interrupts(INT_TBE);                   
   disable_interrupts(INT_SSP);                   
   disable_interrupts(INT_CCP1);                 
   disable_interrupts(INT_CCP2);                 
   disable_interrupts(INT_BUSCOL);               
   disable_interrupts(INT_LOWVOLT);               
   disable_interrupts(INT_EEPROM);     

got it all going.

I suggested the alternative, of declaring the registers for interrupt control (PIE1, PIE2, INTCON3, and INTCON), then having something like:
int8 save[4];
save[0]=PIE1;
save[1]=PIE2;
save[2]=INTCON3;
save[3]=INTCON;
PIE1=PIE2=INTCON=INTCON3=0;

Then execute the eeprom write code, and when finished, use:
PIE1=save[0];
PIE2=save[1];
INTCON3=save[2];
INTCON=save[3];
to restore the interrupt state.

Best Wishes
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