This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SYSBIOS 串口打印异常

Other Parts Discussed in Thread: SYSBIOS

搭建了一个简单的BIOS演示系统,注册两个任务SYS_BootTask(优先级高)与SYS_AppTask(优先级低),对应的任务代码如下,其中函数“UART_DbgPrintf”是串口发送数据(非中断,采用polling方式,uart驱动是自己写的,已经在非BIOS模式下测试正常)。函数“System_printf”与“System_flush”是sysbios提供的系统输出接口(输出在console上显示)。

void SYS_BootTask(UArg arg1, UArg arg2)

{

    while(1)

    {

    Semaphore_pend(semBoot, BIOS_WAIT_FOREVER);

    UART_DbgPrintf(DSP_DBG_UART, "SYS_BootTask\r\n");

    //System_printf("SYS_BootTask\r\n");

   //System_flush();

    gCnt++;

    Task_sleep(DLY_CONST);

    Semaphore_post(semApp);

    }

}

void SYS_AppTask(UArg arg1, UArg arg2)

{

    while(1)

    {

    Semaphore_pend(semApp, BIOS_WAIT_FOREVER);

    UART_DbgPrintf(DSP_DBG_UART, "SYS_MeterTask\r\n");

    Task_sleep(DLY_CONST);

    Semaphore_post(semBoot);

    }

}

问题出现在:通过仿真器将程序下载到板子上(DDR2内),使用函数“System_printf”与“System_flush”时系统能正常运行,两个任务能交替切换并输出打印信息,但是一旦将输出函数替换为函数“UART_DbgPrintf”,则会在打印字符串“SYS_BootTas”后出现异常跳转,还有字符串“k\r\n”没有通过串口输出(串口波特率115200,clock tick周期设置为1ms,用的是timer0)。出错的函数调用层次与具体的中断代码如下:

能否提供一些调试的思路?

  • 问题找到了,是在添加初始化代码时,忘记屏蔽中断控制器的配置代码,应该是sysbios已经完成了timer0的中断设置,但是我们自己的用户程序又进行了覆盖,覆盖代码如下:

    while(step != C674X_INT_COUNT)
    c674xISRtbl[step++] = IntDefaultHandler;

    从出错的特点也符合推测:

    115200速率打印“SYS_BootTas”共11*11比特,耗时在1ms左右,而timer0对应的clock tick间隔设置为1ms。