How to obtain delay in the order of 50us on TMDX570LC43HDK with FreeRtos

etantonio wrote on Tuesday, November 21, 2017:

Hy,
I would like to obtain delay in the order of 50us on a FreeRTOS having a tick of 1ms (1000Hz) on TMDX570LC43HDK, I’m almost sure that this is a non sense,
so the solution could be a tick for example of 10us, is it a realistic solution to this kind of problem?
Thanks
Antonio

tlafleur wrote on Tuesday, November 21, 2017:

No, leave tick at 1 to 100ms and use a timer on interrupts for your
delay. If it happen infrequently, you might be able to use a delay loop.
All depends on your system design.

Haveing a tick at 50 or 10us would use a lot of CPU resources in the
FreeRTOS scheduler doing nothing very useful.

On Tue, Nov 21, 2017 at 9:39 AM Etantonio etantonio@users.sf.net wrote:

Hy,
I would like to obtain delay in the order of 50us on a FreeRTOS having a
tick of 1ms (1000Hz) on TMDX570LC43HDK, I’m almost sure that this is a non
sense,
so the solution could be a tick for example of 10us, is it a realistic
solution to this kind of problem?
Thanks
Antonio

How to obtain delay in the order of 50us on TMDX570LC43HDK with FreeRtos
https://sourceforge.net/p/freertos/discussion/382005/thread/056332df/?limit=25#cd8e

Sent from sourceforge.net because you indicated interest in
https://sourceforge.net/p/freertos/discussion/382005/

To unsubscribe from further messages, please visit
https://sourceforge.net/auth/subscriptions/

~~ _/) _/) _/) ``` _/) ~~

Tom Lafleur

heinbali01 wrote on Tuesday, November 21, 2017:

Antonio, in my opinion: when you need a delay of more that a ms, you could have the task sleep by calling e.g. vTaskDelay().

When you want to wait for 50 uS, you can go either of two ways:

  • Set-up a timer-counter that you can poll and wait 50 uS in a loop.
  • Write a loop that has a predictable speed of execution.

Take care with the latter, when you change the optimisation level of the compiler, a loop could be implemented differently, or even not be compiled at all.
One solution to this is to write the loop as assembler code.

Here is an example from Atmel:

void portable_delay_cycles(unsigned long n)
{
    UNUSED(n);
    /* n is passed in the register r0 */
    asm volatile (
        "loop: DMB	\n"
        "SUBS R0, R0, #1  \n"
        "BNE.N loop         "
    );
}