| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| pikman 
 
 
 Joined: 20 Dec 2004
 Posts: 4
 
 
 
			        
 
 | 
			
				| Driver for linear access of 8 memory 24LC512  512KB!! |  
				|  Posted: Sun Jan 07, 2007 10:17 pm |   |  
				| 
 |  
				| 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.   
 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
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Mon Jan 08, 2007 3:34 pm |   |  
				| 
 |  
				| Excellent Work Pikman 
 Could you be kind enough just to do a quick example program
 
 Thanks in advance
 _________________
 BOB_Santana
  |  | 
	
		|  | 
	
		| last_turk 
 
 
 Joined: 13 Sep 2006
 Posts: 3
 
 
 
			    
 
 | 
			
				| 64K x 8 (512 Kbit) |  
				|  Posted: Tue Mar 20, 2007 9:28 am |   |  
				| 
 |  
				| 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
 
 
 
			        
 
 | 
			
				|  |  
				|  Posted: Mon Apr 02, 2007 11:23 pm |   |  
				| 
 |  
				| 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
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Tue Apr 03, 2007 8:07 am |   |  
				| 
 |  
				| 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.
 |  | 
	
		|  | 
	
		|  |