2026-02-24 3:54 AM
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.
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:
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?
Solved! Go to Solution.
2026-02-24 3:58 AM
2026-02-24 3:58 AM
2026-02-24 4:02 AM
@Andrew Neil you'd think I would have remembered that!
2026-02-24 4:05 AM
> Cube MX confirms PULL UP is enabled for all switch inputs:
But does the generated code really enable all pull-ups ?
2026-02-24 4:07 AM
Ha ha! I hadn't noticed that was also you!
2026-02-24 4:20 AM
@KMill wrote:
@Andrew Neil you'd think I would have remembered that!
:D