Quality RTOS & Embedded Software

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


Loading

How to implement uS delay?

Posted by Kevin Cho on June 1, 2009
Hi all,

Thanks for Open community.

I'm working on SAM7S64, FreeRTOS port.

This port configTICK_RATE_HZ is defined 1000.

vTaskDelay(1); --> 1 ms Delay. I checked it with oscilloscope.

But, I need to 500 or 100 us delay function.

Is it possible?

or How to increse configTICK_RATE_HZ to 2000.

thanks.



RE: How to implement uS delay?

Posted by MEdwards on June 1, 2009
If you set configTICK_RATE_HZ faster than 1000 then the constant portTICK_RATE_MS will be zero and the demo tasks will not run and most likely crash. This is just the demo tasks and not the kernel.

If you are not using the demo tasks then you can set the tick faster but this will result in inefficient code. 1000Hz is already too fast really.

You can use another timer to generate an interrupt at your required frequency, then perform the processing in the interrupt handler. Alternatively you can use the interrupt handler to wake a very high priority task and perform the processing in that. The SAM7 port does not use interrupt nesting though unless you modify the code. You can probably use the FIQ interrupt more easily with no or smaller changes.

RE: How to implement uS delay?

Posted by incrediball on June 4, 2009
Some changes are needed to use FIQ:

1. Create a stack for the FIQ.

2. Set up the FIQ vector. This is often coded as an endless loop or something equally pointless.

3. If interrupt latency is an issue (in my case it was), stop FreeRTOS from disabling the FIQ in portDISABLE_INTERRUPTS, vPortDisableInterruptsFromThumb and vPortEnterCritical.

The FIQ interrupt handler must not interact with FreeRTOS. If it needs to communicate with the rest of the system, it can raise a regular interrupt in software (use AT91F_AIC_Trig).

I wrote about it last year under https://sourceforge.net/forum/message.php?msg_id=4901759

RE: How to implement uS delay?

Posted by Kevin Cho on June 4, 2009

Many thanks, MEdwards and incrediball.

I got so many ideas from your articles.

Thanks again :)

RE: How to implement uS delay?

Posted by Alain Mouette on June 5, 2009
I think that you have to separate that in two diferent problems:

1) a function to wait "at least 50us" is one thing. I have used it in many situations, you can just read a HW timer and wait. It is very usefull if you don't want to waist 1ms for each action, but longer times are not a problem.

2) a time of 50us plus/or/minus 1us is much more complex. Normaly that would run all from ISRs, with HW timers. Doing it with a RTOS would be much more difficult.

Alain Mouette


[ 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