yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
STM32-BoardCar📖
0. Get started quickly
  • 0.ReadMe
  • 1. Installation Instructions
  • 2. Version configuration
  • 3. Smart car installation video
  • 4. Precautions for use
1. Introduction to STM32 development board
  • 1. Learn about STM32
  • 2. Introduction to STM32 development board
  • 3. Development board pin assignment
  • 4. Introduction to HAL library and LL library
2. Setting up and using the development environment
  • 1. Common development tools
  • 2. STM32CubeMX Install - Use
  • 3. STM32CubeIDE Install - Use
  • 4. Common Driver Installation
  • 5. Program download and simulation
  • 6. Engineering experience and migration
3. Development board basic tutorial
  • 1. RGB searchlight (GPIO)
  • 2. Buzzer control (GPIO)
  • 3. Button control (EXTI)
  • 4. Serial communication (UASRT)
  • 5. Voltage detection (ADC)
  • 6. Internal temperature sensor(ADC)
  • 7. Independent watchdog(IWDG)
  • 8. Window watchdog(WWDG)
  • 9. Basic timer (TIM6)
  • 10. Universal Timer (TIM3)
  • 11. Advanced timers (TIM1)
  • 12. I2C Communication (IIC)
  • 13. Off-chip Flash (SPI)
  • 14. On-chip Flash (Flash)
  • 15. DMA:USART
  • 16. DMA:SPI
  • 17. DMA:I2C
  • 18. USB communication
  • 19. USB analog U disk
  • 20. FreeRTOS
4. Car expansion tutorial
  • 1. Servo control
  • 2. Basic use of ultrasonic steering gear gimbal
  • 3. Motor control
  • 4. OLED display light sensitivity value
  • 5. Infrared sensor
  • 6. Four-way tracking module
  • 7. Infrared remote control
  • 8. Ultrasonic ranging
  • 9. PS2 controller test
  • 10.K230 Vision Module
  • 11.AI voice interaction integration module
5. Robot car tutorials
  • 1. Car line patrol
  • 2. Ultrasonic follow
  • 3. Ultrasonic obstacle avoidance
  • 4. Ultrasonic obstacle avoidance (servo gimbal version)
  • 5. Infrared sensor obstacle avoidance
  • 6. Infrared remote control
  • 7. PS2 handle remote control
  • 8.K230 face tracking on PTZ
  • 9.K230 color tracking
  • 10.K230 Color Line Patrol
  • 11.K230 QR code command
  • 12.K230 machine code tracking
  • 13.K230 road sign indication action (voice)
  • 14.K230 color response (voice)
  • 15.K230 gesture control (voice)
  • 16.K230 Rock-Paper-Scissors Game (Voice)
6. Operation video
  • 1-How to install STM32CubeIDE software
  • 2-How to create Demo project
  • 3-How to download code into STM32 robot car
  • 4-How to open and compile a code file for STM32
  • 5-About IR control and Charge battery
Download
  • Code
  • SCH
  • Software File
  • STM32 Chip DataSheet
  • Installation manual
Download ZIP

Welcome to STM32-BoardCar repository

20. FreeRTOS

FreeRTOS

FreeRTOS1、software-hardware2、Brief principle2.1、Hardware schematic diagram2.2、Physical connection diagram2.3、Principle of control3、Engineering configuration3.1、Notes3.2、Pin configuration4、Main Function4.1、User function4.2、HAL library function parsing5、Experimental phenomenon

This tutorial demonstrates: Real-time control of RGB lights, leds, and active buzzers with FreeRTOS.

1、software-hardware

  • STM32F103CubeIDE

  • STM32 robot expansion board

    GPIO: Internal peripheral of the chip

    RGB, LED, key, active buzzer: onboard

  • Type-C cable or ST-Link

    Download or simulate the program of the development board

2、Brief principle

2.1、Hardware schematic diagram

image-20231115180830896

2.2、Physical connection diagram

image-20231115181055917

2.3、Principle of control

Bare metal systems:Most of our cases run on bare metal systems, where programs are usually inside the main loop or interrupts; Multi-task system:The real-time operating system divides the program into independent applets, each applet is a task, each task is independent, non-interfering with each other, and has its own priority, which is configured by the operating system.

  • FreeRTOS

FreeRTOS(Real Time Operating System)

Because real-time operating system involves a lot of content, the tutorial will briefly introduce the website learning materials location and real-time operating system involved in the concept.

Official website Learning website:https://www.freertos.org/RTOS.html

The official online resources provide FreeRTOS books, documentation about the FreeRTOS kernel, the FreeRTOS API reference manual, and more.

image-20231120152637278

If you enter from the official website by yourself, you should click "Getting Strated" → "Getting started with the FreeRTOS kernel: Learn More" in turn.

image-20231120152909332

Basics of real-time operating systems

FreeRTOSfeature
TaskThe basic unit of FreeRTOS
SchedulerManage the execution order and switching of tasks
SemaphoreIt is used for synchronizing and mutually exclusive access to shared resources between tasks
Event FlagsUsed for event notification and synchronization between tasks
QueueIt is used for data transfer and communication between tasks.
MutexIt is used to implement mutually exclusive access to resources, ensuring that only one task can access a shared resource at a time.
TimerIt can be used to periodically trigger events or perform tasks
  • Practical Applications

