I recently encountered a problem, that I am having difficulty solving. Can any please shed some light on this topic?
There is a hardware timer counter, which counts from 0 to 59. When it rollovers from 59 to 0 it will trigger an interrupt handler ISR1.
TS=0;
ISR1( ) ( will increase TS by 1). { #### A TS++; }
There is another interrupt handler ISR2, which can happen at anytime and has a higher priority than ISR1. ISR2 will want to get the exact time from the TS value and also the value of the hardware counter.
ISR2( ) {
... GetTime(); ...
}What is a good way to implement this?
If ISR2 preempts ISR1 at instruction #### A, will it be able to get the correct values of TS and the hardware counter?
For example: If the hardware counter is at 0 and TS should be at 100, how do I ensure that I retrieve hardware counter 0 and TS=100 and not hardware counter 0 and TS=99.
Thanks!