losing my mind over i2c interfacing to 24lc00 eeprom

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

losing my mind over i2c interfacing to 24lc00 eeprom

Jump to solution
7,555 Views
steve_fae
Senior Contributor I

Using PE example, got communication between FRDM board and 24LC00 but can't seem to write a read accurately.

First I do a block write then block read using typical example for I2C component.

volatile bool DataReceivedFlg = FALSE;

volatile bool DataTransmittedFlg = FALSE;

uint8_t OutData[4] = {0x00U, 0x01U, 0x02U, 0x03U};                /* Initialization of output data buffer */

uint8_t InpData[16];

LDD_TError Error;

LDD_TDeviceData *MyI2CPtr;


pastedImage_1.png

First picture is writing of data to device, only two values the first being address zero, second data value of 1. 

Second picture is writing of control word and address zero to device in prep of reading

Third picture is the read

1 Solution
5,211 Views
steve_fae
Senior Contributor I

I think I have discovered the true problem.  The 24LC00 doesn't support sequential or page write.  It does support sequential read.  The app note I have been studying made it seem that all24LCxx devices supported some sort of page write. 

This is for the 24LC00

3575_3575.png

this is the 24LC01

3576_3576.png

View solution in original post

0 Kudos
43 Replies
5,212 Views
steve_fae
Senior Contributor I

I think I have discovered the true problem.  The 24LC00 doesn't support sequential or page write.  It does support sequential read.  The app note I have been studying made it seem that all24LCxx devices supported some sort of page write. 

This is for the 24LC00

3575_3575.png

this is the 24LC01

3576_3576.png

0 Kudos
2,185 Views
JimDon
Senior Contributor III

I think you are correct. That would explain why 0x5a ends up at address 0! You can only write one byte at a time...

0 Kudos
2,185 Views
barbercolman
Contributor III

This is my first try with the EE241 driver. Tried to include EE241 and I2C2 in a CW 10.3 project and getting no prototype errors for I2C2_SendStop(). Is this a know error or an I doing something wrong?

0 Kudos
2,185 Views
BlackNight
NXP Employee
NXP Employee

Hi dale,

is this about the 24AA_EEPROM Processor Expert component?

Erich

0 Kudos
2,185 Views
barbercolman
Contributor III

Yes. I am new to PE and found out I that the SendStop depends on the Automatic stop conditions in the internal I2C2 component. At this point I do not know if the change made by Markus Bättig in EE241.c should be used. Any suggestions?

0 Kudos
2,185 Views
BlackNight
NXP Employee
NXP Employee

Ok. So yes, you need to change the 'automatic stop' condition in the I2C component to have SendStop() available.

This should do it. Markus Bättig made that change a while back, and for him with this change things worked well (on ColdFire V2). But I have not investigated much into the problem. If you see any issues, let me know and I'll investigate further.

0 Kudos
2,185 Views
barbercolman
Contributor III

Hi

Just noticed the hardware was changes from a 24FC512 to a 24FC256! Any advice on changing from a 512 to a 256K part?

I am not used to PE so I am not sure where to look for property that specifies device size.

thanks

0 Kudos
2,185 Views
BlackNight
NXP Employee
NXP Employee

Hi Dale,

wow, hardware can change fast :-)

I checked the data sheet for the 24FC256, and from what I can tell it is compatible with the 24FC512. Anyway, I have implemented an option for the 256 part in the component (attached).

4801_4801.png

As I do not have a 256 device, I'm not able to test it. Report any problems you might see.

Keep in mind that I used the InternalI2C for this component only in non-interrupt mode. Enabling interrupt mode probably would take some efforts on my side to be supported, but I hope this is not critical for you right now.

I hope this helps,

Erich

0 Kudos
2,185 Views
barbercolman
Contributor III

Hi Eric,

The 24FC256 works with the revised code with the exception the EE241_PAGE_SIZE needs to be 64 byte for the 24FC256.

My next task is to get a interrupt driven version working. I have never written a PE component before, so looking at MCU oneclipso I found the “Creating a Processor Expert Component for an Accelerometer” article. Unless you have different advice I will start there and try to get a interrupt driven version working.

