Skip to main content
Visitor
Nov 4, 2026 5:50 PM UTC
Question

nucleo-g474re trying to set up i2c bare metal, no access to cubemx only STM32CubeIDE

I am trying to understand i2c.  I wrote a simple script to initialize my i2c and I am trying to observe SDA and SCL on an oscilloscope. 

 

I have wired the 3.3V from D13 /VREFP and have it feeding two different 5.6kohm resistors. One Resistor is connected to D15 /SCL and the other is connected to D14 /SDA.  I am using the ground on D12/ marked ground and it is hooked up to the gnd on my oscilloscope.

When I probe either D15 /SCL or D14 /SDA, it shows a flat zero volts on my oscilloscope.  When I move it to the other side of the resistor it shows 3.3 V.

Shouldn’t it have D15 sitting high or showing the pulses?

2 replies

Andrew Neil
Super User
Nov 4, 2026 6:10 PM UTC

Welcome to the forum

Please see How to write your question to maximize your chances to find a solution for best results.

 

I am trying to understand i2c. 

What do you mean by that ?

  1. Understand the bus and its protocol, as defined by NXP (formerly Philips) ?
  2. Understand the I2C controller within the STM32 ?

You’ll need at least a working understanding of (1) to get to grips with (2):

NXP’s UM10204 I2C-bus specification and user manual is the definitive document defining the bus and its protocol:  https://www.nxp.com/docs/en/user-guide/UM10204.pdf

It’s a very long-established and widely-used thing - so there are plenty of learning resources; eg,

https://en.wikipedia.org/wiki/I2C

https://learn.sparkfun.com/tutorials/i2c/all

https://www.i2c-bus.org/

 

For getting to grips with (2), bare-metal register access is probably not a great place to start.

Start with one of the examples provided for your Nucleo board by ST.

 

See also Getting started with I2C in the ST Wiki:

https://wiki.st.com/stm32mcu/wiki/Getting_started_with_I2C

 

Please post a schematic of your setup - trying to describe electronic circuits in words is very difficult, and prone to errors.

Some good, clear photos of your setup would also help.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Visitor
Nov 4, 2026 6:52 PM UTC

I am trying to initialize the I2C and view SCL and SDA on an oscilloscope.

SDA should be high
SCL should be high or show the 100khz wave form.

Something in my code is pulling the SDA and SCL low, it seems to happen when:
 

GPIOB_MODER |= ((ALTERNATE_FUNCTION << (8 * 2)) |

(ALTERNATE_FUNCTION << (9 * 2)));


I included a photo of my test circuit.

If you know of any simple initialization functions I would love to look at it.  I didn’t see any for my board.  I do not have cubemx so I cannot use the wizard to set up the i2c.

I would love feedback on my code I attached in the previous thread to let me know if I forgot to enable something or if anything stands out.  

I can get the usart working no problem.