|
|
View previous topic :: View next topic |
Author |
Message |
pathetic
Joined: 07 Mar 2008 Posts: 2
|
Writing to Program memory of Pic16f716 |
Posted: Thu Aug 12, 2010 1:12 am |
|
|
Hi,
I am trying to read and write to program memory of PIC16f716 to hold two byte counter data. This don't have Eeprom so my aim is to know how many times the PIC has started.
Code is as below but I couldn't compile. If I change PIC everything is fine but not for 16f716.
Code: |
int16 kBuffer [1]={0};
int16 bBuffer [1]={0};
int16 sBuffer [1]={0};
int16 kadres=0x0390; // the empty buffers
int16 badres=0x0380; // the empty buffers
void eeprom_kontrol()
{
read_program_memory(kadres,kBuffer,1);
read_program_memory(badres,bBuffer,1);
if(kBuffer [0]==0x3FFF) write_program_memory(kadres,sBuffer,1); //if first time make it zero
if(bBuffer [0]==0x3FFF) write_program_memory(badres,sBuffer,1); //if first time make it zero
if (kBuffer[0]==5) //if it is 5, increase the other byte
{
kBuffer[0]=0;bBuffer[0]=bBuffer[0]+1;
write_program_memory(badres, bBuffer, 1);
}
else
{
kBuffer [0] =kBuffer [0]+1;
}
write_program_memory(kadres, kBuffer, 1);
}
|
I hope it is clear.
Waiting your help |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Thu Aug 12, 2010 1:46 am |
|
|
You need to read the data sheet.
The PIC16F716, _does not have the ability to write to it's own program memory_. Hence the code won't work.
You need to select an equivalent chip, that either has this ability, or internal EEPROM (preferably the latter)....
Best Wishes |
|
|
pathetic
Joined: 07 Mar 2008 Posts: 2
|
|
Posted: Thu Aug 12, 2010 1:59 am |
|
|
Thank you.
I hadn't seen it in pdf :( |
|
|
|
|
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
|