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

18F #ROM EEPROM

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



Joined: 05 Sep 2007
Posts: 46
Location: Londrina - Brazil

View user's profile Send private message

18F #ROM EEPROM
PostPosted: Wed Mar 04, 2009 5:29 am     Reply with quote

Hi

I was using a program with PIC16F876. This program has at start the directive:

Code:
#ROM 0x2100 = {1,2,3,4}


So, when this program was writed it worked well, and initial EEPROM values were right.

Then using the same program, I migrated to PIC18F2420. I'v changed the #ROM to:

Code:
#ROM 0xF00000 = {1,2,3,4}


And something strang happend. At EEPROM looks like:

Adress 0: 1
Adress 1: 0
Adress 2: 2
Adress 3: 0
Adress 4: 3
Adress 5: 0
Adress 6: 4
Adress 7: 0

It appears to using 2 bytes for each number I write. How this could happen?
I was expecting the same behavior that PIC16F have.

CCS PCH C Compiler, Version 4.084
Using CCS C Plugin for MPLAB and Programming in MPLAB.
Thanks!
_________________
Give a man a fish and you'll feed him for a day. Teach a man to fish, and you'll feed him for a lifetime.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Mar 04, 2009 6:18 am     Reply with quote

Quote:
How this could happen?

The behaviour is by design. PCM has 14-Bit ROM and word addressing, so 8-Bit data is placed to consecutive ROM words. PCH has 16-Bit ROM and byte addressing. #ROM data is interpreted as int16 by default, so you get zero high bytes. By specifying #ROM int8 option, you can place byte data to consecutive byte addresses.
rhaguiuda



Joined: 05 Sep 2007
Posts: 46
Location: Londrina - Brazil

View user's profile Send private message

PostPosted: Wed Mar 04, 2009 6:33 am     Reply with quote

Thanks FvM

It works!
_________________
Give a man a fish and you'll feed him for a day. Teach a man to fish, and you'll feed him for a lifetime.
mpaulao



Joined: 30 Aug 2011
Posts: 1
Location: Brasil

View user's profile Send private message MSN Messenger

Use #rom int 8 option
PostPosted: Fri Jan 06, 2012 5:31 pm     Reply with quote

Hello FvM!

I want information about #rom directive.
Your response save me!

Thank you!

Marcos Paulão
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