AnsweredAssumed Answered

Interfacing 24LC64 EEPROM to FRDM KL25-Z

Question asked by Wenderson Oliveira on Aug 28, 2014
Latest reply on Aug 25, 2017 by Radek Sestak

Hi all,

 

I'm trying to interfacing the 24LC64 EEPROM to my FRDM KL25-Z. I'm using the MQX Lite and CW 10.6 (just for you know).

My first try was follow the code from  Driver for Microchip 24xx Serial EEPROM | MCU on Eclipse , but unfortunately I'm unable to follow the code and build my own driver.

I'm trying to do this because I should have control about the blocking routines (like delays and waits), due to a lot of data processing at this same project, like PIT triggering a data logger (for example).

So, I've tried to write this:

 

byte buffer[3]; 
word sent;
byte data;
byte err;

//WRITE DATA
i2c_end = 0; //Variable is setting at CI2C1_OnReceiveData event
err = CI2C1_SelectSlave(0x50);           //Select address of the EEPROM device (not required if only one device on the bus)
buffer[0] = 0;                          //most significant byte of storage address
buffer[1] = 0x12;                       //least significant byte of storage address
buffer[2] = 0xA8;                       //data 
err = CI2C1_SendBlock(buffer, 3, &sent); //send storage address and data to the EEPROM
while(!i2c_end){}              //wait for communication completition
err = CI2C1_SendStop();                  //Send STOP condition

//10ms delay for EEPROM to complete write cycle - for more details see EEPROM datasheet
delay_ms(10); //#define delay_ms(x) _time_delay_ticks(((x)/SYST_TICK_TIME));

//READ DATA
i2c_end = 0;
buffer[0] = 0;                          //most significant byte of storage address
buffer[1] = 0x12;                       //least significant byte of storage address
err = CI2C1_SendBlock(buffer, 2, &sent); //send address to the EEPROM
while(!i2c_end){}
i2c_end = 0;
err = CI2C1_RecvChar(&data);             //read data from EEPROM 
while(!i2c_end){}
err = data;

 

But DATA is returning the value 0xFF (what I think is a error?).

 

Can anyone help?

 

Regards,

Outcomes