Re: Interrupt Question
Date: 02/25/05

Date: 24 Feb 2005 20:27:05 -0800

Adam Caruso wrote:
> 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
> 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
> that I retrieve hardware counter 0 and TS=100 and not hardware
counter 0 and
> TS=99.
> Thanks!

If possible my approach would be to move the TS increamenting step to a
task.I would make ISR1 to release a semaphore and make the task
increamenting the value of TS to pend for it.At the task what ever I am
increamenting,I will make another copy of it.Use that copy to read the
updated value from another ISR.
As far Aryas reply,masking may or maynot be involved in the OPs case.If
masking is enabled then theres no question of ISR2 preempting ISR1.So
from what he describes it seems that masking is not involved in his