View previous topic :: View next topic |
Author |
Message |
ali1_f
Joined: 19 Aug 2010 Posts: 4
|
lost eeprom data when eeprom address upper than 256(18f8722) |
Posted: Thu Aug 19, 2010 3:03 pm |
|
|
hi
In this program when I read my stored data in eeprom data has been changed to 1.
Code: |
#define FirstAddOfEachCabinCalls 300 // save in this space : from 300 to 332
for(z=0;z<32;z++)R_EachCabinCalls[z]=read_EEPROM(FirstAddOfEachCabinCalls+z);
|
When I change "FirstAddOfEachCabinCalls" to 200 the eeprom stored data
are right.
I think read_EEPROM() function cant read address upper than 256.
thanks ![Very Happy](images/smiles/icon_biggrin.gif) |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 19, 2010 3:06 pm |
|
|
You probably declared 'z' as 'int'. In CCS, for the PCH compiler, an 'int'
is only 8 bits. Declare it as 'int16'. Then it will be a 16-bit variable.
The CCS data types are given in the CCS manual. |
|
![](templates/subSilver/images/spacer.gif) |
ali1_f
Joined: 19 Aug 2010 Posts: 4
|
|
Posted: Thu Aug 19, 2010 3:11 pm |
|
|
thanks for reply
but i declare "z" as int16
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 19, 2010 3:24 pm |
|
|
Try a very simple test program, such as the one shown below.
I ran it in MPLAB simulator with vs. 4.110 and I got this result:
Quote: |
Initial values: 55, aa
After writing: 12, 34
|
That's correct. Try it and see what you get. If it fails, then post your
compiler version.
Code: |
#include <18F8722.h>
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#rom int8 0xf00000={0x55, 0xAA}
//==========================
main()
{
int8 a;
int8 b;
a = read_eeprom(0);
b = read_eeprom(1);
printf("Initial values: %x, %x \n\r", a, b);
write_eeprom(0,0x12);
write_eeprom(1,0x34);
a = read_eeprom(0);
b = read_eeprom(1);
printf("After writing: %x, %x \n\r", a, b);
while(1);
} |
|
|
![](templates/subSilver/images/spacer.gif) |
ali1_f
Joined: 19 Aug 2010 Posts: 4
|
|
Posted: Fri Aug 20, 2010 1:37 am |
|
|
Thanks for your reply.
Its working.
Best Regards |
|
![](templates/subSilver/images/spacer.gif) |
|