cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F102C8T I2C, GPIOB set up properly but GPIO never gets in START (drain) condition

klopcic
Associate II
Posted on August 05, 2016 at 09:07

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: 

https://photos.google.com/share/AF1QipPGGdoXirfXp_MJfTWiGL51TEuk21C51YycRugcGEG_zkQ3rwaol8ZB18krDIYDmQ?key=RnNrSnJ1eWpSdkM4ZGhjX2Qya0haRkh1ZkYzVVR3

Thanks for your help!

#i2c #hal #stm32f102
3 REPLIES 3
Posted on August 05, 2016 at 10:37

> 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?

JW

klopcic
Associate II
Posted on August 05, 2016 at 10:43

Yes, SDA doesn't get low (and of course neither SCL). 

Vid

Posted on August 05, 2016 at 20:10

Can you wiggle those two pins ''manually'', by setting them as general-purpose open-drain outputs?

JW