[Top][All Lists]

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

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

From: Eric Pasquier
Subject: Re: [avr-gcc-list] 32-bits time
Date: Thu, 13 Oct 2005 09:26:03 +0200

Not too bad !
In fact, this code is the best one as the overflow can occur AFTER the read of TCNT1, so incrementing "upper" is a bad solution.

Thanks a lot to every one.

----- Original Message ----- From: "Galen Seitz" <address@hidden>
To: <address@hidden>; "Eric Pasquier" <address@hidden>
Sent: Thursday, October 13, 2005 1:22 AM
Subject: Re: [avr-gcc-list] 32-bits time

What about something like this:

uint16_t upper, lower;
uint32_t time;

lower = TCNT1;
upper = hiword_time;
// Force lower bytes to max value if a timer overflow interrupt is pending.
// This assumes the latency on the overflow flag is less than the time it
// takes to execute the previous two statements.
if (timer1 overflow)
  lower = 0xffff;
time = upper<<16 | lower;


reply via email to

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