当前位置:网站首页>[detailed steps of FreeRTOS shift value for the first time]
[detailed steps of FreeRTOS shift value for the first time]
2022-07-06 04:35:00 【Struggling little Yin】
FreeRTOS Shift value
List of articles
Tips : The following is the main body of this article , The following cases can be used for reference
One 、 What is? FreeRTOS?
FreeRTOS Name , It can be divided into two parts :Free and RTOS,Free It's free 、 The freedom of the 、 Unconstrained meaning ,RTOS The full name is Real Time Operating System, The Chinese name is the real-time operating system . It can be seen that FreeROTS It's a free RTOS Class system . Pay attention here ,RTOS It doesn't mean a certain system , It's a system . such as UCOS,FreeRTOS,RTX,RT-Thread Wait, these are all RTOS Class operating system .
Two 、FreeRTOS Characteristics
FreeRTOS It's a croppable small RTOS System , Its features include :
● FreeRTOS The kernel supports preemptive , Cooperative and time slice scheduling .
● SafeRTOS Derived from FreeRTOS,SafeRTOS In terms of code integrity FreeRTOS better .
● A method for low power consumption is provided Tickless Pattern .
● System components can be created dynamically or statically RAM, For example, tasks 、 Message queue 、 Semaphore 、 Software timer, etc .
● It's already surpassing 30 The architecture is transplanted on the chip . ● FreeRTOS-MPU Support Corex-M In the series MPU unit , Such as STM32F103.
● FreeRTOS The system is simple 、 small 、 Easy to use , Usually, the kernel occupies 4k-9k Byte space .
● High portability , Code main C Language writing .
● Support real-time tasks and collaborative processes (co-routines It is also called cooperative 、 Collaborative process , This tutorial has become a collaborative process ).
● Tasks and tasks 、 Task notifications can be used between tasks and interrupts 、 Message queue 、 Binary semaphore 、 Numeric letter Number quantity 、 Recursive mutex semaphores and mutex semaphores communicate and synchronize .
● Innovative event group ( Or event flags ).
● Mutually exclusive semaphores with priority inheritance .
● Efficient software timer .
● Powerful tracking execution function .
● Stack overflow detection function .
● There is no limit to the number of tasks .
● There is no limit to task priority .
Get to the point FreeRTOS Shift value
3、 ... and 、FreeRTOS Shift value
The following is based on the firmware library template FreeRTOS Shift value
3.1、 add to FreeRTOS Source code
First, we create the following folders in the firmware library template

establish FreeRTOS Folder, you can put FreeRTOS Add the source code to this folder ( As shown in the figure below )HARDWARE It is used to store the peripheral code we use later SYSTEM It is used to store system files, which will be introduced below

portable Folder , We just need to stay keil、MemMang and RVDS These three folders , Others can be deleted , After completion, as shown in the figure

3.2、 Open firmware library project Add files to the group for the project files under
Add the following groups c The files are imported into the corresponding folders

add to c file , Click the button below to add a shortcut

3.3、 Add file path
Click on the magic wand choice c/c++ Corresponding c Add the path of the header file

