Hi,
I am working on MCB2300(LPC2387). I have used its sample code for Temperature sensing using I2C and its working fine. Now I have connected EEPROM (AT24C02) with microcontroller to store some data. For that I have used same code and did some changes to write and read data from EEPROM. But its not working properly. Below is changes which I have done.
int main (void) { DWORD i; if ( I2CInit( (DWORD)I2CMASTER ) == FALSE ) /* initialize I2c */ { while ( 1 ); /* Fatal error */ } /* Configure temp register before reading */ for ( i = 0; i < BUFSIZE; i++ ) /* clear buffer */ { I2CMasterBuffer[i] = 0; } I2CWriteLength = 3; I2CReadLength = 0; I2CMasterBuffer[0] = 0xA0; I2CMasterBuffer[1] = 0x00; I2CMasterBuffer[2] = 0x10; /* configuration value, no change from default */ I2CCmd = LM75_CONFIG; I2CEngine(); for ( i = 0; i < BUFSIZE; i++ ) /* clear buffer */ { I2CMasterBuffer[i] = 0; } I2CWriteLength = 2; I2CReadLength = 1; I2CMasterBuffer[0] = 0xA1; I2CMasterBuffer[1] = 0x00; I2CCmd = 0xA0; I2CEngine(); }
Suggest me where I have done mistake. any link of tutorial for R/W data using LPC2387 will be appreciated. Hope for best solution.
Thanks Dhaval
"Sounds similar to the STM32's I2C..."
maybe you are looking at different stm32s, :)
here is from the st library for stm32:
void I2C_Init(I2C_TypeDef* I2Cx, I2C_InitTypeDef* I2C_InitStruct); void I2C_GenerateSTART(I2C_TypeDef* I2Cx, FunctionalState NewState); void I2C_GenerateSTOP(I2C_TypeDef* I2Cx, FunctionalState NewState); void I2C_AcknowledgeConfig(I2C_TypeDef* I2Cx, FunctionalState NewState); void I2C_Send7bitAddress(I2C_TypeDef* I2Cx, uint8_t Address, uint8_t I2C_Direction); void I2C_SendData(I2C_TypeDef* I2Cx, uint8_t Data); uint8_t I2C_ReceiveData(I2C_TypeDef* I2Cx);
does it look like they are even remotely similar to the lpc code?