Hello,
I have been programming on Arduino boards with Arduino IDE for years, but I would like to switch on the STM32. So I try by the very begining, as a newbie on PlatformIO.
I have created a basic new program as shown on this page, Getting Started with PlatformIO | STM32-base project,
and my board being a STM32 Bluepill, i have just changed the 1st line, so my code is as follow:
#include "stm32f1xx_hal.h"
// trouvé sur file:///U:/ELECTRONIQUE/STM32/EXEMPLES/Getting%20Started%20with%20PlatformIO_STM32.html
// j'ai juste changé #include "stm32f4xx_hal.h" par #include "stm32f1xx_hal.h" car ma carte est une
// Bluepill STM32F103C8, déclarée à la création du projet
#define LED_PIN GPIO_PIN_5
#define LED_GPIO_PORT GPIOA
#define LED_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
void LED_Init();
int main(void) {
HAL_Init();
LED_Init();
while (1)
{
HAL_GPIO_TogglePin(LED_GPIO_PORT, LED_PIN);
HAL_Delay(1000);
}
}
void LED_Init() {
LED_GPIO_CLK_ENABLE();
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Pin = LED_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(LED_GPIO_PORT, &GPIO_InitStruct);
}
void SysTick_Handler(void) {
HAL_IncTick();
}
I use an (firmware updated) ST-Link to connect the Bluepill, and PlatformIO tells me that the upload is successful:
Processing bluepill_f103c8 (platform: ststm32; board: bluepill_f103c8; framework: stm32cube)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/bluepill_f103c8.html
PLATFORM: ST STM32 (15.6.0) > BluePill F103C8
HARDWARE: STM32F103C8T6 72MHz, 20KB RAM, 64KB Flash
DEBUG: Current (stlink) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES:
- framework-stm32cubef1 @ 1.8.4
- tool-dfuutil @ 1.11.0
- tool-ldscripts-ststm32 @ 0.2.0
- tool-openocd @ 2.1100.211028 (11.0)
- tool-stm32duino @ 1.0.2
- 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 28 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\bluepill_f103c8\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 0.2% (used 44 bytes from 20480 bytes)
Flash: [ ] 1.8% (used 1156 bytes from 65536 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, mbed, stlink
CURRENT: upload_protocol = stlink
Uploading .pio\build\bluepill_f103c8\firmware.elf
xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2021-10-16-21:19)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 1
hla_swd
none separate
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000100 msp: 0x20001100
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
shutdown command invoked
============================================================================================= [SUCCESS] Took 2.61 seconds ============================================================================================= * Terminal will be reused by tasks, press any key to close it.
So I believe that the code has been uploaded into the Bluepill, but the problem is that nothing happens: the code is suppose to made a Green LED blinking, but there is just the Red LED permanently ON.
What is wrong ??
Thank you very much