I’m trying to get my WeAct BlackPill (STM32F411CEU6) up and running using the blink example provided here. I modified the code to set LED_GPIO_PORT
to GPIOC
and the LED_PIN
to GPIO_PIN_13
, as that is the LED builtin pin. This compiles and uploads correctly but the LED does not blink.
I have downloaded the STM32CubeIDE and set up the blink example in there, and the LED blinks. I tried copy-pasting the code from the IDE into the platformio version, and that does not work (no errors but no blinking).
If I use the Arduino framework and try the basic blink example it works perfectly.
I believe there must be some sort of configuration I’m missing, whether that’s in the code or just at compile time as it seems weird absolutely no code is executed when I build and upload with platformio and stm32cube framework.
Here is my platformio.ini:
[env:blackpill_f411ce]
platform = ststm32
board = blackpill_f411ce
framework = stm32cube
board_build.mcu = stm32f411ceu6
debug_tool = stlink
upload_protocol = stlink
monitor_dtr = 1
monitor_filters = colorize, send_on_enter
My current code is from the example I linked above, but as mentioned I also tried the STM32Cube blink example (can’t find a link to that code on github).
Does anyone know what I could be missing?
And what about setting the clock?
#define LED_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
Also, you should be able to debug the program through the ST-Link. Set a breakpoint at
https://github.com/platformio/platform-ststm32/blob/master/examples/stm32cube-hal-blink/src/main.c#L43
and use the Debug Sidebar and the Play button. Does it break there? Does it loop more than once?
Debugging is a good point, I forgot I could do that. I’m not used to GDB so I don’t know if any of the following could indicate a problem.
When I start the debugger I see this message:
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
[stm32f4x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080005e4 msp: 0x20020000
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Whenever I step over each line I see:
halted: PC: 0x080004fc
Info : halted: PC: 0x0800
though I also think this could just be because it’s halting for each line.
If that’s the case, nothing unusual is happening. It makes it to the while loop, runs each line, and then jumps back to the beginning of the loop to start again.
The GPIO config struct is intialised correctly, and nothing else seems out of the ordinary yet still nothing happens to the LED.
In the debug sidebar, there should be a collapsable label called “Perpiherals”. Then “GPIOC” should be in there, along with its output data register (OCTL? ODATA?). Can you find and expand that, and take a screenshot of it after two consecutive loop iterations?

Here’s the screenshot. Everything being null I would assume is wrong, but as to why I hope we can figure out.
All zero is not good. This is after one execution of the loop? It also doesn’t update when you expand the ODR
(output data register)?
Usually this means the peripheral doesn’t have the clock activated. You already checked what I initially wrote, yes?
I was just writing my answer to this when I decided to go to the definition of the clock enable macro to see what it does. That’s when I noticed a bunch of very similar macros and that’s when I realised what you were saying and what the problem was 
I interpreted your question about the clock as just checking if I had that code entirely, I completely missed each GPIO group has its own clock and that I was enabling group A, not group C. I changed it to C and it does blink.
Thank you for your help!