cancel
Showing results for 
Search instead for 
Did you mean: 

Initial state of pins on STM32G0.

JLemi
Associate III

Hello.

I have a circuit containing notably: (i) MCU pin PA2 connected to both a ULN2003 transistor-array input and a 10k pulldown resistor and (ii) the corresponding output of the ULN2003 is connected to a small beeper GND. In theory, this circuit is supposed to maintain the transistor input at logical zero when the MCU pin is floating, hence preventing the beeper from ever turning on unless it is desired.

I noticed the following:

  • When powering on a board with a MCU that was never flashed, my beeper always turns on. When I check the MCU pin PA2, I read 3.3V. This 3.3V appears despite the 10K pulldown resistor on it, so we can be sure that the pin PA2 at this point must be configured as output, with logical 1 set.
  • If I flash a program that does nothing (simple infinite "for" loop just after the main entry point), then doing a power cycle, the beeper no longer turns on, and the MCU pin now reads 0.
  • If I erase the whole MCU and do a power cycle again, then the beeper turns on.

The datasheet for this MCU, the STM32G0, indicates "By default, all GPIOs are configured in analog input".

So there is something weird, because the default state as shipped by the factory and after mass erase seems, for few pins at least, to be output (I can sink 6mA to gnd from these pins when using a 500ohms load), so they are not floating).

I also found other pins that have the same behavior, such as SCL and SDA on PB10 and PB11. These pins are only conencted to a header, so the 3.3V found on these pins at boot can't come from anywhere else than the pins themselves.

Any clue what might be happening?

Thank you !

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

There is a flash empty check switching to the internal bootloader activating boot interfaces: https://community.st.com/s/article/Empty-check-mechanism-on-SMT32

View solution in original post

4 REPLIES 4
KnarfB
Principal III

There is a flash empty check switching to the internal bootloader activating boot interfaces: https://community.st.com/s/article/Empty-check-mechanism-on-SMT32

Uwe Bonnes
Principal III

Probably PA2 is involved in the sytem bootloader and set to a state that ectivates your beeper. Study AN2606!

JLemi
Associate III

Many thanks to KnarfB and Uwe, it seems that you gave me a good pointer to important information I was not aware of.

JLemi
Associate III

The issue was indeed related to the initial state "output high" of some pins after a chip erase operation. Thanks to everyone who contributed. JL