avr-gcc-list
[Top][All Lists]
Advanced

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

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


From: Galen Seitz
Subject: Re: [avr-gcc-list] 32-bits time
Date: Wed, 12 Oct 2005 16:22:59 -0700

What about something like this:

uint16_t upper, lower;
uint32_t time;

cli();
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;
sei();


galen




reply via email to

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