0

硬件:NXP 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
}
4

1 回答 1

0

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

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

于 2018-08-28T06:42:55.643 回答