WeAct STM32F411CE trying to make example blink work

Hi

I feel like I’m missing something really simple. I’ve got a WeAct Blackpill with an STM32F411CE chip on it and I’m trying to get the cmsis_blink example to run on it via VSCode. I’m getting the below when trying to build:

Processing blackpill_f411ce (platform: ststm32; board: blackpill_f411ce; framework: cmsis)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/blackpill_f411ce.html
PLATFORM: ST STM32 (17.3.0) > WeAct Studio BlackPill V2.0 (STM32F411CE)
HARDWARE: STM32F411CEU6 100MHz, 128KB RAM, 512KB Flash
DEBUG: Current (stlink) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES:
 - framework-cmsis @ 2.50501.200527 (5.5.1)
 - framework-cmsis-stm32f4 @ 2.6.4
 - tool-ldscripts-ststm32 @ 0.2.0
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\blackpill_f411ce\FrameworkCMSIS\gcc\startup_stm32f411xe.o
Compiling .pio\build\blackpill_f411ce\FrameworkCMSIS\system_stm32f4xx.o
Compiling .pio\build\blackpill_f411ce\src\main.o
src\main.c: In function 'main':
src\main.c:107:5: error: 'ENABLE_GPIO_CLOCK' undeclared (first use in this function)
     ENABLE_GPIO_CLOCK;              // enable the clock to GPIO
     ^~~~~~~~~~~~~~~~~
src\main.c:107:5: note: each undeclared identifier is reported only once for each function it appears in
src\main.c:108:5: error: 'LEDPORT' undeclared (first use in this function)
     LEDPORT->_MODER |= GPIOMODER;   // set pins to be general purpose output
     ^~~~~~~
src\main.c:108:24: error: 'GPIOMODER' undeclared (first use in this function)
     LEDPORT->_MODER |= GPIOMODER;   // set pins to be general purpose output
                        ^~~~~~~~~
src\main.c:111:25: error: 'LED1' undeclared (first use in this function)
     LEDPORT->ODR ^= (1<<LED1);  // toggle diodes
                         ^~~~
*** [.pio\build\blackpill_f411ce\src\main.o] Error

Which I’m taking to mean it hasn’t worked out what header file to include. I’ve tried removing all the ifdef block and just hardcoding it to include the stm32f4xx.h file and associated defines and it then complain it’s can’t find stm32f4xx.h

Shouldn’t it be installed as part of cmsis and shouldn’t my board definition make it include that anyway?

Thanks

It seems to me that you’ve just skipped to write the proper macros for defining the LED pin, mode etc from the example.

For example, to blink the pin “PD12”, the example uses

You will have to adapt it for your pin. (GPIOD → GPIOx, 12 → y, etc.), that is, only the first 3 macros first 3 and last macro.

Not sure what changed as I hadn’t even closed vscode but now it builds without error.

Then changed to GPIOC and pin 13 which is supposedly where the LED on the board is but no flashing, but now that it compiles and uploads I can at least progress.

Thanks

So did you use exactly

#define LEDPORT (GPIOC)
#define LED1 (13)
#define ENABLE_GPIO_CLOCK (RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN)
#define _MODER    MODER
#define GPIOMODER (GPIO_MODER_MODER13_0)

No I’d missed the 12 in that bottom line, got it all working no problem and am not playing with UART successfully. Thinking about trying to get DMA working now.

Thanks!