Quality RTOS & Embedded Software

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


vTaskDelay for 1uS, possible?

Posted by Willem on December 3, 2008
First of all, thanks everyone for the response so far. You really helped me out!

But again, i have another question. I managed to get USB HID working under FreeRtos. However, during enumeration some USB hosts require a (small) response every 100uS.

I tried to increase the tick rate, but when set the value to 10.000, the whole OS stopped working. Apparently the OS is consuming too much CPU now.

What is the best way to solve this problem? I`m thinking about using an external timer interrupt every 100uS. But i was wondering if there are more/better ways to do.

RE: vTaskDelay for 1uS, possible?

Posted by MEdwards on December 3, 2008
I don't know anything in USB that requires this resolution. But if you really need to do that use a hardware timer.

RE: vTaskDelay for 1uS, possible?

Posted by Willem on December 4, 2008
Well, actually at 1mS refresh rate (using the delayUntil) gives me a message in windows that the USB device cannot be started (code 10).

When i put the function in a continuous loop, without delay calls, then it works correctly. But then off course the OS gets stalled because the USB task consumes all of the processing power.

The strange thing is that with the 1mS delayUntil, the USB does work correctly on my notebook. But not on my PC.

Anyway, I`m thinking to use the USB on board interrupts instead of a polling loop. I think that should work.

Thanks for the reply.

RE: vTaskDelay for 1uS, possible?

Posted by dave m on December 10, 2008
Delays on the order of microseconds almost certainly have to be done with either a hardware timer (and you just monitor the count value) or with a timed sequence of instructions (like NOPs). But for USB work (and I'm just getting to the "oh, I see" stage with that) you really have to use interrupts. As you've discovered, it's very timing-sensitive, but if you're on the device side, the timing is pretty much not up to you. The reason to use an RTOS is so you can do something else while you're waiting for the host to demand that you do the next thing, within the next X microseconds. You can poll, but you're wasting a lot of time.

For very initial development, I had fair results by calling the ISR in a tight loop from an ordinary task. However, this risks having things work (or not) because of random lucky (or unlucky) timing coincidences. For example, I was able to get enumeration to work this way, but only if I had certain debugging messages turned on. The problem was, with the messages, I was pausing long enough for a STATUS phase to complete, but without, I was doing the next thing too soon. The correct solution is to key off the STATUS-PHASE-COMPLETE interrupt.

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

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

Latest News

FreeRTOS v10.2.1 is available for immediate download. MIT licensed, includes 64-bit RISC-V, NXP Cortex-M33 demo, Nuvoton Cortex-M23 demo & STM32H745 dual core (AMP) demo.

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

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


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

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

Xilinx Microblaze and Zynq partner