[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Re: thread hijack
From: |
Daniel O'Connor |
Subject: |
[avr-gcc-list] Re: thread hijack |
Date: |
Mon, 5 Jan 2009 23:40:34 +1030 |
User-agent: |
KMail/1.9.10 |
On Monday 05 January 2009 22:36:31 prabu wrote:
> Hello Every Body
>
> Can Anyone help me to clear my Timer Issue.
> Am very new to this ....
Please don't hijack a thread with a totally unrelated conversation it makes
reading it rather annoying. (ie don't click on a random email and hit reply,
your mail client keeps headers in place to track threads in this case).
Always start a new email and cut & paste the list email address into the To:
field instead.
Re: your problem, I strongly suggest you use symbolic names, it makes it MUCH
easier to see what you are doing, eg..
volatile static time_t now;
void
setup(void) {
...
/* Setup timer */
/* 16Mhz / 1024 = 15625 Hz / 125 = 125 Hz = IRQ every 8 ms */
/* CTC mode, no output on pin, Divide clock by 1024 */
TCCR2 = _BV(WGM21)| _BV(CS22) | _BV(CS21) | _BV(CS20);
/* Compare with ... */
OCR2 = 125;
/* Enable interrupt for match on A */
TIMSK = _BV(OCIE2);
now.sec = 0;
now.usec = 0;
...
}
...
ISR(TIMER2_COMP_vect) {
wdt_reset();
now.usec += 8000; /* 1000000 * 1 / F_CPU / 1024 / 125 */
while (now.usec > 1000000) {
now.usec -= 1000000;
now.sec++;
}
}
--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
-- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
signature.asc
Description: This is a digitally signed message part.