STM32 Blue Pill

Post date: Jul 04, 2020 6:12:45 AM

The Blue Pill is a development board based on ST Microelectronics’ STM32F103C9T6 microcontroller that has an ARM Cortex-M3 core that runs at 72MHz max. Software libraries are available that allow users to program the chip using the Arduino IDE.

STM32F103C8T6 Blue Pill Pin Configuration

STM32F103C8T6 Technical Specifications

Understanding Blue Pill

The Blue Pill is a 32-bit Arduino compatible development board that features the STM32F103C8T6, a member of the STM32 family of ARM Cortex-M3 core microcontrollers. This board aims to bring the 32-bit ARM core microcontrollers to the hobbyist market with the Arduino style form factor.

Powering your Blue Pill:

There are three ways of powering your Blue Pill development board:

  • Using the built-in USB micro connector.

  • Supplying 5V to the 5V pin as external supply.

  • Supplying 3.3V directly to the 3.3V pin.

Input/Output:

The Blue Pill has 37 GPIO pins spread across four ports – A and B (16 pins), C (3 pins) and D (2 pins). Each pin has a current sink/source ability of 6mA. Pull-up and pull-down resistors can be enabled on each of the pins.

Most pins have extra functionality as well:

  • Serial ports – receive and transmit data via the UART protocol

  • I2C ports – two-wire communication via the IIC protocol

  • SPI – serial communication

  • PWM

  • Pin 13 has a built-in LED

These special functions and their respective pins are illustrated in the Blue Pill pin diagram shown above.

How to Use the STM32 Development Board?

The Blue Pill can be programmed in two ways –

  • Using an external USB/Serial converter connected to UART1 pins, which is the default bootloader for this family of boards. It can be programmed using the Arduino software this way.

  • STLink USB Dongle – this uses the single-wire debug interface to communicate with the board. This allows it to be programmed using advanced software like Keil/CubeMX. It also allows memory access using the STLink software.

Before programming, it is important to connect the BOOT0 jumper to 1 and press the reset button to put the chip in ‘programming mode’.

Uploading Your First Program

If programming using the Arduino software, the appropriate board files should be downloaded using preferences and boards manager.

Then the correct board must be selected on the board's menu.

Since the built-in LED is on pin 13, just like the Arduino, the basic blink sketch will work on the Blue Pill. The code is shown below.

How to Program STM32F103C8T6 STM32 Blue Pill Board

The STM32 is just another microcontroller form the STMicroelectronics family. So all the existing methods to program an ARM chip can be used for the STM32 board as well. One famous and commonly used IDE is the Keil ARM MDK and apart from that we can also use IAR workbench, Atollic TrueStudio, MicroC Pro ARM, Crossworks ARM, Ride 7, PlatformIO+STM32 etc.

But what made this board a lot popular is its ability to be programmed with the Arduino IDE. This way people can get started and build projects with STM32 in no-time since many will be familiar with Arduino IDE and its easy to use programming language and readily available libraries. So in this STM32F103C8T6 Arduino IDE tutorial we will using the Arduino IDE to get started with STM32.

Circuit Diagram

To program the STM32 Blue Pill board directly from Arduino IDE we need to use a Serial FTDI board. This board is connected to the Rx and Tx pin of the STM32 as shown below.

Preparing the Arduino IDE for STM32 (Blue Pill)

Follow the below steps to download and prepare the Arduino IDE to be used with the STM 32 Development board.

Step1: Instal STM Cube Programmer from the following https://www.st.com/en/development-tools/stm32cubeprog.html

Step 2: From IDE Click on Preferences and copy the line below in the additional Boards Manager URL text box paste the below link:

https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/master/STM32/package_stm_index.json

Step3: In board manager in tall the STM32 boards

Step4 :Select STM32F1 Series in the board and Blue Pill F103 C8

Step5: Select Upload Method STM32CubeProgrammer (Serial)

Step6: Select Serial Adapter Com port.

Step7: Upload the code.