Fork me on GitHub

Project Notes

#386 BluePill

Programming an ARM Cortex-M3 STM32F103C8T6 Blue Pill board with the Arduino IDE.

Build

Notes

Popularly known as the Blue Pill, the STM32F103C8T6 Minimum System Development Board seems like an excellent gateway drug for getting into ARM Cortex-M3 development.

This is particularly true as it is possible to program it with the familar Arduino IDE.

This is my first look at one of these boards, so I have simple expectations - follow along some of the tutorials on the web/youtube and at least get a simple program running on the board. In the process I’ll learn a bit more about the board’s capabilities and quirks.

Board Specs

  • ARM Cortex M3
  • 72 MHz
  • 64 KB
  • 20 KB RAM
  • Reset button
  • LED on PIN PC13
  • 32 kHz Real time clock crystal
  • Jump links on Boot0 and Boot1
  • Micro USB connector for power and data
  • ST-Link header on the top of the board.

Pinouts

Bluepillpinout

Power

The STM32F103C8 operates from 2.0 to 3.6V. The development board includes a 3.3V LDO regulator, and since many pins are 5V-tolerant, this allows the board to be used with 5V USB power.

Programming with the Arduino IDE

I’m following the STM32 Arduino Tutorial - How to use the STM32F103C8T6 board with the Arduino IDE YouTube tutorial by educ8s.tv. This is one of many, but it is the most accurate and up-to-date that I found in a quick search.

clip

Here’s how the process went for me….

Adding Board Support to the IDE

NB: I’m running Arduino IDE 1.8.2 on MacOSX at the time of this test.

A Boards Manager package is created by Dan Drown, the instructions are on the stm32duino site

Add custom boards package package_STM32duino_index.json in Preferences

setup_board_manager

Install the STM32F1xx/GD32F1xx boards package by stm32duino in the Board Manager:

setup_install_boards

Connecting a Serial Programmer

I’m using a CH340G USB-serial adapter from MacOSX (similar but different to FTDI-based adapters).

Connections are as follows:

USB-Serial BluePill
GND GND
VCC 5V
RXD A9
TXD A10

Breadboard

Schematic

Build

Configuring the IDE

The default settings that work with this board are as follows:

  • Board: Generic STM32F103C series
  • Variant: STM32F103C8 (20k RAM. 64k Flash)
  • CPU Speed: 72MHz
  • Upload method: Serial
  • Port: (as selected based on USB connection)

setup_serial

Uploading Sketch

The Blink.ino sketch is just about the simplest thing possible - blinks the LED connected on port PC13. This is not showing off the board capabilities at all - I’m just trying to verify the programming process.

For programming, the BluePill Boot0 jumper is set to 1 (pulled high).

From the Arduino IDE, the program compiled and uploaded over serial without any issue..

serial_programming

After disconnecting the serial programmer and switching the BluePill Boot0 jumper to 0 (pulled low), the board can be powered from USB with the program running:

BluePill_usb_powered

Credits and References

About LEAP#386 STM32
Project Source on GitHub Return to the LEAP Catalog

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

LEAP is my personal collection of electronics projects, usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting (IMHO!).

The projects are usually inspired by things found wild on the net, or ideas from the sources such as:

Feel free to borrow liberally, and if you spot any issues do let me know. See the individual projects for credits where due. There are even now a few projects contributed by others - send your own over in a pull request if you would also like to add to this collection.