STM32U5A5: PC13 with two LEDs - FOUR states (instead of three)?
Three states on a single GPIO pin with two LEDs is possible.
For users who want to drive 2 LEDs with three states with one signal GPIO - please, see the details below.
But I want to ask one question:
On a STM32U5A5 - how does the PC13 behave? - I see "FOUR states" possible (even I can force later just to use three states).
- MCU was never flashed with a FW: both LEDs are on (dimmed, like getting pulses)
- both LEDs off: configure PC13 as input (or GPIO_DeInit() to set as analog pin)
- LED1 on / LED2 off: configured as output and drive low
- LED1 off / LED2 on: configure as output and drive high
I cannot force again to see both LEDs on.
But I am sure: after I have soldered my boards, power it up the first time in order to flush the 1st time my FW - both LEDs are on (but dimmed). I assume: there is a frequency (a toggling signal). But why and which one?
BTW: how to configure PC13 for RTC_OUT1? I have not found an ALT setting to do so?
One GPIO pin for three states

- Use a Dual-LED with two LEDs, "anti-parallel"
- One LED is on, if GPIO is set low (acting as a sink)
- The other LED is on, if GPIO is set high (providing a source)
- Both LEDs are off, if GPIO is configured as an input (no current)
Remark:
if you run VDD as 1V8 (as I do) - you can only use red LEDs! The forward voltage of a green LED (or a blue one) is above 1V8 - it would never go on. With 3V3 you can use any combination of colors (maybe not white).
The "fourth state"
The fourth state is just there if MCU was never flashed with a FW. Why do I see both LEDs?
I tried to force the "fourth state" but with simple means not possible, like erasing entire MCU flash, not progressing in Reset_Handler.
I can still make use the "fourth state" in order to realize if the MCU has a flashed FW running.
If you want to create a fourth state with one GPIO and two LEDs:
- generate a frequency (toggling the GPIO fast enough, e.g. with 20 Hz or faster) - both LEDs are on
But this PC13 does not have an option for a PWM output. And not clear how to enable RTC_OUT1/RTC_TS, TAMP_OUT2. Is it maybe a TAMP_OUT2 signal when MCU FW was never flashed?
PC13 not intended to drive LEDs
Yes, I know: datasheet says: PC13,,,PC15 can just source 3mA in total (as sum). And it should not be used to drive LEDs (directly), even I do.
But I made sure the current is below 1mA (1V8 with 300R).
I decided to use PC13 as LED because it does not have any other useful ALT function (e.g. SPI, I2C, ...).
