2024-10-17 01:34 PM
For the life of me I cannot get the I2C pins on my microcontroller to output anything.
I am using I2C1 on pins PB6 (SCL) and PB9 (SDA) on the STM32F746VGT microcontroller. The pins are hooked up to a TXS0108E level shifter that has built-in pull up resistors. I have a very simple CubeMX project that initializes I2C1 to Standard Mode and attempts to transmit some data on it every second.
All I want to see are some signals on the SDA/SCL lines but I get nothing. I can change the I2C pins to open drain GPIO pins and toggle those and see it on the scope, but when I switch back to I2C I see nothing again.
I see the lines stuck either low or high depending on which one I'm probing at the moment. If I reset the MCU then probe the lines, they're both stuck high. They're also stuck high if I reset the MCU while probing SDA. But if I reset the MCU while probing SCL, then both lines get stuck low. So it seems like my oscilloscope has an effect on the transmission. Not sure if that's related to my current issue or not. Either way, not a single bit gets transmitted and not a single clock is pulsed.
I believe the fact that I can toggle the pins in GPIO open drain mode tells me that it is not a circuit problem. In software I'm using the most default, basic configuration I possibly can. So I don't know what could be wrong in software. Does anyone have any ideas for what to do next?
Solved! Go to Solution.
2024-10-21 11:18 AM
By convention of Cube-generated code, MX_GPIO_Init() initializes only pins that do not belong to other components. Pins that belong to I2C and other components are initialized in other places ("msp" functions).
2024-10-25 06:04 AM
Thank you so much for your help, everyone. I ended up solving the issue in the most anticlimactic way possible: the oscilloscope was bad. After switching to one that I've used before and know how to use better, I could see the I2C lines just fine. They were probably there the entire time.
As you can imagine, this came after days of hair-pulling and careful debugging. Only when you get truly desperate do you start questioning your test equipment.
I then discovered that the REAL reason I2C wasn't working in the first place was because one of the (non-I2C) pins on a very small 40-pin connector on my PCB was making a poor connection to the board. Two subtle issues back-to-back!
Sorry the solution wasn't something more exciting, but in electronics it's usually the *** issues we spend the most time on.