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

How to write an entire page of data to an EEPROM

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



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

How to write an entire page of data to an EEPROM
PostPosted: Fri Jun 24, 2005 5:27 am     Reply with quote

Hi,

Compiler: PCM
MCU : 16F628

Is it possible to write to an 24LC256 serial eeprom page wise, if so howe ???

thanks
arunb
Ttelmah
Guest







PostPosted: Fri Jun 24, 2005 6:02 am     Reply with quote

Arrow has been posting code to do exactly this (with a lot of discussion of why it is running slower than he expects).
The key thing is just to write the first byte to the start of the page, and then just keep writing the bytes for the entire page size. Only once all the bytes are sent, do you then issue the 'stop' command.
So for the S4LC16 (for example), using the definitions already in the 2416.c file, give:
Code:

//Here data is passed as the _address_ of a 16 byte buffer
void write_ext_eeprom(long int address, BYTE *data) {
   int8 ctr;
   while(!ext_eeprom_ready());
   i2c_start();
   i2c_write((0xa0|(BYTE)(address>>7))&0xfe);
   i2c_write(address);
   for (ctr=0;ctr<16;ctr++) i2c_write(data[ctr]);
   i2c_stop();
}

The write will actually start, when the 'stop' condition is sent. If the code is called again immediately, it'll sit in the 'wait for ready' loop, until the write finishes. Ideally your processor can go off and do something else for the time involved. Also the starting 'address', should be on a page boundary.

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