avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] new to avr-libc programming: interrupt handling


From: pboenzli
Subject: [avr-libc-dev] new to avr-libc programming: interrupt handling
Date: Mon, 3 Mar 2003 11:16:07 +0100
User-agent: Internet Messaging Program (IMP) 3.1


Hi folks.

I just began programming on a ATMega128. Now I've got a problem ;) and I can't 
find a solution on myself, so brave men and women of this email list, please 
stand me by :)

what I use: avr-libc

what I tried: I wanted to register an interrupt handler for a timer/counter OCF 
(on compare flag), so: if the counter TCNT0 got the same value as the output 
compare register (OCR) OCF is set.

how it looks:
  outp( 0x37, TCCR0 ); /* set TCCR timer/counter control register to prescaled 
clock of 1/256 and sets OCF0 on compare match*/
  
  outp( 0x21c8, OCR0 ); /* set the OCR output compare register to "one minute" 
*/

  outp( 0x2, TIFR ); /* OCF is cleared when executing the interupt handlig 
vector */

  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? */


I'm not realy sure if I have initialized the counter right, so if you see a 
problem or did it better or more elegant, let me know.
Now I want my program to jump to a method time_out() when the counter fires an 
interrupt. In other examples, they did something like:

//interrupt method definition:
interrupt [TIM0_COMP] void time_out( void ) { }

but in my case, <iom128.h> does not contain a constant TIM0_COMP. since 
TIM0_COMP is nothing else than 12, i replaced them and...nothing worked. 
compiler said: "syntax error before void". I just want to know how I can 
execute a method when an interrupt is fired (I know, writing in the interrupt 
vector...but how?)

I don't now how I should go on! So if someone of you professionals knows how to 
do this, please let me know! And please not theoretical, its an implementation 
problem, I don't know how to tell it to the avr...

thanks for any help!
greetings Patrick





reply via email to

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