Hi Guillaume,
A couple of posts that I think answer your question.
Bug report: _time_delay() not the good delay.
elapsed time in nanoseconds
Cut-n-Paste from second post:
Every Kinetis device uses the SysTick timer as its master clock source. Different Kinetis devices can be clocked at different frequencies. K70 @120 or 150MHz, K60 @100, etc… So the range is 50-150MHz depending on the device.
In MQX the SysTick timer is clocked at the core frequency.
Ex: Using the K70-120MHz as my example 120MHz has an 8.333 nanosecond/SysTick.
MQX calculates the SysTick timer count down value to generate an interrupt every 5ms.
Ex: 5ms/8.333nanoseconds = 600024 SysTicks.
When you are calling the timeget_nanoseconds() function in the PSP time.c file, it is grabbing the SysTick counter value and scaling it to return a value in nanoseconds since the last MQX Tick occurred.
This value is based off of hardware so it is real. But the resolution is based on the SysTick counting rate which ic equal to the process core frequency. Faster processor core frequency means better resolution.
The accuracy of the timeget_microseconds() function call is better than thetimeget_nanoseconds() function call since there are 120 SysTick clocks per microsecond.
With respect to SW1. I was just placing a breakpoint in the btn_kernel_isr() routine as a place to stop and then use IDE to inspect the variable window. Nothing more.
With respect to your code to get the TICKS from start of MQX I modified it to the following:
#if 1 //DES 1=test, 0=default code
{
MQX_TICK_STRUCT tickstruct;
uint32 ticknum[2];
timeget_elapsed_ticks(&tickstruct);
ticknum[0] = tickstruct.TICKS[0]; //DES lower 32-bits
ticknum[1] = tickstruct.TICKS[1]; //DES upper 32-bits
printf("\n ticknum64 = %u%u\n", ticknum[1], ticknum[0]); //DES 64-bit TICKS value.
}
#endif
Regards,
David