2023-10-22 11:41 PM
I am trying to use the external i2c connector (CN4) on the STM32H753I-Eval2 board to connect with the i2c connector (CN2) on STM32F769I discovery board. STM32H753I works as master and STM32F769I works as slave.
On STM32H753I, the function "HAL_I2C_Master_Transmit(&hi2c1, 0x20, TxBuffer, TXBUFFERSIZE, 1000)" is used to write data. It always fails at "I2C_WaitOnTXISFlagUntilTimeout(hi2c, Timeout, tickstart)" with the error of timeout. It seems the slave ACK is never received on the master board. I use STM32CubeMX to create the code and "MX_I2C1_Init()" return without any error. I also follow steps here to set up I2C1 in STM32CubeMX (https://wiki.st.com/stm32mcu/wiki/Getting_started_with_I2C#I2C_settings).
Any insight is appreciated! Thanks!
Solved! Go to Solution.
2023-10-24 12:35 PM - edited 2023-10-25 02:05 PM
Now I got 3.3v from pin 5 (I don't know why it was measured 0v yesterday, maybe wrong pin was taken). But "HAL_I2C_IsDeviceReady" still can not find the slave device. With the slave board disconnected, the master board found 3 slave I2C devices (display, MFX and audio) on I2C1. With the slave board connected by I2C extension connector, none slave device is detected. I think it is because the I2C1 on the slave board is used as a master too (display and audio), it can not be used as a slave. I have to use I2C2/3/4 instead?
2023-10-23 06:33 AM - edited 2023-10-23 06:33 AM
Does the slave board have power? Are SDA/SCL connected appropriately and does the bus have external pullups on both of these lines?
Note that HAL expect a left-shifted slave address.
I'd recommend first using HAL_I2C_IsDeviceReady and ensuring you get HAL_OK back before using I2C.
2023-10-23 10:35 AM
Yes, the slave board is powered through ST-Link. SDA/SCL lines both have external pullups from two boards. The slave address is left-shifted by one bit already.
"HAL_I2C_IsDeviceReady" does not find any device that is connected with I2C1. It looks like the I2C1 is disabled on the EVAL board by STM32CubeMX. The status of I2C1 in "Connectivity" of CubeMX shows "Partly disabled conflict with USB_OTG_HS: External Phy Device_Only" (see the attachment). My question is, how to disbable "USB_OTG_HS" and enable I2C1 on this EVAL board?
2023-10-23 11:12 AM
If CubeMX is generating I2C functions, it's not disabled.
Seems like the slave is not responding.
If you have a logic analyzer, hook that up to SDA/SCL to ensure the signal is valid.
2023-10-23 12:20 PM
It looks like the I2C extension connector (CN4) on the STM32H753I EVAL2 board is not enabled at all. When the slave board is disconnected from CN4, I use "HAL_I2C_IsDeviceReady" to enumerate all slave devices on the EVAL board and 3 addresses (MFX, audio and the LCD screen) are found to be connected with I2C1. When the slave board is connected through CN4, none of slave devices of I2C1 are detected. I use an oscilloscope on SCL/SDA lines of CN4, no signal was detected when "HAL_I2C_IsDeviceReady" is executed. The pin 5 of CN4 should have 3.3v signal when the power is on, however it is always 0v when I measured it from the oscilloscope.
2023-10-23 12:50 PM
> The pin 5 of CN4 should have 3.3v signal when the power is on, however it is always 0v
Is the board connected to external power supply or ST-LINK only? Use external supply, check the jumper that selects the power source.
2023-10-23 01:04 PM
It is powered by a 5V DC adapter, which is connected to CN10. The JP10 of the power jumper is set to PSU (5V).
2023-10-24 02:12 AM
Hello @phoenixjia ,
Could you please share you .ioc file ?
Foued
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-10-24 07:28 AM
2023-10-24 07:39 AM - edited 2023-10-24 08:52 AM