View previous topic :: View next topic |
Author |
Message |
stekarn
Joined: 09 May 2005 Posts: 1
|
Adresses for PICs internally eeprom? |
Posted: Mon May 09, 2005 4:03 am |
|
|
Hello, i am writing to the PIC 18f458 internally eeprom. Im using this code:
Code: |
write_eeprom(0,'A');
write_eeprom(1,'B');
|
I wonder, the first number 0, 1 i understand is the adress in the memory, but one thing i dont under stand, my pic have 256 bytes of eeprom, is 0 the first byte, the 1 the second byte ..... ???
My problem is if i write:
Code: |
write_eeprom(0,'A');
write_eeprom(1,'B');
write_eeprom(300,'C');
|
Am i writing to the 301 byte then, but this seem to be strange because i have only 256 bytes of eeprom.
But everything work when i write and the read from the eeprom and sends the data to hyperterminal via RS232.
Is there something here i have misunderstood?
Can anyone explain this thing for me?
Best (beginner) regards /Stekarn |
|
|
valemike Guest
|
|
Posted: Mon May 09, 2005 6:24 am |
|
|
When you write to location 300, perhaps you're actually wrapping around and writing to: 300 - 255 = 45. Who knows.
I'm not sure on the internals on this. Just make sure you don't write to anything else past 255! |
|
|
stekarn
Joined: 09 May 2005 Posts: 1
|
|
Posted: Tue May 10, 2005 2:25 am |
|
|
But wouldnt the compiler give me an error message if i try to write outside the eeprom memory adresses? |
|
|
valemike Guest
|
|
Posted: Tue May 10, 2005 6:42 am |
|
|
If your program compiles just fine, then obviously you're not getting flagged with an error nor warning.
Register EEADR is an 8-bit register.
Similiarly, you may or may not be flagged if you attempt the following assignment:
int x;
...
x= 300;
The 300 is simply truncated when you try to put it in x. |
|
|
|