2016-08-05 12:07 AM
Hi,
I have a problem regarding I2C comm on STM32F102. I am using CubeMX to generate init code. Every time I try to transmit as master it successfully sets START bit in CR1, and waits until SB in SR1 is sets to 1 (which is) and executes:/* Send slave address */
hi2c->Instance
->DR
= I2C_7BIT_ADD_WRITE(DevAddress);Then nothing happens on GPIO - line remains HIGH and it returns HAL_TIMEOUT in/* Wait until ADDR flag is set */
if
(I2C_WaitOnMasterAddressFlagUntilTimeout(hi2c, I2C_FLAG_ADDR, Timeout) !=HAL_OK
)If you look at I2C->SR1 ARLO (arbitration lost) is set. I have no idea what else could I check to get the bus working. The same code works on nucleo L053R8 board (which is connected to the same line - so pullups and everything else is OK).
You can take a look at entire configuration - CUBE pins, CUBE ''configuration'', and registers of MCU after hi2c->Instance
->DR
= I2C_7BIT_ADD_WRITE(DevAddress); command: Thanks for your help! #i2c #hal #stm32f1022016-08-05 01:37 AM
> Then nothing happens on GPIO - line remains HIGH and it returns HAL_TIMEOUT in
Which line? SCL? SDA is supposed to be LOW after START, so do you see the high-to-low transition on SDA?
JW2016-08-05 01:43 AM
Yes, SDA doesn't get low (and of course neither SCL).
Vid2016-08-05 11:10 AM
Can you wiggle those two pins ''manually'', by setting them as general-purpose open-drain outputs?
JW