FreeRTOS tick on ImX8

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FreeRTOS tick on ImX8

1,640 Views
luca_corna
Contributor I

Hallo,

is it correct saying that FreeRTOS port for Imx8 - m4 core does not support scheduler evaluation frequency higher than 1kHz?

0 Kudos
3 Replies

1,292 Views
BlackNight
NXP Employee
NXP Employee

By default, the maximum FreeRTOS tick rate is 1 kHz (1 ms). But you can go to a higher frequency. For this you have to provide your own version of the pdMS_TO_TICKS() macro in FreeRTOSconfig.h

I hope this helps,

Erich

0 Kudos

1,292 Views
luca_corna
Contributor I

So if I want that the scheduler re-evaluate every 100us I have simply to  add:

#define configTICK_RATE_HZ 10000

#define pdMS_TO_TICK ( timeInUs ) ( timeInUs * configTICK_RATE_HZ  /1000000 )

right? in this case ms_to_tick is actually us_to_tick

0 Kudos

1,292 Views
BlackNight
NXP Employee
NXP Employee

Older FreeRTOS ports used something like this:

vTaskDelay(50/portTICK_RATE_MS);

Which is a problem if the tick rate >1 kHz.

That's why newer FreeRTOS ports (I think from 9.0.0 on) use the pdMS_TO_TICKS() macro:

vTaskDelay(pdMS_TO_TICKS(50));

which is defined as

/* Converts a time in milliseconds to a time in ticks.  This macro can be
overridden by a macro of the same name defined in FreeRTOSConfig.h in case the
definition here is not suitable for your application. */
#ifndef pdMS_TO_TICKS
 #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) )
#endif

in projdefs.h

So as long as you are using pdMS_TO_TICKS and not portTICK_RATE_MS you are fine.

I hope this helps,

Erich

0 Kudos