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

Driver for linear access of 8 memory 24LC512 512KB!!

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
pikman



Joined: 20 Dec 2004
Posts: 4

View user's profile Send private message Yahoo Messenger MSN Messenger

Driver for linear access of 8 memory 24LC512 512KB!!
PostPosted: Sun Jan 07, 2007 10:17 pm     Reply with quote

Hello, this simple driver allows to address 8 serial eeproms 24LC512 as one chip of 512KB (524.288 bytes), in my develop it has been of a lot of help, I hope also helps. Very Happy

Ariel.

Code:

///////////////////////////////////////////////////////////////////////////////////
////        Library for lineal address to a bank of 8 24LC512 chip memory      ////
////                                                                           ////
////        0 to 0x07FFF                                                       ////
////                                                                           ////                                                                         ////
//// init_24512x8();  Call before the other functions are used                 ////
////                                                                           ////
//// writeByte24512x8(a,d); Write the byte (int8)d to the address (int32)a     ////
////                                                                           ////
//// d=ReadByte24512x8(a); Read the byte int8)d from the address (int32)a      ////
////                                                                           ////
////                                                                           ////
///////////////////////////////////////////////////////////////////////////////////



#ifndef EEPROM_SDA

#define EEPROM_SDA  PIN_B1
#define EEPROM_SCL  PIN_B0

#endif

#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)

#define MULTIPLE_EEPROM_ADDRESS int32
#define EEPROM_SIZE   524288

void init_ext_eeprom()
{
   output_float(EEPROM_SCL);
   output_float(EEPROM_SDA);

}


void writeByte_24512x8(int32 memaddress, int8 data){

   int16 address;
   int8  controlbyte;
   short int status;
   
   address=memaddress;

   controlbyte=(0xa0 | ((make8(memaddress,2))<<1));

   i2c_start();
   i2c_write(controlbyte);
   i2c_write(address>>8);     
   i2c_write(address);         
   i2c_write(data);           
   i2c_stop();
   // AckNolege pooling
   i2c_start();
   status=i2c_write(controlbyte);
   while(status==1)
   {
   i2c_start();
   status=i2c_write(controlbyte);
   }
   i2c_stop();
}



int8 readByte_24512x8(int32 memaddress){

    int16 address;
    int8  controlbyte;
    int8  data;

    address=memaddress;
    controlbyte=(0xa0 | ((make8(memaddress,2))<<1));


    i2c_start();
    i2c_write(controlbyte);
    i2c_write(address>>8);
    i2c_write(address);             
    i2c_start();
    i2c_write(controlbyte|1); 
    data=i2c_read(0);
    i2c_stop();
    return data;
}




Last edited by pikman on Sun Jan 07, 2007 10:23 pm; edited 2 times in total
BOB_SANTANA



Joined: 16 Oct 2006
Posts: 110
Location: HOVE, EAST SUSSEX

View user's profile Send private message

PostPosted: Mon Jan 08, 2007 3:34 pm     Reply with quote

Excellent Work Pikman

Could you be kind enough just to do a quick example program

Thanks in advance
_________________
BOB_Santana Smile
last_turk



Joined: 13 Sep 2006
Posts: 3

View user's profile Send private message

64K x 8 (512 Kbit)
PostPosted: Tue Mar 20, 2007 9:28 am     Reply with quote

24AA512/24LC512/24FC512 (24XX512*) is a 64K x 8 (512 Kbit)
and eeprom address must be 0 to 0xFFFF
thanks for all
pikman



Joined: 20 Dec 2004
Posts: 4

View user's profile Send private message Yahoo Messenger MSN Messenger

PostPosted: Mon Apr 02, 2007 11:23 pm     Reply with quote

last_turk, I don't understant, my driver is to use whit 8 units 24AA512/24LC512/24FC512, is right you point there are 64KB (512 Kbit), but every one, 64kb x 8 = 512Kb ( or best 524288 bytes ), then adress you must enter is 0 to 0x07FFF, and not 0 to 0xFFFF as you say, when you use this driver of course.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Apr 03, 2007 8:07 am     Reply with quote

According to spec sheet section 5.1 there are 19 bits of address A0->A15 and
chip select bit A0,A1,A2.

I wrote a simular driver for a FRAM FM24C256
http://www.ccsinfo.com/forum/viewtopic.php?t=24099

But in my driver I use a multi-read to speed things up. And in that
multi read my driver can go accross chip boundries.

Have you thought about that?

Here is your spec sheet.
http://ww1.microchip.com/downloads/en/DeviceDoc/21754G.pdf
see page 8 5.1 Contiguous Addressing Across Multiple Devices
and page 9 6.2 Page Write ((what i call multiwrite)) up to 127 more writes.
and 8.3 Sequential Read.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library 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