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

how to use program memory to store and read data?

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



Joined: 22 Jul 2004
Posts: 25

View user's profile Send private message

how to use program memory to store and read data?
PostPosted: Wed Jul 28, 2004 2:51 pm     Reply with quote

I use PIC16F873 to design a RF sensors. But the RAM space is to small for application. So i want to use ROM(program memory) for my data storage. But i am confused that what is the difference between read_program_eeprom and read_program_memory?

the follow is some part of my program to read or write program memory:


#ROM 0x0e00 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
#ROM 0x0e10 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
#ROM 0x0e20 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
#ROM 0x0e30 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
#ROM 0x0e40 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
#ROM 0x0e50 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}

void read_rom()
{
int index;
printf("ID Number:");
index=0;
//read_program_memory(0x0e00,tx_buffer,11);
while(index<11)
{
putc(read_program_eeprom(index+0x0e00));
index++;
}
}

void write_rom()
{
index=0;
while(index<11)
{
//poll and delay for next character
write_program_eeprom(0x0e00+index,rx_buffer[index]);
// write_program_memory(0x0e00,rx_buffer,11);
index++;
}
}


please give me some idea on this topic, thank you:)
Ttelmah
Guest







Re: how to use program memory to store and read data?
PostPosted: Thu Jul 29, 2004 3:51 am     Reply with quote

garyzheng wrote:
I use PIC16F873 to design a RF sensors. But the RAM space is to small for application. So i want to use ROM(program memory) for my data storage. But i am confused that what is the difference between read_program_eeprom and read_program_memory?

the follow is some part of my program to read or write program memory:


#ROM 0x0e00 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
#ROM 0x0e10 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
#ROM 0x0e20 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
#ROM 0x0e30 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
#ROM 0x0e40 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
#ROM 0x0e50 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}

void read_rom()
{
int index;
printf("ID Number:");
index=0;
//read_program_memory(0x0e00,tx_buffer,11);
while(index<11)
{
putc(read_program_eeprom(index+0x0e00));
index++;
}
}

void write_rom()
{
index=0;
while(index<11)
{
//poll and delay for next character
write_program_eeprom(0x0e00+index,rx_buffer[index]);
// write_program_memory(0x0e00,rx_buffer,11);
index++;
}
}


please give me some idea on this topic, thank you:)

read_program_eeprom, is the correct/normal call. The latest include files for some procesors, have 'read_program_memory' defined as a 'psedonym' for the other call.
Use the 'eeprom' syntax, since this is portable to the older compilers.
Hopefully you have followed the thread about the limited life of the program eeprom?. It really is not suitable, if the data has to be updated more than very infrequently. Consider an external FRAM instead.

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