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

Using #ROM on PIC16F877(A)

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



Joined: 30 Oct 2010
Posts: 1

View user's profile Send private message

Using #ROM on PIC16F877(A)
PostPosted: Sat Oct 30, 2010 3:14 pm     Reply with quote

Hi,

I'm trying to write my EEPROM with a "default" data.

I have been searching and all that I found on google, and CCS C help, is:

Code:
#rom  0x2100={1,2,3,4,5,6,7,8}

and

Code:
#ROM getenv("EEPROM_ADDRESS") = {0x55, 0xAA}

The first option would work if I'd know the EEPROM address and the second doesn't work. In fact the help for "getenv()" function doesn't say any thing about "EEPROM_ADDRESS".

I also checked the datasheet of the pic877 and found some information but I didn't get sure about that.

So any one here can help me with this?

I can't believe that I have to fill with the real address. When I user EEPROM_WRITE() and EEPROM_READ() I don't have to know this...

Thanks,
Ian
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 30, 2010 4:26 pm     Reply with quote

What's your compiler version ? It may not work if you have an old version
that was released before they added this feature.

Download the CCS manual:
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
Look in the getenv() section on page 184. It lists EEPROM_ADDRESS
as a parameter. But again, it will depend on your compiler version.


To find the absolute address of the data eeprom, go to the page for the PIC:
http://www.microchip.com/wwwproducts/devices.aspx?ddocname=en010241
Download the Programming Specification.
Quote:
PIC16F87X EEPROM Memory Programming Specification

Don't be confused by them calling it an "EEPROM" spec. It includes the
Flash ROM, and the data eeprom, and the Config memory. Read this
section to find the data eeprom address of 0x2100:
Quote:
2.2 Data EEPROM Memory
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sun Oct 31, 2010 3:26 am     Reply with quote

It is also important (possibly) to understand 'why' you "don't have to fill in the EEPROM address", when using the EEPROM from inside the chip, but 'do' when programming.

The EEPROM is effectively a separate memory device 'built in' to the chip.
The chip itself, has a specific operation sequence to 'talk' to it's EEPROM, and the EEPROM appears using these instructions, starting at address '0'. So no 'address' needs to be known.

However when you program the device, you have the problem, that 'address 0' is already used by the flash memory. The manufacturers, don't want to use more pins to program the EEPROM device, so they 'cheat', and 'map' the EEPROM into the memory space at an address _above_ anything used by the chips. Hence on the PIC18, they stick it way up at 0xF00000, beyond even the 128K in use on some of these chips. On the older PIC16 devices, they put it at 0x2100, and on some of the newer PIC16's with more memory, they moved it higher. Since this is a trick for programming, the details are in the programming 'specs', rather than anywhere else. In use (and hence in the PIC data sheet, and for the read/write EEPROM instructions), the memory is at it's own 'address 0'.

Since the 'mobility' of this address became annoying, CCS added retrieving this to the getenv instruction. It was present for a while in about the mid 4.07x version compilers, before it appeared in the manual, so if your compiler is in this region, it might be worth just trying...

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