当前位置:网站首页>FreeRTOS timer group
FreeRTOS timer group
2022-06-30 07:11:00 【Delta-delta】
Introduce
FreeRTOS The time base of software timer group is realized based on the beat of system clock . When creating a software timer , Specify the callback function of the software timer , Implement the corresponding functions in the callback function .FreeRTOS The software timer provided supports single mode and periodic mode : The single mode is after the user creates the timer and starts the timer , When the scheduled time expires, it will not be executed again ; The cycle mode is that this timer will execute repeatedly according to the set time cycle .
Be careful : The timer callback function is executed in the timer task , In practical application, it is forbidden to call any function that suspends timer task in timer callback function , such as vTaskDelay(),vTaskDelayUntil() And non-zero delay message queue and semaphore related function . Suspend timer task , This will cause the relevant functions of the timer task to be performed incorrectly .
FreeRTOSConfig.h To configure
#define configUSE_TIMERS 1
#include "timers.h"
Correlation function
function xTimerCreate


function xTimerStart


function pvTimerGetTimerID
void *pvTimerGetTimerID( TimerHandle_t xTimer ); /* Timer handle */
function pvTimerGetTimerID Used to return the use function xTimerCreate Software timer created ID.
Use
Definition Timer
static TimerHandle_t xTimers = NULL;
xTimers = xTimerCreate("Timer", /* The name of the timer */
3000, /* Timer cycle , Unit clock beat */
pdTRUE, /* periodic */
(void * )0x01, /* Timer ID */
vTimerCallback); /* Timer callback function */
if(xTimers == NULL)
{
/* Not created successfully , The user can add the handling mechanism of creation failure here */
}
else
{
/* Start timer , The system will not start working until it is started */
if(xTimerStart(xTimers, 100) != pdPASS)
{
/* The timer has not yet entered the active state */
}
}
Callback function
static void vTimerCallback(xTimerHandle pxTimer)
{
uint32_t ulTimerID;
configASSERT(pxTimer);
/* Get the timer time to */
ulTimerID = (uint32_t)pvTimerGetTimerID(pxTimer);
// /* Processing timer 0 Mission */
// if(ulTimerID == 0)
// {
// bsp_LedToggle(1);
// }
/* Processing timer 1 Mission */
if(ulTimerID == 1)
{
uint8_t data[]="This is a Timer";
taskENTER_CRITICAL(); /* Enter the critical area */
HAL_UART_Transmit(&huart1,data,sizeof(data),0xff);
taskEXIT_CRITICAL(); /* Exit critical region */
}
}
Reference documents
边栏推荐
猜你喜欢

Google Earth engine (GEE) - Murray global tidal wetland change V1 (1999-2019) data set

Starting MySQL ERROR! Couldn‘t find MySQL server (/usr/local/mysql/bin/mysqld_safe)

Realization of dissolve effect in unity and its principle analysis

MySQL encounters the problem of expression 1 of select list is not in group by claim and contains nonaggre

第一行代码(第三版)学习笔记
![[daily question] 535 Encryption and decryption of tinyurl](/img/73/35674cd5df3d937af0762645041421.png)
[daily question] 535 Encryption and decryption of tinyurl

Resolution: div failed to get keyboard event

Egret P2 physical engine (1) small ball falling demo

神经网络计算量及参数量

Skillfully use 5 keys to improve office efficiency
随机推荐
Base64 encoding method implemented by native JS
Servlet principle
Introduction to go language pointer
I graduated this year, but I don't know what I want to do
Egret P2 pit encountered by physical engine (1)
Double click the idea to solve the problem of downloading again
【我的OpenGL学习进阶之旅】关于OpenGL的着色器的向量和矩阵分类的访问方式: xyzw/rgba/stpq以及数组下标
How crazy are young people in sideline industry: 3000 monthly salary and 3W sideline income
MAX6675 usage notes
Deploying web projects using idea
Linux服务器安装Redis
MySQL encounters the problem of expression 1 of select list is not in group by claim and contains nonaggre
Ad usage notes
【每日一题】535. TinyURL 的加密与解密
Traverse map
Record common problems: spaces in encodeuricomponent decoding and the use of Schema in third-party apps to invoke apps
编写并运行第一个Go语言程序
[Hot100]10. 正则表达式匹配
Qdebug small details
Idea shortcut key