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

Writing to Program memory of Pic16f716

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



Joined: 07 Mar 2008
Posts: 2

View user's profile Send private message

Writing to Program memory of Pic16f716
PostPosted: Thu Aug 12, 2010 1:12 am     Reply with quote

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: 19569

View user's profile Send private message

PostPosted: Thu Aug 12, 2010 1:46 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Aug 12, 2010 1:59 am     Reply with quote

Thank you.
I hadn't seen it in pdf :(
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