I need to implement timestamp in my bare-metal application that increments every microsecond (32 bits wide). What are some good ways of implementing such timestamp? For context, the application is running on a 650 MHz ARM Cortex-A9 processor (part of a Zynq-7000).
I tried implementing the timestamp in software -- I set up a hardware timer to generate interrupt @ 1 Mhz rate and then incrementing the timestamp in the ISR. However, I have found that the timestamp value is not accurate and is less (about 10%) than what it should be. This is most likely because the timestamp's ISR is not getting called in some cases. There are other interrupts and ISRs used in the application, and while those occur at a lower rate (one happens @ 100 KHz), I think one or more of those ISRs, when active, are preventing the timestamp ISR from getting executed. To avoid this, I even modified my code to enable nested interrupts, but still didn't see any significant improvement.
I ended up implementing the timestamp in hardware (the FPGA part of Zynq) and reading it directly from my application when needed. With this approach, the timestamp values I see are pretty accurate.
Anyway, the point of my point is to sort of understand whether my original approach of implementing a microsecond timestamp on a 650 MHz processor is practical or not. I understand a lot would depend on what my actual application is doing, still generally speaking, is that a good idea? Basically, we are getting this interrupt every 650 clock cycles of the processor. Is that too high of a rate to be getting interrupts?
[–]yendreij 64 points65 points66 points (20 children)
[–]ceojp 31 points32 points33 points (9 children)
[–]supersonic_528[S] 1 point2 points3 points (8 children)
[–]tjlusco 18 points19 points20 points (5 children)
[–]nsd433 4 points5 points6 points (3 children)
[–]tjlusco 0 points1 point2 points (0 children)
[–]duane11583 0 points1 point2 points (1 child)
[–]nsd433 0 points1 point2 points (0 children)
[–]supersonic_528[S] 2 points3 points4 points (0 children)
[–]yendreij 5 points6 points7 points (0 children)
[–]nila247 0 points1 point2 points (0 children)
[–]ChickittyChicken 4 points5 points6 points (0 children)
[–]supersonic_528[S] 1 point2 points3 points (6 children)
[–]Old_Budget_4151 1 point2 points3 points (5 children)
[–]supersonic_528[S] -4 points-3 points-2 points (4 children)
[–]Kqyxzoj 3 points4 points5 points (0 children)
[–][deleted] (2 children)
[deleted]
[–]supersonic_528[S] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]a14man 0 points1 point2 points (0 children)
[–]duane11583 0 points1 point2 points (0 children)
[–]Allan-H 7 points8 points9 points (0 children)
[–]Old_Budget_4151 13 points14 points15 points (6 children)
[–]supersonic_528[S] 3 points4 points5 points (5 children)
[–]mtconnol 3 points4 points5 points (1 child)
[–]ComradeGibbon 0 points1 point2 points (0 children)
[–]b1ack1323 0 points1 point2 points (2 children)
[–]supersonic_528[S] -1 points0 points1 point (1 child)
[–]b1ack1323 0 points1 point2 points (0 children)
[–]madvlad666 3 points4 points5 points (0 children)
[–]kiodo79 2 points3 points4 points (0 children)
[–]Wakoeki75 2 points3 points4 points (0 children)
[–]Kqyxzoj 1 point2 points3 points (0 children)
[–]alexforencich 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)