LM3S9B96 safertos启动调度器失败?

2019-03-24 12:38发布

将官方例程去掉几个任务后,就剩下空闲任务、LED任务和显示任务,运行一下,液晶屏显示:Failed to start scheduler!,这说明几个任务都创建成功了,但是调度器为什么会启动失败呢?看了下手册,调度器启动失败的可能原因有:1.在启动调度器之前没有创建任务。2.调度器已经在运行中。3.调度器不能启动空闲任务。
难道是调度器不能启动空闲任务?不明白啊。。
int
main(void)
{
    tContext sContext;
    tRectangle sRect;

    // Set the clocking to run at 80 MHz from the PLL.
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
                       SYSCTL_OSC_MAIN);

    // Initialize the device pinout appropriately for this board.
    PinoutSet();

    Kitronix320x240x16_SSD2119Init();// 初始化显示驱动

    // 初始化图形设备上下文
    GrContextInit(&sContext, &g_sKitronix320x240x16_SSD2119);

    // Fill the top 24 rows of the screen with blue to create the banner.
    sRect.sXMin = 0;
    sRect.sYMin = 0;
    sRect.sXMax = GrContextDpyWidthGet(&sContext) - 1;
    sRect.sYMax = 23;
    GrContextForegroundSet(&sContext, ClrDarkBlue);
    GrRectFill(&sContext, &sRect);

    // Put a white box around the banner.
    GrContextForegroundSet(&sContext, ClrWhite);
    GrRectDraw(&sContext, &sRect);

    // Put the application name in the middle of the banner.
    GrContextFontSet(&sContext, &g_sFontCm20);
    GrStringDrawCentered(&sContext, "safertos-demo", -1,
                         GrContextDpyWidthGet(&sContext) / 2, 10, 0);

    // 设置系统堆栈的位置和大小
    g_sSafeRTOSPortInit.pulSystemStackLocation =
        (unsigned portLONG *)(*(unsigned long *)0);
    g_sSafeRTOSPortInit.ulSystemStackSizeBytes = 128 * 4;

    // 设置向量表的位置
    g_sSafeRTOSPortInit.pulVectorTableBase =
        (unsigned portLONG *)HWREG(NVIC_VTABLE);

    // 初始化SafeRTOS内核
    vTaskInitializeScheduler((signed portCHAR *)g_pulIdleTaskStack,
                             sizeof(g_pulIdleTaskStack), 0,
                             &g_sSafeRTOSPortInit);

    // 创建显示任务
    if(DisplayTaskInit() != 0)
    {
        GrContextForegroundSet(&sContext, ClrRed);
        GrStringDrawCentered(&sContext, "Failed to create display task!", -1,
                             GrContextDpyWidthGet(&sContext) / 2,
                             (((GrContextDpyHeightGet(&sContext) - 24) / 2) +
                              24), 0);
        while(1)
        {
        }
    }

    // 创建LED任务
    if(LEDTaskInit() != 0)
    {
        GrContextForegroundSet(&sContext, ClrRed);
        GrStringDrawCentered(&sContext, "Failed to create LED task!", -1,
                             GrContextDpyWidthGet(&sContext) / 2,
                             (((GrContextDpyHeightGet(&sContext) - 24) / 2) +
                              24), 0);
        while(1)
        {
        }
    }

    // 启动调度器,这将没有返回
    xTaskStartScheduler(pdTRUE);   

    // 如果调度器由于某种原因返回,打印错误并无限循环
    GrContextForegroundSet(&sContext, ClrRed);
    GrStringDrawCentered(&sContext, "Failed to start scheduler!", -1,
                         GrContextDpyWidthGet(&sContext) / 2,
                         (((GrContextDpyHeightGet(&sContext) - 24) / 2) + 24),
                         0);
    while(1)
    {
    }
} 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
2条回答
mitop01
1楼-- · 2019-03-24 18:42
< 没怎么看懂!!
Study_Stellaris
2楼-- · 2019-03-24 23:08
 精彩回答 2  元偷偷看……

一周热门 更多>

相关问题

    相关文章