Page 1 of 1

high precision system time

Posted: Tue May 19, 2015 8:36 am
by deadlyboy
hi every body

for creating a real time system i need to have system time which has microsecond precision.

i used halGetCounterValue() and halGetCounterFrequency(). but it will reset every 25 second.

my code is lke this :

Code: Select all

uint32_t tnow = getSystemTimeInMicroSecond();
while(true)
{
   
   if(getSystemTimeInMicroSecond() - tnow => 13333)
   {       tnow = getSystemTimeInMicroSecond();
      dojobOne();
   }
   if(getSystemTimeInMicroSecond() - tnow  >= 25555)
   {      tnow = getSystemTimeInMicroSecond();
      dojobTwo();
   }
   
}


so i cannot use chThdSleepMicrosecond().
chTimeNow() gives me a 1 millisecond precision.if i had a counter which counts every 168 ticks of micro (stm32f4-168mhz) i will have a system time in micro second.

is it possible to implement this ?? if yes how ??

Re: high precision system time

Posted: Tue May 19, 2015 9:15 am
by Giovanni
ChibiOS/RT 3.0 supports high resolution time in the kernel, you can have system tick with 1uS resolution.

You may also consider the GPT driver but only for delays.

Giovanni