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

Library for a 24LC512 serial EEPROM question

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



Joined: 19 Jun 2017
Posts: 27

View user's profile Send private message

Library for a 24LC512 serial EEPROM question
PostPosted: Thu Jul 27, 2017 6:52 am     Reply with quote

Code:
void write_ext_eeprom(EEPROM_ADDRESS locEE, unsigned int8 data)
{
   disable_interrupts(global);
   
   unsigned int8 status;
   
   i2c_start(SHARED_STREAM_I2C_EEPROM);
   i2c_write(SHARED_STREAM_I2C_EEPROM, EEPROM_SLAVE_ADDRESS);
   i2c_write(SHARED_STREAM_I2C_EEPROM, make8(locEE, 1));
   i2c_write(SHARED_STREAM_I2C_EEPROM, make8(locEE, 0));
   i2c_write(SHARED_STREAM_I2C_EEPROM, data);
   i2c_stop(SHARED_STREAM_I2C_EEPROM);

   do
   {
      i2c_start(SHARED_STREAM_I2C_EEPROM);
      status = i2c_write(SHARED_STREAM_I2C_EEPROM, EEPROM_SLAVE_ADDRESS);
   } while(status==1);
   i2c_stop(SHARED_STREAM_I2C_EEPROM);
   enable_interrupts(global);
}


Is this code absolutely necessary? and which is, its purpose?
Code:
   do
   {
      i2c_start(SHARED_STREAM_I2C_EEPROM);
      status = i2c_write(SHARED_STREAM_I2C_EEPROM, EEPROM_SLAVE_ADDRESS);
   } while(status==1);
   i2c_stop(SHARED_STREAM_I2C_EEPROM);



also is it possible to write sequentially at arbitrary addresses? or its the adress only specified at just after the start? where can i find info about it.


Thanks in advance!
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jul 27, 2017 7:15 am     Reply with quote

Working backwards....

The BEST place to get information about the 24LC512 is from manufacturer. I just downloaded the Microchip datasheet for their device.

Yes, you can write at any individual address, check the chapter called 'write operations' in the datasheet.

You also need to know that every 'single' byte write will take up to 5ms. So if you want to save 100 bytes that will take up to 1/2 second.

Now there is a 'page ' write option and by using it, you can store the same 100 bytes of data in just 5 ms !! A 'page' for this device is 128 bytes, so a clever programmer will create a RAM buffer of 128 bytes and write a page as it's a LOT faster.

How you write to the device will depend upon how much data you need to save at one time and how often. Typically my 'datalogger' will store data in RAM until the buffer is full OR a time limit is tripped.

As for the code ... it might be a 'wait until ready' function or a 'release the bus' function. Just contact the original coder and ask.
Jay
Alphada



Joined: 19 Jun 2017
Posts: 27

View user's profile Send private message

PostPosted: Thu Jul 27, 2017 7:22 am     Reply with quote

temtronic wrote:
Working backwards....

The BEST place to get information about the 24LC512 is from manufacturer. I just downloaded the Microchip datasheet for their device.

Yes, you can write at any individual address, check the chapter called 'write operations' in the datasheet.

You also need to know that every 'single' byte write will take up to 5ms. So if you want to save 100 bytes that will take up to 1/2 second.

Now there is a 'page ' write option and by using it, you can store the same 100 bytes of data in just 5 ms !! A 'page' for this device is 128 bytes, so a clever programmer will create a RAM buffer of 128 bytes and write a page as it's a LOT faster.

How you write to the device will depend upon how much data you need to save at one time and how often. Typically my 'datalogger' will store data in RAM until the buffer is full OR a time limit is tripped.

As for the code ... it might be a 'wait until ready' function or a 'release the bus' function. Just contact the original coder and ask.
Jay


Thanks alot for real it helped me a lot im gonna analyze the buffer idea.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Thu Jul 27, 2017 9:16 am     Reply with quote

If you look in the code library:

<http://www.ccsinfo.com/forum/viewtopic.php?t=39135&highlight=eeprom>

This is for the 256Kbit ROM, not the 512, but shows how 'page' reads and writes can be done. Basically check the data sheet and change the page size to match your chip.
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