Hi.
I used CubeMX to generate code for a STM32F303cc micro controller.
The code compiled and worked.
Then I refactored the code into a few C++ classes suited for my project.
The code compiled and worked.
But when I tried to use UART, the code compiled on both versions, but only worked on the CUbeMX generated one.
I reviewed all the code carefully, even with diff, but could not find the cause for the difference.
Many retries and days later I noted I was programming the uC with the hex file on the CubeMX version and with the bin file on the C++ version.
When I used the hex version, uart initialised correctly.
The moral of this story: when everything else fails, use a different binary format to program your micro controller.