Skip to main content
KMill
Senior
February 24, 2026
Solved

STM32G071 PORTD Pullups

  • February 24, 2026
  • 2 replies
  • 222 views

I'm connecting a 12-Way rotary switch to an STM32G071 as shown:

Board room is extremely limited, so I'm using the MCUs built in Pull Ups.

Screenshot 2026-02-24 114414.png

 

However when I read the lowest four bits of PORTD->IDR (for switch positions 7,8,9 and 10) it reads 0xA when it should read 0xF (The rotary is at position 1, so PORTD0:3 should all be pulled up).

Cube MX confirms PULL UP is enabled for all switch inputs:

Screenshot 2026-02-24 at 11.49.24.png

The only other peripherals enabled on the chip are DAC output on PA4 and GPIO Output on PA15

I have carefully examined the board, and there are definitely no shorts to ground, and the switch it operating perfectly.

If I measure the voltage on all the PORTD0:3 pins, all are pulled up to 3.3v except PD0 and PD2, when they should be.

Any suggestions?

 

Best answer by Andrew Neil

PORT D Read errors.

2 replies

Andrew Neil
Andrew NeilBest answer
Super User
February 24, 2026
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.
KMill
KMillAuthor
Senior
February 24, 2026

@Andrew Neil you'd think I would have remembered that!

Andrew Neil
Super User
February 24, 2026

Ha ha! I hadn't noticed that was also you!

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.
Ozone
Principal
February 24, 2026

> Cube MX confirms PULL UP is enabled for all switch inputs:

But does the generated code really enable all pull-ups ?