项目场景
MCU:STM32F103RBT6/APM32F103RBT6 STM32CUBEMX:Version 6.5.0 FreeRTOS:Version10.0.1 CMSIS-V2
问题描述
配置没有问题,事件组设置位不成功 中断里调用osEventFlagsSet 函数返回值为-3
void USAR_UART_IDLECallback(UART_HandleTypeDef *huart)
{
extern osEventFlagsId_t Event_Ranging_ReceivedHandle;
HAL_UART_DMAStop(&huart3);
data_length = BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&hdma_usart3_rx);
osEventFlagsSet(Event_Ranging_ReceivedHandle,EVENTBIT_DATA_RECEIVED);
}
原因分析
返回值-3 对应osErrorResource ,查看osEventFlagsSet 源码发现这句代码有问题
if (xEventGroupSetBitsFromISR (hEventGroup, (EventBits_t)flags, &yield) != pdFAIL) {
rflags = (uint32_t)osErrorResource;
} else {
rflags = flags;
portYIELD_FROM_ISR (yield);
}
xEventGroupSetBitsFromISR (hEventGroup, (EventBits_t)flags, &yield) != pdFAIL 应该是== pdFAIL 才对啊!
解决方案
经过查阅确定这是FreeRTOS-10.0.1版本的BUG 官方github issues
所以我们只要把!= pdFAIL 改成== pdFAIL 就可以解决问题了!
|