1
votes

I'm using Freescale FRDM-KL25Z board with Codewarrior 10.6 software. My goal is to make small program in FreeRTOS, which reads voltage from thermistor by analog/digital converter (0-3,3v) and depends on this voltage I'd like turn on/off led diodes. It worked for me till the moment, when I added second task and queues. I'm thinking that problem might be in stack size, but I have no idea how to configure it.

Code is below:

xQueueHandle queue_led;


void TaskLed (void *p)

{

uint16_t temp_val;

    xQueueReceive(queue_led, &temp_val, 1);  

    if (temp_val<60000)
    {
        LED_1_Neg();        
    }
}

void TaskTemp (void *p)
{

    uint16_t temp_val;

    (void)AD1_Measure(TRUE);
    (void)AD1_GetValue16(&temp_val);

    xQueueSendToBack(queue_led, &temp_val, 1000);

    FRTOS1_vTaskDelay(1000);
}

Code in main():

  xTaskCreate(TaskLed, (signed char *)"tl", 200, NULL, 1, NULL);
  xTaskCreate(TaskTemp, (signed char *)"tt", 200, NULL, 1, NULL);
  vTaskStartScheduler();
  return(0);
2

2 Answers

2
votes

A task is normally a continuous thread of execution - that is - it is implemented as an infinite loop that runs forever. It is very rare for a task to exit its loop - and in FreeRTOS you cannot run off the bottom of a function that implements a task without deleting the task (in more recent versions of FreeRTOS you will trigger an assert if you try). Therefore the functions that implement your tasks are not valid.

FreeRTOS has excellent documentation (and an excellent support forum, for that matter, which would be a more appropriate place to post this question). You can see how a task should be written here: http://www.freertos.org/implementing-a-FreeRTOS-task.html

In the code you post I can't see that you are creating the queue that you are trying to use. That is also documented on the FreeRTOS.org website, and the download has hundreds of examples of how to do it.

If it were a stack issue then Google would show you to go here: http://www.freertos.org/Stacks-and-stack-overflow-checking.html

0
votes

You should create the queue and then check that the returned value is not zero (the queue is successfully created)