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

EEPROM or Flash memory ???

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







EEPROM or Flash memory ???
PostPosted: Fri Feb 13, 2004 2:04 am     Reply with quote

Hello all !

I'm working with a PIC16F877 and I would like to store 100 bytes in memory. Is it better to strore that bytes in EEPROM memory or in FLASH memory ??

I saw in this forum a topic who talk about the #ROM instruction.
Does this instruction store the data in EEPROM or in FLASH memory ?

I use this code (I found it in a topic of this forum). It works but I don't understand why must I start at the address 0x2100 and why must I use the instruction read_eeprom(0) to read the first byte stored ????


Code:
#ROM 0x2100 = {0x0E,0xB2,0x0F,0x22,0x0C,0xF2,0x0D,0x62,0x0E,0x42,0x10,0x02,
               0x0D,0xD2,0x10,0x72,0x11,0x52,0x11,0xC2,0x0F,0x92,0x05,0x72,
               0x0B,0x32,0x0A,0xC2,0x06,0x52,0x0B,0xA2,0x0C,0x82,0x14,0x62,
               0x15,0x62,0x10,0xE2,0x15,0xE2,0x13,0xF2,0x13,0x12,0x16,0x62,
               0x14,0xD2,0x13,0x82,0x12,0x32,0x12,0xA2,0x0C,0x12,0x05,0xE2}
...
...
...
...
...
...
Nh=read_EEPROM(0);
Nl=read_EEPROM(1);



Can you help me please ????

Sorry for my english !
Ttelmah
Guest







Re: EEPROM or Flash memory ???
PostPosted: Fri Feb 13, 2004 3:22 am     Reply with quote

Mic wrote:
Hello all !

I'm working with a PIC16F877 and I would like to store 100 bytes in memory. Is it better to strore that bytes in EEPROM memory or in FLASH memory ??

I saw in this forum a topic who talk about the #ROM instruction.
Does this instruction store the data in EEPROM or in FLASH memory ?

I use this code (I found it in a topic of this forum). It works but I don't understand why must I start at the address 0x2100 and why must I use the instruction read_eeprom(0) to read the first byte stored ????


Code:
#ROM 0x2100 = {0x0E,0xB2,0x0F,0x22,0x0C,0xF2,0x0D,0x62,0x0E,0x42,0x10,0x02,
               0x0D,0xD2,0x10,0x72,0x11,0x52,0x11,0xC2,0x0F,0x92,0x05,0x72,
               0x0B,0x32,0x0A,0xC2,0x06,0x52,0x0B,0xA2,0x0C,0x82,0x14,0x62,
               0x15,0x62,0x10,0xE2,0x15,0xE2,0x13,0xF2,0x13,0x12,0x16,0x62,
               0x14,0xD2,0x13,0x82,0x12,0x32,0x12,0xA2,0x0C,0x12,0x05,0xE2}
...
...
...
...
...
...
Nh=read_EEPROM(0);
Nl=read_EEPROM(1);



Can you help me please ????

Sorry for my english !

Which is 'best', depends on the applicatiion needs. The EEPROM, only offers 256 bytes of storage, so for large tables, the main memory may have to be used. The main emory, has a much more limited number of read/write cycles supported, so if the data needs to be changed at all often, the EEPROM should be used. Using main memory, reduces the code size that you can have.
The instruction to read the EEPROM storage, is 'read_eeprom'. The EEPROM is typically 256 bytes in size, and the instruction simply accepts a number from 0 to 255, as an 'address', and returns the byte at that address in the EEPROM. So 'read_eeprom(0)', returns the first byte from the EEPROM.
The '0x2100', will vary with different types of chip. This is part of the 'programming specification' from MicroChip. To allow the EEPROM to be written by device programmers, it is 'mapped' into the main memory area at an address, during the programming operation. For the 16 family devices, this address is '0x2100', which is above the top of the normal flash memory. For 18 series chips it is 0xF00000.
The ROM statement, puts data at a specific address. So if you used #ROM 0x100=
the following data would appear at address 100 in the main memory. At this address (on chips that support it), the data could be read using the 'read_program_eeprom' instruction. The same instruction, when used to write to 0x2100 (on the chips where the data EEPROM is mapped at this point during programming), puts the data into the data EEPROM instead, and it can then be read with the 'read_eeprom' instruction.

Best Wishes
Mic
Guest







tell me if i'm right
PostPosted: Fri Feb 13, 2004 4:09 am     Reply with quote

Thank you very much for your help Ttelmah !

Tell me if I'm right:

if I use #ROM 0x2100 {data....}, I'll store data in the PIC's EEPROM so I'll can store 'only' 256 bytes. The address 0x2100 is the mapped address of the PIC16F877's EEPROM in the main memory area and that's why I can use the read_eeprom() instruction to read the data.
Pete Smith



Joined: 17 Sep 2003
Posts: 55
Location: Chester, UK

View user's profile Send private message Visit poster's website MSN Messenger ICQ Number

Re: tell me if i'm right
PostPosted: Fri Feb 13, 2004 4:33 am     Reply with quote

Mic wrote:
Thank you very much for your help Ttelmah !

Tell me if I'm right:

if I use #ROM 0x2100 {data....}, I'll store data in the PIC's EEPROM so I'll can store 'only' 256 bytes. The address 0x2100 is the mapped address of the PIC16F877's EEPROM in the main memory area and that's why I can use the read_eeprom() instruction to read the data.


Spot on Smile

Bear in mind that #rom is a compile time option, which will pre-load the EEPROM data when you program the PIC. It can't be used at a couple of places in your code to load values at different times.

Pete.
Mic
Guest







ok I'll keep this in my mind !
PostPosted: Fri Feb 13, 2004 4:41 am     Reply with quote

Thank you for this precision Pete !
I'll try to keep this in my mind !

Laughing
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