How to use FreeRTOS for STM32F103C8 in Arduino IDE

STM32 Discovery Kits from STMicroelectronics are a low-cost, all-inclusive solution for analyzing STM32 MCUs. The kits offer the infrastructure required to demonstrate particular device properties. A HAL library and many software examples enable you to make use of device capabilities and extra values. Extension connections provide access to the majority of the device’s I/Os and allow the attachment of add-on devices. The kits, which have an integrated debugger/programmer, are great for prototyping. In this blog, we discuss how to use FreeRTOS for STM32F103C8 in Arduino IDE.

The STM32F103C is a FreeRTOS-capable ARM Cortex M3 processor. Let’s jump right into FreeRTOS for STM32F103C8 in the Arduino IDE. We can also use Keil, but we’ll have to download and paste the downloaded files into the Keil path, which is a more time-consuming operation than using the Arduino IDE.

What is FreeRTOS?

FreeRTOS is a real-time operating system (RTOS) that operates on a variety of popular microcontrollers, including the STM32.

An Operating System is a piece of software that coordinates the use of other software and hardware resources in a computer. A general-purpose operating system is usually developed with the user’s experience in mind.

Let’s imagine we’re working on an app for a mobile phone operating system. If a user wants to watch a movie online, we can divide the process into two jobs: downloading chunks of video from the web as Job 1 and showing each chunk to the user as Job 2. These tasks could be part of a larger program, in which case they could be implemented as threads that run in parallel.

If our processor only has one core, our streaming program might be able to quickly switch from job 1 to job 2 to give the user the idea that downloading and viewing are both happening at the same time.

freeRTOS STM32

It’s crucial to understand how the Arduino IDE has included FreeRTOS with the STM32F103C8. While FreeRTOS is an underlying software framework that allows for task switching, scheduling, and other functions, we will not be calling FreeRTOS directly. The CMSIS-RTOS library, developed by ARM, allows us to form calls to an underlying RTOS, enhancing code portability across ARM processors.

How to download FreeRTOS for STM32F103C8 in Arduino IDE?

So, let’s have a look at how to install FreeRtos for the Arduino step by step.

Step 1:

Using the Arduino IDE To begin, navigate to File -> Preferences. Copy the link below and paste it into the additional board manager as shown in the diagram. a link to download

Step 2:

We must now obtain the FreeRTOS library file. To download, go to Sketch-> Include Library-> Manage Libraries and select Manage Libraries from the drop-down menu.

Step 3:

Wait for a second, then type FreeRTOS into the search field. It will display some library files; scroll down and look for STM32duino FreeRTOS by Richard Barry. Then choose that library and install it. Installing it will take some time. Shows as installed after installation.

Step 4:

Our Arduino can now use the STM32F103C8 freeRTOS library. We’ll make a basic blinking program for both the onboard and separate LEDs.

Hardware Required

  • STM32F103C board
  • FTDI
  • LED
  • Jumper Wires
  • Breadboard

I’m utilizing one onboard led, which is connected to PC13, and the other led, which is attached to PB11, is connected separately.

How to run two different tasks on STM32F103C8 using FreeRTOS?

I’m using two LEDs, and for each LED, I’m creating two tasks. In this job, one led blinks for one second while the other blinks for 200 milliseconds. Let’s get started with the FreeRTOS coding for two flashing LEDs.

In the Arduino IDE, create a new sketch and paste the code below into it.

#include <MapleFreeRTOS821.h>
#define BOARD_LED_PIN PC13
#define LED_PIN PB11

static void task1(void *pvParameters) {
for (;;) {
digitalWrite(BOARD_LED_PIN, HIGH);
digitalWrite(BOARD_LED_PIN, LOW);

static void task2(void *pvParameters) {
for (;;) {
digitalWrite(LED_PIN, HIGH);
digitalWrite(LED_PIN, LOW);

void setup()

void loop()

After uploading the code, you can see the following result.

FreeRTOS STM32F103C8 Arduino


I hope all of you have understood how to use FreeRTOS for STM32F103C8 in Arduino IDE. We MATHA ELECTRONICS will be back soon with more informative blogs.

Leave a Reply

Your email address will not be published.