Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

Simple example program

Posted by nagaraju on August 6, 2013
Hi ,

I have created the two tasks of equal ptiority like below.

xTaskCreate( vTask2, "Task 2", 1000, NULL, 1, NULL );
xTaskCreate( vTask1, "Task 1", 1000, NULL, 1, NULL );

In my task1 defination just i am printing on to the console " i am in task1" and in my task2 defination i am printing on the console " i am in task2."

in my main i have created the two tasks and called the vTaskStartScheduler();

Then my console is showing the only "i am in task1" message continuously.I have never seen the message "i am in Task2."

Please suggest me why this is happening.

I am working on stellaris DK-LM3s9b96 board.

Thanks,
Nagaraju

RE: Simple example program

Posted by Richard on August 6, 2013
My first guess would be that printing to the console is using some kind of semi hosting or other mechanism that is taking a long time and generally messing up with the functioning of the MCU - especially if you are printing to the console continuously without the task ever going into the blocked state.

I would suggest removing the console print functions are replacing them with a simple incrementing variable. For example:

volatile unsigned long x = 0, y = 0;

void vTask1( void * pvParameters )
{
for( ;; )
{
x++;
}
}

void vTask1( void * pvParameters )
{
for( ;; )
{
y++;
}
}


Create both tasks, let the application run for a few seconds, then stop the application on the debugger and inspect x and y - as you are creating both tasks at the same priority both variables should have incremented.

Note if you create the tasks at different priorities then only the higher priority task will run because the code above does not allow either task to enter the Blocked state.

Regards.

RE: Simple example program

Posted by nagaraju on August 6, 2013
I am compiling my FreeRTOS and application with gcc.i don't have flexibility to debug the application through the IDE.
I tried the below .

1.i have assigned same priority to the both the tasks .
i observed the message on the console for the forst created task only.

2.I commented the printf statement in the first created task, then i have not observed the console message for the second creted task.

3.I changed the priority of the second created task to high then i am able to see the console message for the created high priority task.

Please suggest or help me how can i ensure that both tasks are running simultaneously.

Thanks,
Nagaraj


RE: Simple example program

Posted by Richard on August 6, 2013
If you don't have a debugger then it will be difficult to support you, but the next thing I would suggest is checking that the tick interrupt is executing. If you don't have a debugger then you can create a tick hook function and have that toggle a GPIO pin, then check the pin is toggling at the expected frequency on a scope.

Regards.

RE: Simple example program

Posted by nagaraju on August 6, 2013
Able to see the console messages by placing the below API in both the tasks.

vTaskDelay( 250 / portTICK_RATE_MS );

Regards,


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner