cancel
Showing results for 
Search instead for 
Did you mean: 

EEPROM_I2c

meena
Associate III

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

 

6 REPLIES 6
gbm
Lead III

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.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

@meena wrote:

 the drivers not working for me.


What "driver"?

Hardware details?

Please see the Posting Tips:

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228

meena
Associate III
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

 

The EEPROM address should be shifted - 0xa0 instead of 0x50.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

@meena wrote:

Hi I tried this to but i dont know why its not working


Again, please pay attention to the Posting Tips:

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228

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

  • Are your HAL_I2C_... calls returning HAL_OK ?
  • If not, what are they returning? What does that tell you?

 

WhatsApp Image 2024-12-03 at 12.13.16.jpegthis 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