I have MK60DN512VLL10 that has its I2C1 connected to EEPROM (ST Microelectronics - datasheet pdf) M24256-BWDW6
I removed the pull up on WC signal above.
following the above write sequence in my application I have:
Then based on the read sequence:
My read looks like:
But this returns me 0xff (printf result is 0xff 0x0 0x0 0x0 0x0), that means either I did not write or I cannot read?
As you can see from the above code snippets, my I2C1 is interrupt based:
Can someone tell me what is wrong? And why I cannot write/read EEPROM?
Thanks
Mehdi
Hi Medhi,
The problem has been handle through Service Request process.
The SR is 1-1342499221
Have a great day,
Pascal
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Just to add that as I stated in my last post above, I could write and read but I cannot write and read in sequence. Is there such a rule for I2C EEPROMs to write and read separately?
Hi Mehdi,
I received feedback for Proceesor Exper team which could explain the EEPROM behavior.
See below:
It is a feature of the EEPROM device.
Write cycle takes up to 5ms.
It is not responsibility of I2C bus protocol in general.
Have a great day,
Pascal
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Mehdi,
Thanks for the feedback and survey.
I shared this information with Processor Expert team and development.
Have a great day,
Pascal
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi @Jorge_Gonzalez
Can you please give me an example based on the EEPROM read/write format above.
based on Figure8 and Figure9 that I showed above, would the following work:
uint8 buffer[4];
buffer[0] = 0x57 //address of the slave
buffer[1] = 0x00 // first byte address
buffer[2] = 0x00 //second byte address
buffer[3] = 0x55 // one byte data
I2C1_SelectSlaveDevice(I2C1ptr, LDD_I2C_ADDRTYPE_7BITS, passin[0]);
Sent = 0;
I2C1_MasterSendBlock(I2C1ptr, passin , sizeof(passin), LDD_I2C_SEND_STOP); //LDD_I2C_SEND_STOP LDD_I2C_NO_SEND_STOP
while (Sent == 0){}
I tried this and it did not work. Do you have any suggestions?
Hi Medhi:
Each call to MasterSendBlock() generates a new start signal together with the address, as you see in your scope.
To avoid this try placing together all your data. If you look at Figure 8 above, you may use a unique buffer with [Byte addr + Byte addr + Data in] in the same buffer.
As reference here you have some code:
uint8 pass_buff[3];
uint8 passin;
pass_buff[0] = 0x00;
pass_buff[1] = 0x00;
pass_buff[2] = 0x55;
passin = 0x57;
I2C_SelectSlaveDevice(I2C1ptr, LDD_I2C_ADDRTYPE_7BITS, passin);
Sent = 0;
I2C1_MasterSendBlock(I2C1ptr, &pass_buff , sizeof(pass_buff), LDD_I2C_SEND_STOP);
while (Sent == 0){}
Regards!
Jorge Gonzalez
The whole transmission frame is complete according to your scope. Then we need to track down the problem with the debugger.
You can start by setting a breakpoint inside of the OnMasterBlockSent(), just to confirm that it never reaches that line.
Next step is to analyze the code in the interrupt routine PE_ISR(I2C1_Interrupt). I know it is a lot of code, but the problem resides in there.
n/a
I think that should be working.
So, in your last code there are 3 while loops, if I understood correctly you can already passed the first one and now you are stuck in the second while loop?
I do not know what is the cause, but again it would be helpful to check it with the scope.
Hi Jorge,
So I checked it with scope. Here is what's happening, I cannot do write and read in sequence but I can do them separately. I don't know why? Do you have any idea why?
I wrote to address 0x0000 first time. I wrote the value 0x55. So my 0x55 stored at address zero of my eeprom. I removed write and do the read of that byte. When I do that I can read 0x55 back, which means it wrote to that address and stores it there coreclty.
But do you have any idea why I cannot do this in sequence and it get stuck in the while loop for read?
Here is my latest code:
Your code seems OK to me.
Check the bus with your scope to verify the activity.