cancel
Showing results for 
Search instead for 
Did you mean: 

I2C addressing issue

VThan.2
Associate III

Hello all, I am new to the STM32 environment. I have a Rasberry pi's I2C lines connected to a NUCLEO-L552ZE-Q on the I2C2 peripheral on pin PF0 and PF1. I have set up the address to 0x50. I have attached a text file showing different instantiations and declarations on my STM32 I2C initialization. But whenever I try to detect the I2C the pi does not detect it. Any advise would be appreciated. Thank you

0693W00000Hq0N2QAJ.png

7 REPLIES 7
TDK
Guru

Do you have an external pullup on SDA and SCL? Do you have a logic analyzer or scope to see what is on those lines?

The code you show doesn't actually call any HAL_I2C_Slave_* functions. I don't believe the STM32 will ACK simply after calling HAL_I2C_Init.

If you feel a post has answered your question, please click "Accept as Solution".
Shirley.Ye
ST Employee

in the code attached you just have only initiate the i2c peripheral, no transmit functions. need to add functions such as HAL_I2C_Master_Transmit/HAL_I2C_Master_Receive.

VThan.2
Associate III

Hello, Thank you for your time and reply. Here is a screen capture from a logic analyzer.

0693W00000Hq6NIQAZ.png0693W00000Hq6NSQAZ.pngSorry I am still confused. I am trying to get an address acknowledge. Shouldn't my initiated interrupt, handle that for me? These 2 lines are my interrupt instantiation.

  HAL_NVIC_SetPriority(I2C2_EV_IRQn, 0, 0);

  HAL_NVIC_EnableIRQ(I2C2_EV_IRQn);

I am not writing or reading any data. Just doing an address run through.

Once again thank you for your time. Help is much appreciated

VThan.2
Associate III

I also think my SDA line is always low after the data has been sent by the pi. But the SCL comes up. The SDA comes back up only when the reset on the MCU is pressed. Which makes me not confident about the instantiation of I2C in that text file. Please correct me if I am wrong

0693W00000Hq6QgQAJ.pngThank you

VThan.2
Associate III

Got it resolved. Thanks

aston
Associate II

How did you solve it

VThan.2
Associate III

I solved it based on TDK and Shirley's answers. I just added a line for slave receive. Thank you