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


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