STM32CubeMX bug preventing to use the LED output (PC13) on STM32F103/BluePill + bug in SVD file for STM32F103
I am using a Chinese low-cost "Blue Pill" board with an STM32F103C8T6, and developping in EmBitz IDE using init code generated by STM32CubeMX. On this board, the PC13 output is connected to an LED, but the code generated by STM32CubeMX will not allow to control this output.
The root cause is that the init code sets the ASOE bit (b8) in BKP_RTCCR, which reserves the PC13 pin for the "Alarm or second output".
This is an error, because in STM32CubeMX I correctly set PC13 as an output GPIO and no error was indicated.
Once you know it, the solution is easy, just adding the following line after the standard initialization:
BKP->RTCCR &= ~BKP_RTCCR_ASOE;
This bug was specially difficult to find, because there is also a bug in the file STM32F103.svd:
In the file, RTCCR is at offset 0x28 and CR at offset 0x2C, but according to the reference manual RTCCR is at offset 0x2C and CR at offset 0x30.
As a result, the faulty bug is RTCCR is displayed as a non-existing bit in CR.
So please fix these two bugs, it should not be too difficult!
