当前位置:网站首页>Stm32g0 Tim interrupt use
Stm32g0 Tim interrupt use
2022-06-30 07:11:00 【Delta-delta】
Clock configuration
TIM To configure
3s An interruption
Interrupt configuration
Turn on
HAL_TIM_Base_Start_IT(&htim1);
Critical area in mission
static void vTaskLED(void *pvParameters)
{
while(1)
{
uint8_t data[]="LED";
taskENTER_CRITICAL(); /* Enter the critical area */
HAL_UART_Transmit(&huart1,data,sizeof(data),0xff);
taskEXIT_CRITICAL(); /* Exit critical region */
HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_5);
vTaskDelay(500);
}
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if(htim->Instance==TIM1)
{
uint8_t data[]="TIM1 Interrupt";
HAL_UART_Transmit(&huart1,data,sizeof(data),0xff);
}
}
with FreeRTOS
Critical area of interruption
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
BaseType_t xYieldRequired;
UBaseType_t uxSavedInterruptStatus;
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); /* Enter the critical area */
{
/* Users can add critical code here , We haven't used it yet */
if(htim->Instance==TIM1)
{
uint8_t data[]="TIM1 Interrupt";
HAL_UART_Transmit(&huart1,data,sizeof(data),0xff);
}
}
portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); /* Exit critical region */
/** Resume pending tasks */
xYieldRequired = xTaskResumeFromISR(xHandleTaskLED);
/* Whether to perform task switching after exiting the interrupt */
if( xYieldRequired == pdTRUE )
{
portYIELD_FROM_ISR(xYieldRequired);
}
}
边栏推荐
猜你喜欢
Idea running run and services
大学刚毕业不知道做什么工作怎么办?
The maximum expression in Oracle database message list is 1000 error
Pit stepping record: Supervisor log return information: redis extension is not installed
[docsify basic use]
Go语言指针介绍
[resolved] MySQL exception: error 1045 (28000): unknown error 1045, forgetting the initial password
汇编语言学习一(有栈协程铺垫,32位寄存器和相关指令学习,未完待续06/29)
Connection flood attack principle
Qtcreator debug code after configuring CDB debugger view variable value display card
随机推荐
经纬恒润再次荣获PACCAR集团 10PPM 质量奖
What underlying technologies support the metauniverse?
Pit stepping record: Supervisor log return information: redis extension is not installed
Connection flood attack principle
Go语言指针介绍
2、 Layout system
js创建pdf文件
Go项目目录结构介绍
我今年毕业,但我不知道我要做什么
MySQL优化:从十几秒优化到三百毫秒
【docsify基本使用】
The first up Master of station B paid to watch the video still came! Price "Persuading" netizens
Deploying web projects using idea
[Hot100]10. 正则表达式匹配
Redis cache
ROS-URDF
June 29, 2022 -- take the first step with C # -- add decision logic to the code using the "if", "else" and "else if" statements in C #
NFS mount
Determine whether the picture is in JPG picture format
B站首个UP主付费观看视频还是来了!价格“劝退”网友