Hi,
I am working on S32K144 LPI2C driver. While reading from slave(EEPROM), at a time I am able to read only 4 Bytes. If I am trying to read more than four bytes then garbage characters are coming except those four byte. After reading first four bytes, for next four bytes FEF bit is setting. I am trying to clear FEF by writing 1 but it is not clearing.
How to transmit and receive data without using FIFO. if possible help with example code. I tried with S32K example code it is also with FIFO and I am facing same issue here also.
Please help....
Thanks and Regard,
Ravi Ranjan Kumar.
Hi,
I tested the LPI2C_master example and tested it with EEPROM (PCA24C08). Seems it is working normally.
Within an component inspector I changed Slave address to 0x54
then modified demo code to write 8 bytes to memory and read it back
/* Initialize LPI2C Master configuration
* - Slave address 0x01
* - Fast operating mode, 400 KHz SCL frequency
* - See LPI2C components for configuration details
*/
LPI2C_DRV_MasterInit(INST_LPI2C1, &lpi2c1_MasterConfig0, &lpi2c1MasterState);
txBuffer[0] = 0x0; // first byte define the memory/register address
/* Initialize the data buffer */
for (i = 1u; i < TRANSFER_SIZE+1; i++)
{
txBuffer[i] = i;
}
/* Send a packet of data to the bus slave */
LPI2C_DRV_MasterSendDataBlocking(INST_LPI2C1, txBuffer, TRANSFER_SIZE+1, true, OSIF_WAIT_FOREVER);
/* Request data from the bus slave */
/* Just register address will be sent after Slave address so total 2 bytes, STOP is not generated */
/* During the E/W cycle the slave receiver does not acknowledge if addressed */
while (STATUS_I2C_RECEIVED_NACK == LPI2C_DRV_MasterSendDataBlocking(INST_LPI2C1, txBuffer, 1, false, OSIF_WAIT_FOREVER));
/* Repeate Start is issued following Slave address and waiting reading for 8 bytes */
LPI2C_DRV_MasterReceiveDataBlocking(INST_LPI2C1, rxBuffer, TRANSFER_SIZE, true, OSIF_WAIT_FOREVER);
/* End of the driver example */
I was able to write and read data back, see below bus signals...
writing...
reading...
BR, Petr
Hi Petr,
Thanks for reply. It was really very helpful for me. I took txBuffer[0] as a data bit. Thank you so much.
Thanks and Regard,
Ravi Ranjan Kumar.