Skip to main content
Visitor II
March 1, 2026
Solved

Can't use the Arduino Framework to code

  • March 1, 2026
  • 3 replies
  • 188 views

One small issue I have. I have a custom STM32F411CEU6 board, quite similar to the WeAct Black Pill in terms of connections, except for the fact that I have a LED on pin PB13, and whenever I try to blink it using:

while (1)
{
 /* USER CODE END WHILE */
	 HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_13);
	 HAL_Delay(500);
 /* USER CODE BEGIN 3 */
}

 in the STM32CubeIDE, everything works fine and dandy

The moment i switch to using the Arduino Framework, albeit with the Arduino IDE or PlatformIO, with parameters of:

platform = ststm32
board = genericSTM32F411CE

using the code:

#define LED PB13
void setup() {
 pinMode(LED, OUTPUT);
}

void loop() {
 digitalWrite(LED, HIGH);
 delay(1000);
 digitalWrite(LED, LOW);
 delay(1000);
}

or anything similar, it just doesn't work! It always says the upload is successful, and it verifies successfully too! But why then, it refuses to work? Any suggestions?

Best answer by mƎALLEm

Hello @4896jazz and welcome to the ST community,

Unfortunately, you have an issue with Arduino environnement which is not an ST one (CubeIDE). You need to ask your question in the Arduino forum: 

https://www.stm32duino.com/index.php

or https://forum.arduino.cc/

3 replies

mƎALLEm
mƎALLEmBest answer
Technical Moderator
March 1, 2026

Hello @4896jazz and welcome to the ST community,

Unfortunately, you have an issue with Arduino environnement which is not an ST one (CubeIDE). You need to ask your question in the Arduino forum: 

https://www.stm32duino.com/index.php

or https://forum.arduino.cc/

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
MasterT
Lead II
March 1, 2026

What board was selected to compile a code?

https://github.com/stm32duino/Arduino_Core_STM32#boards-available 

Navigate to Variants in the installation directory

https://github.com/stm32duino/Arduino_Core_STM32/tree/main/variants/STM32F4xx/F411C(C-E)(U-Y) 

to verify pins definition. You also have to confirm clock configuration.

BTW, you can use CubeMX code under arduino IDE:

static void cfg_Pins(void)
{
 GPIO_InitTypeDef GPIO_InitStruct;

 __HAL_RCC_GPIOA_CLK_ENABLE();
 __HAL_RCC_GPIOB_CLK_ENABLE();
 __HAL_RCC_GPIOC_CLK_ENABLE();
 __HAL_RCC_GPIOD_CLK_ENABLE();

 /**TIM16 GPIO Configuration
 PB8-BOOT0 ------> TIM16_CH1 :MSCLK
 */
 GPIO_InitStruct.Pin = GPIO_PIN_8;
 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
 GPIO_InitStruct.Alternate = GPIO_AF1_TIM16;
 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

 //DEBUG
 GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_2 | GPIO_PIN_3;
 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
}

than call function from setup() to config GPIO, same way as pinMode().

And drive pin by

 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_15, GPIO_PIN_SET);
 delay(200);
 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_15, GPIO_PIN_RESET);

 

Andrew Neil
Super User
March 2, 2026

@4896jazz wrote:

The moment i switch to using the Arduino Framework, ?


Did you follow the instructions to set up your "Arduino Framework" for STM32?

https://github.com/stm32duino/Arduino_Core_STM32/wiki/Getting-Started 

 

As @mƎALLEm suggests, this forum isn't really the place for Arduino questions.

Apart from the general Arduino forums, see https://www.stm32duino.com/ for questions specifically related to the STM32 Arduino Core

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.