【问题标题】:FreeRTOS software timer (taskSCHEDULER_RUNNING) faultFreeRTOS 软件计时器 (taskSCHEDULER_RUNNING) 故障
【发布时间】:2018-08-27 09:57:25
【问题描述】:

硬件: 恩智浦 M4 MKE14

软件: MCUXpresso 10.1.1

一个软件定时器的实现非常顺利。当启动第二个定时器时,微控制器不再响应。我收到错误消息“taskSCHEDULER_RUNNING”。但是,如果这不运行,系统将不会执行任何操作。

我实现了计时器和一个这样的任务:

   /* Create the queue used by the queue send and queue receive tasks. */
        xQueue = xQueueCreate(/* The number of items the queue can hold. */
                              mainQUEUE_LENGTH,
                              /* The size of each item the queue holds. */
                              sizeof(uint32_t));

xSensorTimer = xTimerCreate(/* A text name, purely to help
                                   debugging. */
                                     "SensorTimer",
                                     /* The timer period, in this case
                                     1000ms (1s). */
                                     SENSOR_TIMER_PERIOD_MS,
                                     /* This is a periodic timer, so
                                     xAutoReload is set to pdTRUE. */
                                     pdTRUE,
                                     /* The ID is not used, so can be set
                                     to anything. */
                                     (void *)0,
                                     /* The callback function */
                                     vTimerCallback_SensorTimer);
                                if(xSensorTimer==NULL) {
                                    for(;;); /*failure! */
                                }

xSUS_BUS_TIMEOUT_Timer = xTimerCreate(/* A text name, purely to help
                                   debugging. */
                                     "SUS_BUS_TIMEOUT_Timer",
                                     /* The timer period, in this case
                                     1000ms (1s). */
                                     SUS_BUS_TIMEOUT_PERIOD_MS,
                                     /* This is a periodic timer, so
                                     xAutoReload is set to pdTRUE. */
                                     pdFALSE,
                                     /* The ID is not used, so can be set
                                     to anything. */
                                     (void *)1,
                                     /* The callback function */
                                     vTimerCallback_SUSBUSTIMEOUT);
                                if(xSUS_BUS_TIMEOUT_Timer==NULL) {
                                    for(;;); /*failure! */
                                }

    xTaskCreate(/* The function that implements the task. */
                prvQueueModuleTask,
                /* Text name for the task, just to help debugging. */
                "Module",
                /* The size (in words) of the stack that should be created
                for the task. */
                configMINIMAL_STACK_SIZE + 166,
                /* A parameter that can be passed into the task.  Not used
                in this simple demo. */
                NULL,
                /* The priority to assign to the task.  tskIDLE_PRIORITY
                (which is 0) is the lowest priority.  configMAX_PRIORITIES - 1
                is the highest priority. */
                mainQUEUE_MODULE_TASK_PRIORITY,
                /* Used to obtain a handle to the created task.  Not used in
                this simple demo, so set to NULL. */
                NULL);

    /* Start the tasks and timers running. */
    vTaskStartScheduler();

    /* The program should never enter this while loop */
    while(1)
    {
        ;
    }
}

static void vTimerCallback_SensorTimer (xTimerHandle pxTimer)
{
    ReadTemperature();
    ADCMeasurement();
}

static void vTimerCallback_SUSBUSTIMEOUT (xTimerHandle pxTimer)
{
   //Reset the communication state back to the header state
}

【问题讨论】:

    标签: timer freertos nxp-microcontroller


    【解决方案1】:

    不确定您所说的“收到错误 taskSCHEDULER_RUNNING”是什么意思。您何时以及如何收到该错误?

    关于计时器的创建;您是否为 FreeRTOS 分配了足够的堆(在您的 FreeRTOSConfig.h 中)?

    【讨论】:

    • 在启动第二个计时器时,我从函数中收到了这个错误:if(xSUS_BUS_TIMEOUT_Timer==NULL) { for(;;); /*失败! */ 我按照本教程进行操作:mcuoneclipse.com/2018/05/27/… 堆大小为 10240。如果您的意思是这个 #define configTOTAL_HEAP_SIZE ((size_t)(10240)) configAPPLICATION_ALLOCATED_HEAP 为 0。
    • 你能看一下xFreeBytesRemaining 变量吗?它是一个 FreeRTOS 变量,显示堆中剩余的字节数。计时器的大小约为。 48 字节。
    猜你喜欢
    • 2018-05-27
    • 1970-01-01
    • 1970-01-01
    • 2017-03-12
    • 1970-01-01
    • 2016-01-02
    • 1970-01-01
    • 2020-11-22
    • 2019-07-07
    相关资源
    最近更新 更多