cancel
Showing results for 
Search instead for 
Did you mean: 

I2C HAL_I2C_Mem_Read ( ) failed

Dick Lin
Senior

Hi,

I am working on I2C read EEPROM. The HAL function failed due to the I2C_FLAG_BUSY is always SET.

Is there anything I am missing in init code?

Thx

  if (I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_BUSY, SET, I2C_TIMEOUT_BUSY, tickstart) != HAL_OK)

  {

   return HAL_TIMEOUT;

  }

18 REPLIES 18
T J
Lead

m_i2c->read_from_address(0b10100000, 0xFA, 1, in_data, in_len);

that's incorrect.

read is 0b10100001

Dick Lin
Senior

You are right. I correct it OR to 0x01. Thx

T J
Lead

works now ?

now we find the next issue :(

its a difficult struggle to bring up code on a new chip.

best not to use blocking code, otherwise you will continually have issues...

Dick Lin
Senior

No, I corrected the READ command after you but still failing.

This is our existing driver for NXP MCP5777m. I just ported to STM32. Still seeing issue and it's on STM32 side for all of checking before sending I2C data out.

I am wondering if the init code not quite right. I am using MXCube code.

Thx

dbo
Associate II

0690X000006D8D0QAK.jpgHi,

I'm using HAL_I2c_Mem_Read(), too.

And may I ask if STM32's I2C can generate wave like the following picture. I have tryed Mem_read() and any other function in i2c.c , but the bit following device addres is "0",which means "write" in I2c.

May you help me out, thanks.

Yes, that doesn't look like the usual I2C method, which is to have a WRITE with the Register Address, and then a READ which pulls the data.

Probably going to need to bit-bang the frame here.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
dbo
Associate II

thanks for your reply,

I have bit-bang and success, but I just want to know may stm32's i2c hsrdware generate the ware, by the way the chip is infineon's tle493d-A2B6.

have a nice day.

This is often because you don't have pull-ups on the SDA and/or SCL lines (4.7k-10k). You can also enable the internal pull-ups in the MCU itself.

S.Ma
Principal


_legacyfs_online_stmicro_images_0693W00000dDHLSQA4.png24AA02E48/25E48/24AA02E64/25E64 Data Sheet (microchip.com)

Notice the Restart bit in the middle? That is true I2C.

It does not match your reference shared document.

Same device, really?