[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-libc-dev] new to avr-libc programming: interrupt handling
From: |
Joerg Wunsch |
Subject: |
Re: [avr-libc-dev] new to avr-libc programming: interrupt handling |
Date: |
Mon, 3 Mar 2003 11:40:48 +0100 |
User-agent: |
Mutt/1.2.5i |
As address@hidden wrote:
> how it looks:
> outp( 0x37, TCCR0 ); /* set TCCR timer/counter control register to
> prescaled
> clock of 1/256 and sets OCF0 on compare match*/
Hmm, better use
TCCR0 = 0x37;
now. That's the prefered syntax. If i were you, i'd rather use
TCCR0 = _BV(COM00) | _BV(COM01) | _BV(CS02) | _BV(CS01);
That makes it more obvious that your description didn't match your hex
values :) (clk/256 vs. clk/1024).
> outp( 0x2, TIFR ); /* OCF is cleared when executing the interupt handlig
> vector */
That's not necessary. The flag is cleared by hardware anyway.
> outp( 0x2, TIMSK ); /* OCIE is set -> otput compare interrupt enabled */
>
>
> sei(); /* is this right? do I need more method calls to let the program
> listen to an interrupt? */
That's OK.
> //interrupt method definition:
> interrupt [TIM0_COMP] void time_out( void ) { }
RTFM. :-) You can find TFM here:
http://savannah.nongnu.org/download/avr-libc/doc/avr-libc-user-manual/
More specifically:
http://savannah.nongnu.org/download/avr-libc/doc/avr-libc-user-manual/group__avr__interrupts.html
So in your case
SIGNAL(SIG_OVERFLOW0)
{
...
}
--
J"org Wunsch Unix support engineer
address@hidden http://www.interface-systems.de/~j/