Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists