Quality RTOS & Embedded Software

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




Loading

How can i use the same delay before and after starting a thread

Posted by cca1234 on July 28, 2015

This may be a very stupid question but i am very new to RTOS and i haven't been able to find where this is addressed. i have a function that i would like to be able to call either in the initialization before any threads are actually running or from a running thread (i.e., in the init section of main before the ostask scheduler starts as well as in a thread after the scheduler is running). HAL_Delay won't work properly after the thread starts and osDelay doesn't seem to work before the thread and scheduler starts. is there a way to have a delay in a function so that function can be used regardless of where it is used?

for the moment i am just playing with the keil examples,e.g., FreeRTOS thread creation and moving delays around and trying different delays on an eval board. so i am stuck right out of the gates!

thanks


How can i use the same delay before and after starting a thread

Posted by rtel on July 28, 2015

Neither HAL_Delay or osDelay are FreeRTOS functions and I have no idea what they do, so I cannot comment on them.

After the scheduler has started you can use vTaskDelay() or vTaskDelayUntil() - but they cannot be used before the scheduler starts.

You do do something like this:

if( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED )
{
    MyDelayFunction(); /* whatever that is */
}
else
{
    vTaskDelay();
}

How can i use the same delay before and after starting a thread

Posted by cca1234 on July 28, 2015

Thank you, this confirms my understanding (as limited as that may be at this point). The HAL_Delay is part of the hardware abstraction layer for our processor (STM32 à la Keil) and the osDelay is part of the CMSIS library and probably others.

This is off-topic, but at this point we are trying to make somewhat of an informed decision between Keil RTX and OpenRTOS so if there is any sort of comparison documentation that exists it would be appreciated


How can i use the same delay before and after starting a thread

Posted by davedoors on July 29, 2015

if there is any sort of comparison documentation that exists it would be appreciated

They are both small OS's solving the same problem. A lot more people use FreeRTOS, probably because its API is easier to use and you can use it with any compiler.


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




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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