I'm currently trying to program an STM32 with arduino, but along the way, i encountered some issues with pin modes. To be more specific, programming certain pins to certain modes. Some pins have consistent digital outputs like PC13, while others have wonky outputs like PA11 and PA12, despite being able to be used as digital outputs. PA12 digital output here is what i get from PA12 PA11 digital output here is what i get from PA11

i've read the pinout diagrams, and im not too sure if both mentioned pins can be used digitally according to this pinout diagram : stm32 pinout diagram

can anyone help me explain what is going on, how do i program an STM32 with Arduino IDE exactly (stm32duino programming procedures, rule of thumb, etc), and can an stm32duino be used to do complex programs like an arduino like for example driving a motor with PWM in a balancing robot or do we have to use C or C++ using atollic TrueSTUDIO and all of those software?

  • 1
    In both images, it looks like you are reading and printing PA0. It's normal for a floating pin to read random 1's and 0's.
    – Tagli
    Commented Dec 14, 2019 at 16:27

1 Answer 1


others have wonky outputs like PA11 and PA12, despite being able to be used as digital outputs.

As the pinout diagram you included in the question yourself shows, PA11 and PA12 provide the USB interface.

You can't use those pins for both USB and other GPIO roles at the same time.

Your Arduino core and add-on bootloader are presumably using the USB port for programming and communication with the host PC. Custom projects which did not use the pins for USB would be possible, but you'd likely be largely on your own and unable to use those particular Arduino components (or at least not without heavily modifying them).

There are other pins which have key purposes, too, for example those which support external clock crystals, those which provide the SWD debug interface, those which could provide serial UART output, etc - some designs can use these as generic I/O's but only by forgoing the unique functionality which many designs need them to provide.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.