View previous topic :: View next topic |
Author |
Message |
rhaguiuda
Joined: 05 Sep 2007 Posts: 46 Location: Londrina - Brazil
|
18F #ROM EEPROM |
Posted: Wed Mar 04, 2009 5:29 am |
|
|
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
|
|
Posted: Wed Mar 04, 2009 6:18 am |
|
|
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
|
|
Posted: Wed Mar 04, 2009 6:33 am |
|
|
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
|
Use #rom int 8 option |
Posted: Fri Jan 06, 2012 5:31 pm |
|
|
Hello FvM!
I want information about #rom directive.
Your response save me!
Thank you!
Marcos Paulão |
|
|
|