Thanks for you help.

0 Kudos
2,185 Views
BlackNight
NXP Employee
NXP Employee

Hi Dale,

thanks for pointing out the difference in PAGE_SIZE. I have changed this and pushed the component source to GitHub. Let me know if I need to create a *.PEupd package for you.

As for interrupts: I quickly checked the driver code, and I believe it should work in interrupt mode too. It is just that I do not have a test environment right now to verify it. So if it works for you in non-interrupt way: great. Now you can try the same thing with interrupts enabled (enable interrupts in the InternalI2C component) and check if it still works. Chances are good.

As for tutorials: Yes, that tutorial you mention is a starter for general component development. But it probably will not help much in your case here as things are more about changing an existing component and the underlying driver model. But a good starter anyway ;-)

I hope this helps.

0 Kudos
2,185 Views
barbercolman
Contributor III

Hi Erich,

I was able to download the new files with the 64 byte page size. However, I do not know how to create the component. Please create the PEupd or let me know how to use the new files. Thanks

0 Kudos
2,185 Views
BlackNight
NXP Employee
NXP Employee

There are *.PEupd files available on GitHub, see

Driver for Microchip 24xx Serial EEPROM | MCU on Eclipse

Additionally, I wrote an article how to use the 24xx EEPROMS with Kinetis here:

Driver for Microchip 24xx Serial EEPROM | MCU on Eclipse

I hope this useful.

Erich

0 Kudos
2,182 Views
hesamakbarian
Contributor II

Hi Erich,

Would you please let me know how should i find the 24AA_EEPROM Processor Expert component? i do not have such component in my compinent list. I am using code warrior v10.5.

Thanks,

Hesam

0 Kudos
2,182 Views
BlackNight
NXP Employee
NXP Employee

The components are available on GitHub, see Processor Expert Component *.PEupd Files on GitHub | MCU on Eclipse

0 Kudos
2,182 Views
hesamakbarian
Contributor II

Thanks, This is awesome!

Just to remind, in the list the 64 and 128 Kbits are not available and the last one should be 1024 instead of 1025.

Thanks,

0 Kudos
2,185 Views
steve_fae
Senior Contributor I

Any plans to add application notes for the spi eeproms? It turns out

Kinetis works wonderfully with them but the DSC family sends out a bunch

of clocks

on the SPI lines during boot which made it very challenging to

communicate with the part correctly.

Steven Cohen

0 Kudos
2,182 Views
BlackNight
NXP Employee
NXP Employee

I had one design with S08 and SPI EEPROM, but all my new projects are using the I2C interface. Maybe somebody else could share some thoughts?

0 Kudos
2,185 Views
JimDon
Senior Contributor III

I do see this error.

When you write the address for reading, you should send stop. You should not pass in LDD_I2C_NO_SEND_STOP. you should send LDD_I2C_SEND_STOP instead.

The write has nothing to do with the read. The write is just setting a register in the chip. When you do the read, it will send the address before reading,

0 Kudos
2,185 Views
steve_fae
Senior Contributor I

If I change it to SEND STOP, the interrupt never sets DataTransmittedFlg TRUE.  It just hangs there.

pastedImage_0.png

Wow, the Microchip data sheet doesn't state clearly that after the write you need to send a stop.

pastedImage_0.png

pastedImage_2.png

pastedImage_0.png

0 Kudos
2,185 Views
JimDon
Senior Contributor III

You are correct that it is not clear, because it also says:

If a Stop bit is transmitted to the device at any

point in the Write command sequence before the entire

sequence is complete, then the command will abort

and no data will be written.

Which I took to mean that you should write the address and then send stop, leaving the address register set, but perhaps this is contradicted by what the read command says. Figure 8-2 strongly suggests that you should not send the stop, although I don't understand why the tx would not complete. So I don't think what I said is correct, and that you should change it back.

You should at this point look at error conditions to see if the write is completing error free, and make certain that you do get an ack. I'll keep looking around.

0 Kudos
2,184 Views
KeshavaGN
Contributor V

Hi steve_fae ,

What problem you are facing?

You have written what you did.

But what error you are getting?

With regards,

Keshava G N

0 Kudos