We can use the CubeMX plugin to initialize and configure FreeRTOS, and configure FreeRTOS components such as tasks, timers, semaphores, and message queues according to our requirements. The following table is the name and function of the newly created tasks during the project configuration:

Taskfeature
myTask_RGBControl RGB
myTask_BeepControl the buzzer
myTask_KEYCheck the KEY1 status
myTask_LEDControl LED
xxxxxxxxxx
The task entity functions are defined in the bsp_task.c file and actually called in freertos.c
  • RGB:High level light, low level off
RGB(Schematic name)Control pinfeature
LRGB-RPG1Control the red light display of the RGB light on the left
LRGB-GPE7Control the green display of the RGB light on the left
LRGB-BPG2Control the blue light display of the RGB light on the left
RRGB-RPE2Control the red light display of the RGB light on the right
RRGB-GPE3Control the green display of the RGB light on the right
RRGB-BPE4Control the blue light display of the RGB light on the right
  • LED:High level on, low level off
LED(Schematic name)Control pinfeature
LED1PG14控制LED1亮灭
LED2PG15控制LED2亮灭
  • KEY:Default high level, press the key low level
KEY(Schematic name)Control pinfeature
KEY1PG3Change the KEY1 pin level state
KEY2PG4Change the KEY2 pin level state
KEY3PG5Change the KEY3 pin level state
  • Buzzer: high level sound, low level do not sound
buzzer(Schematic name)Control pinfeature
BuzzerPG12Control the buzzer to sound

3、Engineering configuration

Project Configuration: Prompts for configuration options in the STM32CubeIDE project configuration process

3.1、Notes

Omitted project configuration: New project, chip selection, project configuration, SYS for pin configuration, RCC configuration, clock configuration, and project configuration content

The project configuration part, which is not omitted, is the key point to configure in this tutorial.

xxxxxxxxxx
Please refer to [2. Development environment construction and use: STM32CubeIDE installation and use] to understand how to configure the omitted parts of the project.

3.2、Pin configuration

  • Configure the specified pin function

You can directly select the corresponding pin number in the pin view, and the corresponding option will appear when the mouse is left clicked

image-20231115184703726

  • GPIO

image-20231115184825359

  • SYS

The reference is changed to TIM1

image-20231115185001936

  • FREERTOS

The four tasks differ only in task name and task function entity

image-20231115185212854

Task optionsfeature
Task NameTask name
PrioritySet priorities
Stack Size (Words)Heap space
Entry FunctionTask function entity
Code Generation OptionCode generation configuration, default is weak generation task entity
ParameterTask parameters
AllocationYou can choose between Dynamic allocation or Static allocation
Buffer NameStatically allocated buff name
Control Block NameThe statically allocated block name

4、Main Function

This section mainly introduces the functional code written by users. Detailed code can be viewed by opening the project file provided by us. .

4.1、User function

function:Task_Entity_RGB

Function prototypesvoid Task_Entity_RGB(void)
Functional DescriptionRGB task entity function: controls the left and right RGB light color switching
Input parametersNone
Return valueNone

function:Task_Entity_BEEP

Function prototypesvoid Task_Entity_BEEP(void)
Functional DescriptionBuzzer task entity function: Control the buzzer to sound
Input parametersNone
Return valueNone

function:Task_Entity_LED

Function prototypesvoid Task_Entity_LED(void)
Functional DescriptionLED task entity function: Control the left and right RGB light color switching
Input parametersNone
Return valueNone

function:Task_Entity_KEY

Function prototypesvoid Task_Entity_KEY(void)
Functional DescriptionKey task entity function: switch the state of buzzer and LED light
Input parametersNone
Return valueNone

4.2、HAL library function parsing

The HAL library functions that were covered in the previous tutorial will not be covered

xxxxxxxxxx
If you want to find the HAL library and LL library function analysis involved in the entire tutorial, you can view the documents in the folder [8. STM32 Manual: STM32F1_HAL Library and LL Library_User Manual]

function:MX_FREERTOS_Init

Function prototypesvoid MX_FREERTOS_Init(void)
Functional DescriptionTasks to initialize FreeRTOS: Create and initialize components such as tasks, queues, mutexes, etc
Input parametersNone
Return valueNone

function:osKernelStart

Function prototypesosStatus osKernelStart (void)
Functional DescriptionStart the scheduler of the RTOS kernel and start executing tasks
Input parametersNone
Return valueosStatus:The result of the function execution

function:osDelay

Function prototypesosStatus osDelay (uint32_t millisec)
Functional DescriptionThe operating system's latency function
Input parametersThe delay (in ms)
Return valueosStatus:The result of the function execution
TipsPause the thread, execute another thread, and wait until the delay is complete

5、Experimental phenomenon

After downloading the program successfully, press the RESET button of the development board to observe the phenomenon of the development board

xxxxxxxxxx
For program download, please refer to [2. Development environment construction and use: program download and simulation]

Phenomenon:

Left and right RGB lights:toggle different colors all the time;

KEY1 button:The buzzer sound switch, sound and no sound interval of 1s (press once to open, then press once to close);

KEY2 button:The switch for LED1 (press once to be on and again to be off);

KEY3 button:The LED2 switch (press once to be on and again to be off).

The experimental phenomenon can be seen [freertos_experimental Phenomenon.mp4]
USB analog U disk
Servo control

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文