2024-12-03 01:34 AM - edited 2024-12-03 02:01 AM
I am using M24C04 chip and downloaded the software package EEPRAM2.
if(EEPRMA2_M24_Init(EEPRMA2_M24C02_0) == BSP_ERROR_NONE)
{
chip_ok=1;
// DOUBLEFLASH();
}
else
{
chip_ok=0;
}
if I used this instance it says chip ok=1 but the read and write not working .As using M24C04 ,I also tried the instance as
if(EEPRMA2_M24_Init(EEPRMA2_M24xx) == BSP_ERROR_NONE)
{
chip_ok=1;
// DOUBLEFLASH();
}
else
{
chip_ok=0;
}
it says the chip is not working
2024-12-03 01:44 AM
You forgot to show your code, so it's hard to help you.
Use HAL_I2C_MewWrite and MemRead family functions. They are described in HAL Reference.
2024-12-03 01:48 AM
@meena wrote:the drivers not working for me.
What "driver"?
Hardware details?
Please see the Posting Tips:
2024-12-03 02:08 AM
void testEEPROM()
{
// Write data to EEPROM
if (HAL_I2C_Mem_Write(&hi2c1, 0x50, memAddress, I2C_MEMADD_SIZE_8BIT, dataToWrite, 2, 1000)== HAL_OK) {
// Handle Write Error
i2c_write=1;
return;
}
// Read data from EEPROM
if (HAL_I2C_Mem_Read(&hi2c1, 0x50, memAddress, I2C_MEMADD_SIZE_8BIT, dataRead, 2, 1000)== HAL_OK) {
i2c_read=1;
return;
}
// Check if the written data matches the read data
if (dataRead[0] == dataToWrite[0] && dataRead[1] == dataToWrite[1]) {
i2c_test=1;
} else {
i2c_test=0;
}
}
Hi I tried this to but i dont know why its not working
2024-12-03 02:16 AM
The EEPROM address should be shifted - 0xa0 instead of 0x50.
2024-12-03 02:18 AM - edited 2024-12-03 02:34 AM
@meena wrote:Hi I tried this to but i dont know why its not working
Again, please pay attention to the Posting Tips:
You need to give details of your hardware setup - it might not even be a software issue.
And tell us what investigation/testing/debugging you have done to find the problem(s).
Have you used an oscilloscope to check what's happening on the wires?
if (HAL_I2C_Mem_Read(&hi2c1, 0x50, memAddress, I2C_MEMADD_SIZE_8BIT, dataRead, 2, 1000)== HAL_OK)
You're just checking for the HAL_OK return value
2024-12-03 04:19 AM
this is memory chip connected to the MCU U11 is the memory chip .Can you please tell me the I am using the correct software.I have downloaded EEPRAMA2 which says instance as M24C02 probe