Getting Started with STM32 Microcontroller : Blinking of LED

STM32 Arm Microcontroller Tutorial Getting Started with STM32F103C8T6 Bluepill & Arduino IDE (Last Updated On: February 17, 2019)

Getting Started with STM32F103C8T6 STM32 Development Board

Arduino is the first board for many when they started with electronics. But when we go deeper we understand that Arduino is not industry ready development board and its 8-bit CPU with a ridiculously slow clock and may be not suitable for higher level projects. So we need to move to advance level and we have the new STM32F103C8T6 STM32 Development Boards also known as Blue Pill. It has 32-bit CPU and based on ARM Cortex M3 architecture.

So in this post we will be covering all these areas:



- Getting Started with STM32F103C8T6 STM32 Microcontroller
- Installing STM32 Board to Arduino IDE via Board Manager
- Learn about Input/Output pins of STM32
- Setting STM32 with USB to TTL Converter and connection diagram
- Method for uploading Code to STM32 Microcontroller
- Blink of LED using STM32 as begineers Guide

Components Required:

1. STM32F103C8T6 STM32 Microcontroller Board (Buy Online from Amazon)
2. USB-TTL Converter/FTDI Programmer (Buy Online from Amazon)
3. Breadboard
4. Connecting Wires

STM32F103C8T6 STM32 (Blue Pill) Board:

Before Getting Started with STM32 Microcontroller, we need to know about STM32. The datasheets of STM32 contains all the information. Some of the information are explained below:

Introduction:

The STM32 family of microcontrollers from STMicroelectronics is based on the ARM Cortex-M 32-bit processor core. The STM32 series are some of the most popular microcontrollers used in a wide variety of products. They also have an excellent support base from multiple microcontroller development forums.

STM32

STM32 microcontrollers offer a large number of serial and parallel communication peripherals which can be interfaced with all kinds of electronic components including sensors, displays, cameras, motors, etc. All STM32 variants come with internal Flash memory and RAM.



The range of performance available with the STM32 is quite expansive. The board also holds two crystal oscillators, one is an 8MHz crystal, and the other is a 32 KHz crystal, which can be used to drive the internal RTC (Real Time Clock). This enables the MCU to operate in deep sleep modes making it ideal for battery operated applications. There are also two on-board LEDs, one (red colour) is used for power indication, and the other (green colour) is connected to the GPIO pin PC13.

STM32F103C8T6 Full Form & Meaning:

“Blue Pill” or STM32F103C8T6 name has a meaning behind it.

STM - stands for the manufacturers name STMicroelectronics
32  - stands for 32-bit ARM architecture
F103  - stands to indicate that the architecture ARM Cortex M3
C  - 48-pin
8 - 64KB Flash memory
T - package type is LQFP
6 - operating temperature -40°C to +85°C

Specifications:

Manufacturer: STMicroelectronics 
Product Category: ARM Microcontrollers MCU 
Mounting Style: SMD/SMT 
Core: ARM Cortex M3 
Data Bus Width: 32 bit 
Maximum Clock Frequency: 72 MHz 
Program Memory Size: 64 kB 
Data RAM Size: 20 kB 
ADC Resolution: 12 bit 
Number of I/Os: 37 I/O 
Operating Supply Voltage: 2 V to 3.6 V 
Operating Temperature: - 40 C to + 85 C  
Interface Type: CAN, I2C, SPI, USART, USB 
Program Memory Type: Flash   
Number of ADC Channels: 10  
Number of Timers/Counters: 3 Timer

Pin Details:

STM32 Pin Details



Method to Program STM32 Microcontroller:

There are 6 methods by which you can program STM32 Microcontroller. The methods are:
1. STM32duino Bootloader Method
2. Serial Method
3. By using ST-Link Debugger
4. By BMP (Black Magic Pro)
5. Jlink Method
6. By HID bootloader 2.0

But here we will be using the most popular method, i.e Serial Method to program STM32 Microcontroller. For this you need USB to TTL Converter. And we are using FTDI Module to program STM32. The connection diagram between STM32 and USB to TTL is given below.

stm32 and usb to ttl connection

Connect GND of FTDI to GND of STM32
Connect 5V/3.3V of FTDI to 5V/3.3V of STM32
Connect Rx of FTDI to A9 (Tx) of STM32
Connect Tx of FTDI to A10 (Rx) of STM32


Setting up STM32 with Arduino IDE:

Before getting started with STM32 we need to add STM32 board library to Arduino IDE, so that we can program STM32 using Arduino IDE.

So for this follow the following Steps:

Step 1:
Click on file then click on Preference and then add the following link below:

http://dan.drown.org/stm32duino/package_STM32duino_index.json


Step 2:
Click on Tools >>>>>> Boards >>>>>> Board Manager
Then Type STM32F1 and then install the board that you get on board manager

Step 3:
After installation is completed, make the following changes by selecting these options




Blinking of LED using STM32 as a Test Program:

Now you can connect USB to TTL converter to your PC. To connect FTDI with STM32 follow the above circ Make sure that FTDI driver is installed on your PC else, Arduino IDE won’t show port.

Now you can copy the blink sketch from below and upload it to STM32 Board. This can be done by simply compiling and then uploading same like what you do with Arduino Board.

During the uploading process you will see the following written on IDE Console.


Source Code/Program for Blinking of LED:

#define LED_BUILTIN PC13
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

Video Tutorial & Full Explanation:

If you still face the problem for Getting started with STM32, you can watch the full detailed tutorial video and guide below.


Recommended For You

About the Author: Alex Newton

Ask A Question .......

Close