Microcontroller

Getting Started with STM32 Microcontroller: Blinking of LED

Arduino was the first board for many when they started with electronics. But when we go deeper we understand that Arduino is not an 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 an advance level and we have the new STM32F103C8T6 STM32 Development Boards also known as Blue Pill. It has a 32-bit CPU and is based on ARM Cortex M3 architecture.

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

  1. Getting Started with STM32F103C8T6 STM32 Microcontroller
  2. Installing STM32 Board to Arduino IDE via Board Manager
  3. Learn about Input/Output pins of STM32
  4. Setting STM32 with USB to TTL Converter and connection diagram
  5. Method for uploading Code to STM32 Microcontroller
  6. Blink of LED using STM32 as beginners Guide


Components Required:

1. STM32F103C8T6 STM32 Microcontroller Board
2. USB-TTL Converter/FTDI
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 contain all the information. Some of the information is 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 color) is used for power indication, and the other (green color) 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 manufacturer’s name STMicroelectronics
32 – stands for 32-bit ARM architecture
F103 – stands to indicate that the architecture ARM Cortex M3
– 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 USB 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:

1http://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 circuit Make sure that the FTDI driver is installed on your PC else, Arduino IDE won’t show port.

Now you can copy the blink sketch form below and upload it to STM32 Board. This can be done by simply compiling and then uploading the same as 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:

Leave a Reply

Your email address will not be published. Required fields are marked *