cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32F4 i2c as master trasmit HAL_OK but not working

JChen.43
Associate II

I’m using the board, motordriver IIC, to control motor through I2C bus.

The chip on the board is PCA9685.

The board is originally a extension for arduino UNO, and I’m using STM32F446RE which also support arduino UNO expansion connector.

The official give the arduino code, here is github link

github.com/YFROBOT-TM/Yfrobot-Motor-Driver-Library

and I translate it into stm32 code.

Now I want to drive a motor connent to M1 on the board with PWM 100%.

The following is the my stm32 code in main function:

0693W00000bhIjYQAU.pngAnd this is the ioc setting(including clock configuration):

[I2C]

standard mode with 100kHz

PB8 for SCL and PB9 for SDA, both pin set as open drain and pull-up.

[RCC]

set HSE to Crystal/Ceramic Resonator

[SYS]

set Debug to Serial Wire

0693W00000bhInFQAU.png 

I use the logic analyzer, and the SDA line shows what I trasmit is correct

0693W00000bhIrbQAE.png0693W00000bhIsPQAU.png0693W00000bhIikQAE.png 

***Worth mentionong, I found that at the SCL line, some duty cycle are 50%, and some are40%, don’t know if it make the i2c not working…

0693W00000bhIupQAE.png 

100kHz = 10us, refer to the form, the duty cycle should be between 40%~53% (?)

0693W00000bhJ0iQAE.png

11 REPLIES 11
HGanc.1
Associate

Do you find the solution? Because i have the same problem, i use a PCA9685 with the adress 0x7f, and the i2c connection don't work. I test my connection with the HAL status.

Sadly, I haven't found the solution...