|
|
View previous topic :: View next topic |
Author |
Message |
Trampas Guest
|
PIC18F Flash routines |
Posted: Mon Aug 02, 2004 7:25 am |
|
|
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 |
Posted: Mon Aug 02, 2004 9:23 am |
|
|
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 |
|
|
|
|
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
|