当前位置:网站首页>[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
边栏推荐
- CADD course learning (7) -- Simulation of target and small molecule interaction (flexible docking autodock)
- Fedora/rehl installation semanage
- 食品行业仓储条码管理系统解决方案
- Introduction to hashtable
- ue5 小知识点 开启lumen的设置
- SharedPreferences 源码分析
- Figure application details
- How do programmers teach their bosses to do things in one sentence? "I'm off duty first. You have to work harder."
- 2/13 review Backpack + monotonic queue variant
- How does computer nail adjust sound
猜你喜欢

CertBot 更新证书失败解决

题解:《单词覆盖还原》、《最长连号》、《小玉买文具》、《小玉家的电费》
![[face recognition series] | realize automatic makeup](/img/a5/de98d0522b9dae809cd242aac305b3.jpg)
[face recognition series] | realize automatic makeup

View workflow

Easyrecovery reliable and toll free data recovery computer software
![[tomato assistant installation]](/img/06/672a616d4fc2a43b83054eb1057628.jpg)
[tomato assistant installation]

Fedora/rehl installation semanage

Cross domain and jsonp details

电脑钉钉怎么调整声音

Comprehensive ability evaluation system
随机推荐
Platformio create libopencm3 + FreeRTOS project
Implementation of knowledge consolidation source code 2: TCP server receives and processes half packets and sticky packets
ETCD数据库源码分析——etcdserver bootstrap初始化存储
P2102 地砖铺设(dfs&贪心)
hashlimit速率控制
C. The third problem
MySQL reported an error datetime (0) null
CADD course learning (7) -- Simulation of target and small molecule interaction (flexible docking autodock)
Meet diverse needs: jetmade creates three one-stop development packages to help efficient development
VNCTF2022 WriteUp
Solve the compilation problem of "c2001: line breaks in constants"
The implementation of the maize negotiable digital warehouse receipt standard will speed up the asset digitization process of the industry
2/13 review Backpack + monotonic queue variant
Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022
Stable Huawei micro certification, stable Huawei cloud database service practice
Ue5 small knowledge freezerendering view rendered objects in the cone
[try to hack] John hash cracking tool
我想问一下 按照现在mysql-cdc的设计,全量阶段,如果某一个chunk的binlog回填阶段,
Is the mode of education together - on campus + off campus reliable
Slow SQL fetching and analysis of MySQL database