Timer FreeRTOS软件计时器(taskSCHEDULER\u正在运行)故障

Timer FreeRTOS软件计时器(taskSCHEDULER\u正在运行)故障,timer,freertos,nxp-microcontroller,Timer,Freertos,Nxp Microcontroller,硬件: NXP M4 MKE14 软件: MCUXpresso 10.1.1 一个软件定时器的实现非常顺利。当启动第二个定时器时,微控制器不再响应。我返回错误“taskSCHEDULER\u正在运行”。但如果这不运行,系统就什么也做不了 我实现了计时器和一项任务,如下所示: /* Create the queue used by the queue send and queue receive tasks. */ xQueue = xQueueCreate(/* The n

硬件: NXP M4 MKE14

软件: MCUXpresso 10.1.1

一个软件定时器的实现非常顺利。当启动第二个定时器时,微控制器不再响应。我返回错误“taskSCHEDULER\u正在运行”。但如果这不运行,系统就什么也做不了

我实现了计时器和一项任务,如下所示:

   /* 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
}
不确定您所说的“让taskSCHEDULER\u运行时出错”是什么意思。你是什么时候和怎样得到这个错误的


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

当我用:if(xSUS_BUS_TIMEOUT_timer==NULL){for(;);/*failure!*/启动第二个计时器时,我从函数中得到了这个错误。我遵循了这个教程:堆大小是10240。如果你的意思是#定义configTOTAL_Heap_size((size_t)(10240))configAPPLICATION_ALLOCATED_堆为0。您是否可以查看
xFreeBytesRemaining
变量?它是一个FreeRTOS变量,显示堆中剩余的字节数。计时器的大小约为48字节。