Quality RTOS & Embedded Software

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


Loading

while (1) loop in the main function vs. FreeRTOS

Posted by tahirnaseer on November 11, 2014

Hi,

I am trying to implement FreeRTOS on controller with specific API calls. In the bare controller example, there are a few commands which are used at the beginning and end of while(1) loop in main as follows:

void main (void) { ... while(1) command1();

/* your application code here */

command2();

}

It is mandatory to used command1 and command2. Where in FreeRTOS should I write calls to command1 and command2 functions? }


while (1) loop in the main function vs. FreeRTOS

Posted by rtel on November 11, 2014

I'm not sure I understand your question. Let me state it back to see if I have it right.

Currently you have a non-RTOS application that is structured as follows:


while( 1 )
{
    /* Must be called before application code. */
    command1();

    /* Application code goes here. */


    /* Must be called after application code. */
    command2();
}

now you want to implement the same thing but using the RTOS.

If so then the first thing to say is you could just create that function as a task and have it run. If it does not block and you have other tasks running it would have to be a low priority though.

Other than that any answer would depend on the what command1() and command2() were, what is their purpose, what are their processing requirements, and what relation (if any) do they have to the application code.

For example, does command2() use a value calculated by the application code, in which case it must be executed exactly once after each execution of the application code.

Or alternatively is command2() completely unrelated to the application code but needs to be called either periodically or as fast as possible.

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