FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [June 2009 Threads] 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
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|