How to implement uS delay?
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.
How to implement uS delay?
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.
How to implement uS delay?
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 [url]https://sourceforge.net/forum/message.php?msg_id=4901759[/url]
How to implement uS delay?
Many thanks, MEdwards and incrediball.
I got so many ideas from your articles.
Thanks again :)
How to implement uS delay?
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