硬件: 恩智浦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
}
答案 0 :(得分:0)
不确定“将错误taskSCHEDULER_RUNNING退回”是什么意思。您何时,如何获得该错误?
关于计时器的创建;您是否为FreeRTOS分配了足够的堆(在FreeRTOSConfig.h中)?