[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] 32-bits time

From: Dmitry K.
Subject: Re: [avr-gcc-list] 32-bits time
Date: Thu, 13 Oct 2005 08:50:45 +1100
User-agent: KMail/1.5

On Thursday 13 October 2005 07:22, Eric Pasquier wrote:
> Dear All,
> I have implemented a 32-bits time information using the code below.
> Timer1 is incremented using internal clock, prescaler=1;
> SIG_OVERFLOW interrupt is used to increment a variable used to complete
> the 16-bits of Timer1.
> In fact, the code below have the following problem: if the call is made
> exactly when the counter overflow, TCNT1 (tempL) is equal to zero, but
> hiword_time (tempH) is pending to be incremented, leading to an error
> (time is returning in the past).
> Does anybody has a solution ?

1:      lds     r22, TCNT1L
        lds     r23, TCNT1H
        lds     r24, hiword_time
        lds     r25, hiword_time + 1
        lds     r0, TCNT1L
        cp      r0, r22
        brne    1b

This code work if you will use it only with flag 'SREG.I' setting.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]