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 support@ccsinfo.com

lost eeprom data when eeprom address upper than 256(18f8722)

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



Joined: 19 Aug 2010
Posts: 4

View user's profile Send private message

lost eeprom data when eeprom address upper than 256(18f8722)
PostPosted: Thu Aug 19, 2010 3:03 pm     Reply with quote

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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Aug 19, 2010 3:06 pm     Reply with quote

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.
ali1_f



Joined: 19 Aug 2010
Posts: 4

View user's profile Send private message

PostPosted: Thu Aug 19, 2010 3:11 pm     Reply with quote

thanks for reply
but i declare "z" as int16
Code:

int16 z;
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Aug 19, 2010 3:24 pm     Reply with quote

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);
}
ali1_f



Joined: 19 Aug 2010
Posts: 4

View user's profile Send private message

PostPosted: Fri Aug 20, 2010 1:37 am     Reply with quote

Thanks for your reply.

Its working.

Best Regards
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