Program the STM32F103C8T6 Blue Pill-LED Blinking

Hardware:

STEP 1: Preparing Arduino IDE Setup.

Download and install Arduino IDE into your computer.

image

Open the Arduino IDE.

image 2

First, you need to download the library for STM32. Go to Tools > Board > Boards Manager. Then, simply search for “Arduino SAM Boards (32-bits ARM Cortex-M3)” and install it.

picture1 1

 

 

STEP 2: Download the Arduino STM32-master.

Then you need to download the driver that can support STM32 board in Arduino IDE. The latest driver was modified by Roger Clark. Download the com drivers here.

hm 1

Unzip the downloaded file. Then, go to the Arduino installation folder. It is usually at C:\Program files(x86)\Arduino.

ss

Now, go to the hardware folder of the Arduino file. In the hardware folder, drag the “Arduino_STM32-master” from the ZIP to the hardware folder and rename it to Arduino_STM32.

The Arduino IDE now can detect the STM32 board.

 

 

STEP 3: Preparing the hardware parts.

For the hardware parts, connect the FTDI programmer to the STM32F103C8T6 Blue Pill.

stm32 blue pill 1
STM32F103C8T6 Blue Pill
fg 1
UC00C (CH340) USB to UART Converter

In this tutorial, UC00C (CH340) USB to UART Converter is used for the FTDI programmer.

circuit diagram for blinking led using stm32

The VCC pin of the FTDI board is connected to the STM32 5V pin to supply the board. The ground is connected to the ground of STM32. The Rx and Tx pin of the FTDI board is connected to the A9 and A10 pin of the STM32 respectively.

Please note that STM32 is a 3.3V microcontroller. Despite the fact that some pins are 5V tolerant, connecting to a 5V power supply will definitely damage it.

photo 2021 08 18 15 43 29 1

Insert the USB cable from the computer to the FTDI programmer and the LED of the STM32 will start to flash. This is the uploaded program by the manufacturer.

 

 

STEP 4: Running the code.

picture2 2

Open the Arduino IDE. Go to Tools > Board > Generic STM32F103C series.

For Variant, select the 64k version. Then, go to CPU speed and choose 72MHz while for the upload method, select the Serial.

Select the COM port that is connected to the FTDI programmer.

open blink program from arduino ide example 1

Next, go to File > Examples > A_STM32_Examples > Digital. Find the Blink sketch and open it.

stm32f103c8t6 pinout voltage01

Based on the pinout diagram above, the LED of STM32 board is connected to pin C13.

In the example program that opens, you have to make a small change. By default, the program will be written for PB1 but the onboard LED is connected to PC13, so replace all PB1 with PC13 and you are good to proceed.

picture3 1

The PC13 pin is kept HIGH (on) for 1000 millisecond and then turned LOW (off) for another 1000 millisecond and this is done for infinite times since it is in loop function. Thus the LED appears to be blinking with an interval of 1000 millisecond.

 

 

STEP 5: Final.

Make sure the boot 0 jumper pin on the board is set to 1 (programming mode) before uploading the program. Once the STM32 is flashed this pin can be changed back to initial position (operating mode).

stm32 operating and programming mode
picture4

Press the RESET button and the microcontroller is now in program mode. Upload the code in the Arduino IDE and the LED will start to blink.

picture5

If the Program has been uploaded successfully then you should see the Red LED blinking at a 1 second interval. You can also fiddle around with the program to increase or decrease the delay.

To upload another program, just press the RESET button on the board and the microcontroller is in program mode again.

 

Hope you understood the tutorial and found it useful to get started with STM32 Board. If you have any problems, leave them in the comment section below.

 

 

Credits goes to following references:

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Real-Time IoT Room Monitoring on Maker Pi Pico Using pyRTOS
Build an IoT Plant Monitoring System with MicroBit and Grove WiFi Module
Snap & Fit ABS Case and ICE Tower Cooling Fan Case Stress Test
Raspberry Pi Zero 2 W – Quad-core and 64-bit CPU
IoT Push Notification Using Rain Sensor with MicroBit
Tutorials of Cytron Technologies Scroll to Top