hi,
I use the LPC11C24 i2c and AT24C16 communication,I am using NXP official example.as follew:
/* Master tx only */
int Chip_I2C_MasterSend(I2C_ID_T id, uint8_t slaveAddr, const uint8_t *buff, uint8_t len)
{
I2C_XFER_T xfer = {0};
xfer.slaveAddr = slaveAddr;
xfer.txBuff = buff;
xfer.txSz = len;
while (Chip_I2C_MasterTransfer(id, &xfer) == I2C_STATUS_ARBLOST) {}
return len - xfer.txSz;
}
/* Sequential master read */
int Chip_I2C_MasterRead(I2C_ID_T id, uint8_t slaveAddr, uint8_t *buff, int len)
{
I2C_XFER_T xfer = {0};
xfer.slaveAddr = slaveAddr;
xfer.rxBuff = buff;
xfer.rxSz = len;
while (Chip_I2C_MasterTransfer(id, &xfer) == I2C_STATUS_ARBLOST) {}
return len - xfer.rxSz;
}
Who can give me some examples of reading and writing?
Hi VN V,
I don't have the LPC11C24 I2C code for AT24C16 directly.
But we have some I2C code for PCF8594, I think you can refer to it.
Please download the code from this link:
1. MDK project
Sample Code Bundle for LPC11xx Peripherals using Keil's MDK-ARM | www.LPCware.com
2. LPCxpresso IDE project
Sample Code Bundle for LPC11xx Peripherals using NXP LPCXpresso | www.LPCware.com
Please download the code, and refer to lpc11xx.keil-examples-CMSIS-update_2\lpc11xx.keil-examples-CMSIS-update\ADC
There has the I2C write and read code.
With it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------