使用GD32F450跑freeRTOS,串口中断内接受数据并放入队列,队列就卡死了,跟踪发现是断言失败,串口中断的优先级不在freeRTOS中断优先级管理范围内。
/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15
/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
void USART2_IRQHandler(void)
{
u8 res = 0;
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
if (RESET != usart_interrupt_flag_get(EVAL_COM2, USART_INT_FLAG_RBNE))
{
res = (uint8_t)usart_data_receive(EVAL_COM2);
if(pdFALSE == xQueueSendFromISR(xQueue_coder, &res, &xHigherPriorityTaskWoken));
{
printf("send error\r\n");
}
//nvic_irq
nvic_irq_enable(USART2_IRQn, 7, 0);
usart_interrupt_enable(EVAL_COM2,USART_INT_RBNE);
//end
usart_enable(EVAL_COM2);
结果会进入断言:
/* Priority grouping: The interrupt controller (NVIC) allows the bits
that define each interrupt's priority to be split between bits that
define the interrupt's pre-emption priority bits and bits that define
the interrupt's sub-priority. For simplicity all bits must be defined
to be pre-emption priority bits. The following assertion will fail if
this is not the case (if some bits represent a sub-priority).
If the application only uses CMSIS libraries for interrupt
configuration then the correct setting can be achieved on all Cortex-M
devices by calling NVIC_SetPriorityGrouping( 0 ); before starting the
scheduler. Note however that some vendor specific peripheral libraries
assume a non-zero priority group setting, in which cases using a value
of zero will result in unpredicable behaviour. */
configASSERT( ( portAIRCR_REG & portPRIORITY_GROUP_MASK ) <= ulMaxPRIGROUPValue );
我的解答思路和尝试过的方法
修改了优先级,串口中断为7,freeRTOS为5-15,但是不行
我想要达到的结果
可能还是哪里的问题?