EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

FreeRTOS help needed

Started by sAm May 6, 2011
Hi guys..
i am working on FreeRTOS kernel and stuck in creating my first task.. i am not sure that it is the right place to get help but i know for sure that u guys know much about FreeRTOS. i have modified the port of Microblaze to fit my architecture for AEMB. So basically my kernel now has no hardware setup and i want to kick my tasks using the cooperative mode..

so far i have already made sure that the stack is successfully allocated for my task by printing the return value of vTaskCreate macro and i activated the cooperative mode by setting configUSE_PREEMPTION to 0. but my problem now is, i can not see the output of my tasks..

my code is as follows:
void vTestTask1( void *pvParameters );
void vTestTask2( void *pvParameters );

int main (void)

{

portBASE_TYPE TReturn1, TReturn2;

portDISABLE_INTERRUPTS();

TReturn1 = xTaskCreate( vTestTask1, "T1", 1000, NULL, 1, NULL );
TReturn2 = xTaskCreate( vTestTask2, "T2", 1000, NULL, 1, NULL );

printf("\n\n alloc T0 = %d , alloc T1 = %d \n\n", TReturn1, TReturn2);

vTaskStartScheduler();

return 0;

}

void vTestTask1( void *pvParameters )

{

printf("Task 1 running\n");

taskYIELD();

}

void vTestTask2( void *pvParameters )

{

printf("Task 2 running\n");

taskYIELD();

}
Am i missing something ? Am i Doing something wrong ?
any suggestions and guidance are so much appreciated :)

Hi,

How do you know that printf is working?

Have you setup the UART for printf?
Just check if printf is working?
Regards
TVRPrasad

On Fri, May 6, 2011 at 8:57 PM, sAm wrote:

> Hi guys..
> i am working on FreeRTOS kernel and stuck in creating my first task.. i am
> not sure that it is the right place to get help but i know for sure that u
> guys know much about FreeRTOS. i have modified the port of Microblaze to fit
> my architecture for AEMB. So basically my kernel now has no hardware setup
> and i want to kick my tasks using the cooperative mode..
>
> so far i have already made sure that the stack is successfully allocated
> for my task by printing the return value of vTaskCreate macro and i
> activated the cooperative mode by setting configUSE_PREEMPTION to 0. but my
> problem now is, i can not see the output of my tasks..
>
> my code is as follows:
>
> void vTestTask1( void *pvParameters );
> void vTestTask2( void *pvParameters );
>
> int main (void)
>
> {
>
> portBASE_TYPE TReturn1, TReturn2;
>
> portDISABLE_INTERRUPTS();
>
> TReturn1 = xTaskCreate( vTestTask1, "T1", 1000, NULL, 1, NULL );
> TReturn2 = xTaskCreate( vTestTask2, "T2", 1000, NULL, 1, NULL );
>
> printf("\n\n alloc T0 = %d , alloc T1 = %d \n\n", TReturn1, TReturn2);
>
> vTaskStartScheduler();
>
> return 0;
>
> }
>
> void vTestTask1( void *pvParameters )
>
> {
>
> printf("Task 1 running\n");
>
> taskYIELD();
>
> }
>
> void vTestTask2( void *pvParameters )
>
> {
>
> printf("Task 2 running\n");
>
> taskYIELD();
>
> }
>
> Am i missing something ? Am i Doing something wrong ?
> any suggestions and guidance are so much appreciated :)
>
>
>
> > i am working on FreeRTOS kernel and stuck in creating my first task.. i am
> > not sure that it is the right place to get help

The FreeRTOS support forum would be the obvious place to get help.
> > but i know for sure that u
> > guys know much about FreeRTOS. i have modified the port of Microblaze to fit
> > my architecture for AEMB.

If you are using an AT91SAM, why did you start with a Microblaze port, rather than an AT91SAM port?



> > void vTestTask1( void *pvParameters )
> >
> > {
> >
> > printf("Task 1 running\n");
> >
> > taskYIELD();
> >
> > }
There are two things wrong there. First, you are using printf() without any mutual exclusion, so if two tasks call printf() at the same time there will be a big problem. Second, and most importantly, you should never run off the bottom of a task, that will definitely crash. If you want a task to run once, then end the task with vTaskDelete( NULL ); or better still, use a software timer and not a task. If you want the task to run repeatedly, then put it in an infinite loop.

Finally, depending on the compiler libraries, and other things, calling printf() will use a *lot* of stack. You may have stack overflow on top of all those other issues, but fix the first issues first, then use the stack overflow protection mechanisms to check the stack usage.

I would recommend investing in the FreeRTOS tutorial book.

Regards.


The 2024 Embedded Online Conference