cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G071 PORTD Pullups

KMill
Senior II

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?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Andrew Neil
Super User

PORT D Read errors.

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.

View solution in original post

5 REPLIES 5
Andrew Neil
Super User

PORT D Read errors.

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.

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

Ozone
Principal III

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

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

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.

@KMill wrote:

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


:D

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Announcement

We’re moving the ST Community to a new platform to give you a better and more reliable community experience.