I'm trying to use a microsecond delay function prior to starting the FreeRTOS schedular on the S32K344. At first, I was thinking of using the Osif System Timer, but that seems to be disabled when the FreeRTOS OS is enabled (OsIf_Timer_System_GetCounter() always returns 0). I cannot use xTaskGetTickCount() since this is only valid after vTaskStartScheduler has been called, which in my code has not yet called. I did try using simple assembly language loop but the count value necessary tends to be a very large since the instruction execution is in nanoseconds and I need around 500uS.
So, is there an alternative to use where I can get the system tick count? Or, would it be easier to use the STM and create a loop with the comparator? I couldn't not find any S32K3xx S32DS projects that had any timer examples. I thought about using the Osif Custom Timer, but not sure how to utilize it since there are again, no examples for it. Or is this disable also when using the FreeRTOS OS?
Thanks in advance.
Hi,
yes, that's correct, those FreeRTOS functions and SDK drivers which use OS services cannot be called before starting the scheduler.
The easiest option I can see is to create delay loop(s) even if the count value is very high.
Or there's PIT example in RTD in Gpt folder.
Regards,
Lukas