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

PIC 16f877a EEPROM Accessing

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



Joined: 23 May 2015
Posts: 4
Location: chennai

View user's profile Send private message

PIC 16f877a EEPROM Accessing
PostPosted: Sat May 23, 2015 7:17 am     Reply with quote

Good morning..

I have PIC 16f877a. Now i write the value 300 in this pic EEPROM
I am using following Syntax its only store the value 0 to 255.
so Pls Guid to store the value of 300 in this pic eeprom.

write_eeprom (0x00,300);
i=read_eeprom (0x00);


pls send the syntax
jeremiah



Joined: 20 Jul 2010
Posts: 1342

View user's profile Send private message

PostPosted: Sat May 23, 2015 7:42 am     Reply with quote

300 is not an int8 value (0-255 are int8 values).

You either need to use an int16 value and split it/merge it:

Code:

unsigned int16 value = 300;
unsigned int16 result = 0;

write_eeprom(0x00,make8(value,1));
write_eeprom(0x01,make8(value,0));

result = make16(read_eeprom(0x00),
                read_eeprom(0x01));



or if the compiler has pointer/length write_eeprom and read_eeprom support for your chip:

Code:

unsigned int16 value = 300;
unsigned int16 result = 0;

write_eeprom(0x00,&value,sizeof(unsigned int16));
read_eeprom(0x00,&result,sizeof(unsigned int16));
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