STM32F411e-Disco board without using Cube-MX
14:11 08 Jul 2026

Just wanted to share this in case it saves someone else the hours it cost us. We've got an STM32F411E-Discovery board running a bare-metal STM32Cube project (no CubeMX, hand-written HAL calls) talking to an ESP32-C6 over UART, plus a second UART going out to a USB-serial adapter for debug logging. Both UARTs just... stopped making sense. Not silent, not obviously wrong baud either — we'd get a fixed, repeating garbled byte pattern on one line and total silence on the other, and it didn't matter what baud rate we tried on the receiving end, the garbage looked exactly the same every time.

Naturally we assumed hardware. That's what this kind of symptom screams. So we went through all of it: wrong GPIO pin, bad jumper wire, missing ground reference, flaky USB-to-TTL adapter. We even looped the adapter's TX back into its own RX and typed into a terminal to prove the adapter itself was totally fine, which it was. Swapped wires, checked continuity with a multimeter, moved the signal wire to a totally different, known pin to see if the problem followed it. Every single one of those checks came back clean, which was maddening because clean checks were supposed to mean things should just work.

The thing that finally cracked it was reading the chip's actual registers live over the ST-Link, without halting or resetting it, so we could see what the firmware was really doing instead of guessing from outside. The UART's baud rate register had a value in it that didn't correspond to any baud rate we'd ever asked for. Not 9600, not 115200, nothing standard. Working backwards from that register value assuming the clock was running at what we expected (100 MHz, since this is an STM32F411 with an 8 MHz crystal and a PLL multiplying up to 100 MHz) gave a baud rate that made no sense either. So we started questioning the clock speed itself, and sure enough, reading the SystemCoreClock variable straight out of RAM showed 312.5 MHz. Which is impossible. This chip tops out at 100 MHz.

Here's what was actually going on. The STM32Cube HAL library has a header that defines HSE_VALUE, which is just a compile-time constant telling the software what frequency the external crystal runs at. If your project doesn't provide its own version of that config file, which ours didn't since we're not using CubeMX, it falls back to the framework's default, and that default is 25 MHz. Totally reasonable default for a lot of ST's boards. Just not this one. This Discovery board actually has an 8 MHz crystal. The PLL multiplier settings in our clock config were written correctly for an 8 MHz input, so the actual physical PLL hardware locked just fine and really was putting out 100 MHz, you could verify that by reading the PLL configuration registers directly. But the software's calculation of what the system clock is running at doesn't measure anything, it just does math using that HSE_VALUE constant, and with the wrong constant baked in, it calculated a system clock of 312.5 MHz instead of the real 100 MHz. That's off by exactly a factor of 3.125, which not coincidentally is 25 divided by 8.

That bogus clock number feeds into basically every timing calculation in the HAL. It's what the UART peripheral setup uses to figure out what divisor to program in for a given baud rate, so every baud rate we configured actually came out 3.125 times slower than we asked for. It's also what HAL_Delay is built on, so every millisecond-based delay in the firmware was actually taking about three times longer in real life than the code thought it was, which explains why waiting "long enough" for something to happen kept not being long enough during testing.

The fix was one line, adding -DHSE_VALUE=8000000U to the build flags so it overrides the framework's wrong default before that default ever gets a chance to apply. Rebuilt, reflashed, read the same registers again, and this time the system clock came back as exactly 100,000,000 and the baud rate register had exactly the value you'd expect for the baud we asked for. Everything worked immediately after that on both UARTs.

What makes this one sneaky is that it doesn't fail loudly anywhere. The board boots fine. The PLL genuinely locks, because that's an analog process driven by the real crystal, not by what the software believes about it. There's no error thrown anywhere. It only shows up as a proportional error in anything downstream that trusts the software's idea of the clock speed, and that kind of proportional, consistent-but-wrong behavior looks exactly like a hardware problem instead of a configuration one. If you're hand-rolling an STM32Cube project without CubeMX generating your hal_conf.h for you, it's worth just explicitly setting HSE_VALUE yourself instead of trusting the framework default, because the failure mode when you get it wrong is about as misleading as it gets.

stm32f4