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

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) 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