2017-08-25 04:11 AM
Hello,I'm trying to use this code to write/read a EEPROM 24C02,but it's not working,what i'm doing wrong?
Could someone post a example please?
uint8_t eedget[1],eedata[1];
void main()
{
eedata[0] = 0x01;
eedata[1] = 0x02;
while(1)
{
HAL_I2C_Mem_Write(&hi2c1,0x00A0,0x0000,0x0008,eedata,1,1000);
HAL_I2C_Mem_Read(&hi2c1,0x00A1,0x0000,0x0008,eedget,1,1000);}
}
2017-08-25 11:14 AM
If sending 8 bytes, make the array exist for the 8 bytes...
uint8_t eedget[8],eedata[8];
who said the memory locations after the reserved one for the array exist in the SRAM?
Check the input parameter of the function, to write from location 0x00 the value 0x01 you need to write S.A0a.00a.01a.P (wait 10 msec) S.A0a.00a.S.A1.a.xx.n.P where xx is expected to be 0x01.
Try to to use a fixed value as if it works once and fail the next, you won't detect it.
Read the byte, XOR 0xFF then write the value back. Everytime you run the code, you will be able to make sure, even if you power off the application....
2017-09-07 02:50 AM
Hello,
Have a look to the
https://community.st.com/0D50X00009XkW1qSAF
,it may be helpful.
You have a full set of running
I2C EEPROM
examples within the STM32Cube firmware package.BestRegards
Imen