Hi,
I am trying to debug my ATmega324P TQFP INT0 interrupt. I have configured the MCU so INT0 (PD2) is triggered on an incoming logic low event and therefore I have used a pull-up resistor.
The problem I have is the INT0 I/O pin after the first event is pulled low and will not reset high. I have confirmed this by putting a scope on the I/O pin.
I have included my code below, and cross referenced with the datasheet, but I do not think I have made a mistake. Can anybody see any problem, or am I implementing my interrupt incorrectly?
Thanks,
Tuurbo46
#define F_CPU 8000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <stdio.h>
#include <avr/interrupt.h>
int8_t Data;
ISR(INT0_vect)
{
Data = 1;
}
int main(void)
{DDRB = (1 << DDRB4); // Set LED as output
PORTB = 0b00000000; // Set LED state to zero
DDRD = (0 << DDRD2); // Set INT0 as input
PORTD = (1 << PORTD2); // Set INT0 pull up resistor
EIMSK |= (1 << INT0); // Enable INT0
EICRA |= (0 << ISC01) | (0 << ISC00 ); // Trigger on logic low
sei();
while(1)
{
if (Data)
{
Data = 0;
PORTB ^= PORTB4; // Toggle led state
}
}
}