新手上路
- 积分
- 38
- 金钱
- 38
- 注册时间
- 2020-4-5
- 在线时间
- 17 小时
|
楼主 |
发表于 2020-8-17 13:00:14
|
显示全部楼层
相关图片被吞掉了,我重新写一下
相关代码
XCOM接受数据为
TIM3 IRQ
TIM3 IRQ
bit0 and bit1 have set 1
task running
task running
task running
相关定时器中断代码
void TIM2_IRQHandler(void) //TIM2ÖжÏ
{
BaseType_t xResult;
BaseType_t xHigherPriorityTaskWoken=pdFALSE;
TIM_Cmd(TIM2, DISABLE);
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET) //¼ì²éTIM2¸üÐÂÖжϷ¢ÉúÓë·ñ
{
xResult=xEventGroupSetBitsFromISR(xCreatedEventGroup,0x01,&xHigherPriorityTaskWoken);
printf("TIM3 IRQ\r\n");
if(xResult!=pdFAIL)
{
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
TIM_ClearITPendingBit(TIM2, TIM_IT_Update ); //Çå³ýTIMx¸üÐÂÖжϱêÖ¾
}
void TIM3_IRQHandler(void) //TIM3ÖжÏ
{
BaseType_t xResult;
BaseType_t xHigherPriorityTaskWoken=pdFALSE;
TIM_Cmd(TIM3, DISABLE);
if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //¼ì²éTIM3¸üÐÂÖжϷ¢ÉúÓë·ñ
{
xResult=xEventGroupSetBitsFromISR(xCreatedEventGroup,0x02,&xHigherPriorityTaskWoken);
printf("TIM3 IRQ\r\n");
if(xResult!=pdFAIL)
{
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
TIM_ClearITPendingBit(TIM3, TIM_IT_Update ); //Çå³ýTIMx¸üÐÂÖжϱêÖ¾
}
对应事件标志位任务代码
void vTask_ledshow(void *pvParameters)
{
EventBits_t uxBITs;
const TickType_t xTickstoWait=100/portTICK_PERIOD_MS; //100ms
while(1)
{
uxBITs=xEventGroupWaitBits(xCreatedEventGroup,0x03,pdTRUE,pdTRUE,portMAX_DELAY);
if((uxBITs&0x03)==0x03)
{
printf("bit0 and bit1 have set 1\r\n");
PBout(5)=!PBout(5);
vTaskDelay(500);
}else
{
printf("bit0 and bit1 have not set 1\r\n");
}
}
}
同时定时器初始化里面必须加入临界段不然会在定时器里面的NVIC_Init(&NVIC_InitStructure);里初始化失败进入硬故障,定时器初始化代码和正点freertos里代码里相同,但是正点里程序就不需要加入临界段,
taskENTER_CRITICAL();
TIM2_Int_Init(499,7199);//10KhzµÄ¼ÆÊýƵÂÊ£¬50ms
TIM3_Int_Init(499,7199);//10KhzµÄ¼ÆÊýƵÂÊ£¬50ms
taskEXIT_CRITICAL();
|
|