cancel
Showing results for 
Search instead for 
Did you mean: 

I2C Not Working

Avid
Associate II

I am unable to get the I2C line on my STM32H750VB to connect with my PCA9685 PWM driver on my custom PCB. The I2C line is constantly high, which I have seen on multiple oscilloscopes. I got the software online from a tutorial on the PWM driver and was able to run it successfully on a Nucleo-H743ZI2 board which has a STM32H743ZI MCU with a breakout of the PCA9685 so the code unrelated to board setup should work. I attached the entire code file in case though. Things I've tried: 

  • Changing the I2C pull-up resistors from 4.7k to 10k
  • Resetting the I2C bus with HAL_I2C_DeInit and HAL_I2C_Init 
  • Continuity between the MCU SCL and SDA and breakout is good 
  • Pull-up resistor values when measured between each line and 3V3 is the same 
  • Plugged in the working breakout to the custom board and took out the original PCA9685
  • Multiple system configurations with internal clocks HSI, CSI, and PLLCLK
  • Multiple I2C clock configurations with PCLK1 and HSI
  • Pulling NRST high (it is low on my board but the board has been able to run other peripherals like USB) 

Layout

Avid_1-1741218902055.png

  • Circled are the pull-up resistors and the I2C connections on the PCA9685 PWM driver, microcontroller is on the bottom left connecting to the pull-ups 

Schematic

Avid_3-1741219041931.pngAvid_4-1741219076576.png

  • I2C is connected on PB7 for SDA and PB8 for SCL

Pinout

 

Avid_6-1741219233950.png

  • SDA on PB7 SCL on PB8, and other than these the only other pin enabled is a GPIO going to an LED

Any ideas for other things to try to get the I2C bus running or what could be causing the issue?

Edit: the code shows an I2C address of 0x80 from the breakout board I was testing with, though along with 0xAA I was unable to get a connection, also HAL_I2C_ISDeviceReady was not returning TRUE

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Avid
Associate II

Update: 

  • I switched the SCL and SDA pins to GPIO and tried to toggle them and both lines remained high due to the pull-up resistors, I then took out the pull-ups and tried again and both lines remained low so I concluded it was likely an issue with the pins themselves or the connection with the board
  • I then switched from I2C1 to I2C4 which was using some pins I had on a connector and it was able to communicate with the breakout board, it also works when I2C4 is connected to the original I2C1 line with the original I2C1 pins configured as GPIO_INPUT so ideally it should work with components soldered to the I2C line on the board.

View solution in original post

3 REPLIES 3
TDK
Guru

> #define PCA9685_ADDRESS 0x80

The slave address is wrong. You're using 0x80 while clearly A0, A2, A4 are pulled up. Should be 0b10101010.

TDK_0-1741220403088.png

 

Ensure HAL_I2C_IsDeviceReady returns HAL_OK before using any other HAL_I2C_* function.

Look at return values from HAL function to understand why they failed.

If you feel a post has answered your question, please click "Accept as Solution".
Avid
Associate II

Apologies, I forgot to mention that the PCA9685 breakout board I was trying to test with the custom PCB has an I2C address of 0x80. I had also tried 0xAA with the one soldered to the board and it failed to connect as well. I had run HAL_I2C_IsDeviceReady with an if statement and an LED to indicate the status and that wasn't working as well. 

I haven't looked at other return values from the HAL function though so thanks for the advice! 

Avid
Associate II

Update: 

  • I switched the SCL and SDA pins to GPIO and tried to toggle them and both lines remained high due to the pull-up resistors, I then took out the pull-ups and tried again and both lines remained low so I concluded it was likely an issue with the pins themselves or the connection with the board
  • I then switched from I2C1 to I2C4 which was using some pins I had on a connector and it was able to communicate with the breakout board, it also works when I2C4 is connected to the original I2C1 line with the original I2C1 pins configured as GPIO_INPUT so ideally it should work with components soldered to the I2C line on the board.