cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 RTC timestampping

khalid
Associate II
Posted on July 25, 2013 at 11:06

Hi All,

I wanted to timestamp external events with a resolution of 10's of milliseconds. How can I do that in STM32F407 ?

Best Regards,

K

#rtc
4 REPLIES 4
jpeacock2399
Associate II
Posted on July 25, 2013 at 15:54

On the F4 you can look at the sub-second timestamp register to get the RTCCLK prescaler value.  However, you are limited to the base 32.768Khz base frequency of the RTC, assuming an LSE oscillator.  You can derive an approximate 10ms count from the RTC_TSSSR register.

  Jack Peacock
Posted on July 25, 2013 at 16:39

The RTC is supposed to be able to take a 1 MHz external source.

Outside the RTC, there are several other method to get sub milli-second accuracy.

For sub-millisecond accuracy you could use an EXTI interrupt for a software solution, a 32-bit TIM in input capture mode would also get a good timebase measurement in the sub micro-second range.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
khalid
Associate II
Posted on July 29, 2013 at 15:27

Thanks for your reply. What is the sub-second resolution of RTC? Also, just to let you know a bit more, I am planning to record multiple events on GPIOs in time as hh:mm:ss.mss

where,

hh- > hours, mm-mins, ss-> seconds, mss-> miliseconds.

My RTC time is updated with the help of an NTP server. 

An suggestions or ideas? Is using RTC the best idea to proceed ? Is it better to use some other timers ?

Thanks in advance,

Posted on July 29, 2013 at 15:54

But that's a very human centric decoding, the hardware would be more effective representing time otherwise.

The Ethernet unit has a 64-bit clock reference as part of the PTP/IEEE-1588 implementation. There is also a 32-bit core cycle counter. You have some 32-bit TIM units, with 16-bit prescalers, these you run easily with a 1us or 1ms timebase.

Depends I suppose on the accuracy of your relative clock sources. If I clocked HSE with a TCXO or OCXO I surely wouldn't bother with the RTC, with a cheap watch crystal, beyond the ability to sustain time in a low power state.

Multiple clock sources will all drift with respect to each other, for a single synchronous source I'd be looking at a 25/50 MHz one I could use across the system, with a single drift/bias problem to solve.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..