PlatformIO Community

STM32ADC Library not working as expected with bluepill

Using Platformio Core 5.2.5 Home 3.4.1

I am trying to build a project on a STM32F103C bluepill board using this STM32ADC library: GitHub - rogerclarkmelbourne/Arduino_STM32: Arduino STM32. Hardware files to support STM32 boards, on Arduino IDE 1.8.x including LeafLabs Maple and other generic STM32F103 boards

Although my code uploads to the MCU, even a simple LED blink test does not work.

Here is how I’ve set up my .ini file:

[env:bluepill_f103c8]
platform = ststm32
framework = arduino
board = bluepill_f103c8_128k
board_build.core = maple

And here is the code I am trying to run:

#include <Arduino.h>
#include <STM32ADC.h>

#define LED_PIN PC13

void setup() {
  pinMode(LED_PIN, OUTPUT);  // LED out
}

void loop() {
    // Blink the LED so we know we haven't crashed
    digitalWrite(LED_PIN, HIGH);
    delay(1000);
    digitalWrite(LED_PIN, LOW);
    delay(1000);
}

When I remove both board_build.core = maple from the .ini file and #include <STM32ADC.h> from the cpp file, the code blinks as expected.

I tried to put the STM32ADC library directly into the Library folder in my project but that didn’t work. I also checked every pin on the MCU after running the code to see if the pins are mapped differently with the STM32ADC library, but I didn’t find any pins outputting a high and low signal.

For full reference, the actual code I am trying to upload for this project is here: directional_speaker/main.cpp at master · gururise/directional_speaker · GitHub

Any help would be deeply appreciated. Cheers!

So what you found out is that the maple core fails but the the STM32Duino core works on your board.

Did you also test the above program with the maple core but without #include <STM32ADC.h>?

The Bluepill variant already does the same

so the pin should definitely be correct.

When I use the maple core and remove the #include <STM32ADC.h> the program uploads to the MCU successfully, but the light does not blink. It only works if I remove both.

Does it also not work in the Arduino IDE when you install the Maple core per their instructions and try the same blinky program under the same board configuration?

I just tried it in Arduino IDE and it does work with the Maple core! In fact, the bigger code file I was trying to run that makes use of the STM32ADC library seems to be functioning as well.

If this is the case, do you have a better idea of why it might not be working in PlatformIO?

If you upload via an ST-Link, you should have debugging automatically working for you (left sidebar with the Bug + Play icon). Can you debug where the board is stuck in the PlatformIO + maple project?