shiguojie19892 2022-03-01 11:20
浏览 157
已结题

【GD32中,串口中断调用freeRTOS的API后断言失败】

使用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,但是不行

我想要达到的结果

可能还是哪里的问题?

  • 写回答

1条回答 默认 最新

  • 有问必答小助手 2022-03-02 19:16
    关注

    你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答


    本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。


    因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。

    评论

报告相同问题?

问题事件

  • 系统已结题 3月9日
  • 创建了问题 3月1日

悬赏问题

  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法