That's it FreeRTOS Simple value shifting and environment configuration
Four 、FreeRTOS First experiment
Next we will move the value of good FreeRTOS Perform simple multitasking procedures
Used in the project usart sys delay Relevant documents are put in SYSTEM In folder I will put the complete file below .
/*---------------------------------------------------------------------- * first FreeRTOS experiment *Date:2022-2-12 *Author: Xiao Yin *---------------------------------------------------------------------*/
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "FreeRTOS.h"
#include "task.h"
// Task priority
#define START_TASK_PRIO 1
// Task stack size
#define START_STK_SIZE 128
// Task to handle
TaskHandle_t StartTask_Handler;
// Task function
void start_task(void *pvParameters);
// Task priority
#define LED0_TASK_PRIO 2
// Task stack size
#define LED0_STK_SIZE 50
// Task to handle
TaskHandle_t LED0Task_Handler;
// Task function
void led0_task(void *pvParameters);
// Task priority
#define LED1_TASK_PRIO 3
// Task stack size
#define LED1_STK_SIZE 50
// Task to handle
TaskHandle_t LED1Task_Handler;
// Task function
void led1_task(void *pvParameters);
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);// Set system interrupt priority group 4
delay_init(); // Delay function initialization
uart_init(115200); // Initialize serial port
LED_Init(); // initialization LED
// Create start task
xTaskCreate((TaskFunction_t )start_task, // Task function
(const char* )"start_task", // The name of the task
(uint16_t )START_STK_SIZE, // Task stack size
(void* )NULL, // Parameters passed to the task function
(UBaseType_t )START_TASK_PRIO, // Task priority
(TaskHandle_t* )&StartTask_Handler); // Task to handle
vTaskStartScheduler(); // Turn on task scheduling
}
// Start task task function
void start_task(void *pvParameters)
{
taskENTER_CRITICAL(); // Enter the critical area
// establish LED0 Mission
xTaskCreate((TaskFunction_t )led0_task,
(const char* )"led0_task",
(uint16_t )LED0_STK_SIZE,
(void* )NULL,
(UBaseType_t )LED0_TASK_PRIO,
(TaskHandle_t* )&LED0Task_Handler);
// establish LED1 Mission
xTaskCreate((TaskFunction_t )led1_task,
(const char* )"led1_task",
(uint16_t )LED1_STK_SIZE,
(void* )NULL,
(UBaseType_t )LED1_TASK_PRIO,
(TaskHandle_t* )&LED1Task_Handler);
vTaskDelete(StartTask_Handler); // Delete start task
taskEXIT_CRITICAL(); // Exit critical region
}
//LED0 Task function
void led0_task(void *pvParameters)
{
while(1)
{
LED0=~LED0;
vTaskDelay(500);
printf("led1 is running\r\n");
}
}
//LED1 Task function
void led1_task(void *pvParameters)
{
while(1)
{
LED1=0;
vTaskDelay(200);
LED1=1;
vTaskDelay(800);
printf("led2 is running\r\n");
}
}
The specific relevant parameters in the code are not introduced Basic people can go B Stand and learn
because stm32f103c8t6 Only one onboard LED We print through serial port

Be careful
The above multi task creation is created in a dynamic form It is a little different from static creation
During dynamic creation, we will define the following macro by 0 When using static creation, it is 1

configSUPPORT_STATIC_ALLOCATION 1 Set to 1 If you use the dynamic creation method, the following error will appear. Just modify it accordingly

Links to related materials
link :https://pan.baidu.com/s/1EXxSt6QEd1lCaXnlDryv-g
Extraction code :8ac6
– From Baidu network disk super member V4 The share of
边栏推荐
- P3500 [poi2010]tes intelligence test (two points & offline)
- Query the number and size of records in each table in MySQL database
- Figure application details
- Visio draw fan
- 题解:《单词覆盖还原》、《最长连号》、《小玉买文具》、《小玉家的电费》
- Understanding of processes, threads, coroutines, synchronization, asynchrony, blocking, non blocking, concurrency, parallelism, and serialization
- ue5 小知识点 开启lumen的设置
- Vulnerability discovery - vulnerability probe type utilization and repair of web applications
- MLAPI系列 - 04 - 网络变量和网络序列化【网络同步】
- 11. Intranet penetration and automatic refresh
猜你喜欢

Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system

Slow SQL fetching and analysis of MySQL database

How to estimate the population with samples? (mean, variance, standard deviation)

Execution order of scripts bound to game objects

查询mysql数据库中各表记录数大小

Dry goods collection | Vulkan game engine video tutorial
![Mlapi series - 04 - network variables and network serialization [network synchronization]](/img/fc/aebbad5295481788de5c1fdb432a77.jpg)
Mlapi series - 04 - network variables and network serialization [network synchronization]

MySQL learning record 13 database connection pool, pooling technology, DBCP, c3p0

Stable Huawei micro certification, stable Huawei cloud database service practice

CADD课程学习(7)-- 模拟靶点和小分子相互作用 (柔性对接 AutoDock)
随机推荐
Vulnerability discovery - vulnerability probe type utilization and repair of web applications
Comprehensive ability evaluation system
深入浅出node模板解析错误escape is not a function
R note prophet
newton interpolation
HotSpot VM
When debugging after pycharm remote server is connected, trying to add breakpoint to file that does not exist: /data appears_ sda/d:/segmentation
Visio draws Tai Chi
[Chongqing Guangdong education] Suzhou University English film and Television Appreciation reference materials
Lagrange polynomial
【HBZ分享】云数据库如何定位慢查询
I'd like to ask about the current MySQL CDC design. In the full volume phase, if a chunk's binlog backfill phase,
我想问一下 按照现在mysql-cdc的设计,全量阶段,如果某一个chunk的binlog回填阶段,
P2102 地砖铺设(dfs&贪心)
2327. Number of people who know secrets (recursive)
Easyrecovery靠谱不收费的数据恢复电脑软件
JVM garbage collector concept
In depth MySQL transactions, stored procedures and triggers
E. Best Pair
Script lifecycle