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

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

[avr-gcc-list] External interrupt doesn't react


From: Bart Friederichs
Subject: [avr-gcc-list] External interrupt doesn't react
Date: Fri, 26 Mar 2004 13:31:00 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031208

<x-flowed>
Hi,

I have been experimenting with external interrupts, but I don't seem to get it working. I am using an ATmega16 and avr-gcc version 3.3.1

The code I use is as follows:

/*
* Timer test ground
*/

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>

SIGNAL (SIG_INTERRUPT0) {
 PORTA = 0x00;
}

int main() {
 /* init ports */
 DDRA = 0xFF;
 PORTA = 0x01;

 /* set INT0 to request interrupt at rising edge */
 enable_external_int(BV(INT0));

 /* enable interrupts */
 sei();

 for(;;);

 return 0;
}

It should light up a LED connected to PIN 1 of PORT A. Then, when I pull the INT0 (pin 16 on the ATMega16) high, the LED should go off. However, after compiling and downloading this, only the LED lights up, and nothing happens when I pull the INT0 hi.

Some problems:
1. What should the 'mask' be in calling 'enable_external_int()' ?
2. I replaced enable_external_int() with
 MCUCR = (1<<ISC01) | (1<<ISC00);
 GICR = (1<<INT0);

 Still, no luck.


I cannot find any clear examples on how to use external interrupts on the net and the document by Rich Neswold isn't very clear on the 'mask' to be given to enable_external_int().

Can anybody give me some clues?

Thanks in advance,
Bart

_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list

</x-flowed>

reply via email to

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