Dear Community
I started a small INT0 exersise.
Thats what the code should do:
I apply 100Hz signalto INT0 pin
I declared a variable uinit32_t counter.
In the ISR I increment the counter by 1.
In a while loop I check if counter exceeds 1000 counts and if yes I toggle pin4 of portD.
I checked with a pin toggle in the ISR that the interrupt gets sensed and it does. I have just wondered about the quite long latency of ca. 3us until the interruppt gets serviced.
The debuger does not help much, when I do single step it goes straight to the PORTD toggle (after initialising) after executing PORTD toggle it goes to "if (counter >= 1000)" and the debugger exits single stepping, I can only stop or pause.
It looks like a simple code,buit I dont know whats wrong.
Have you got a tip?
regards
Juergen
/* * ExternInt0.c * * Created: 18.10.2019 10:36:28 * Author : jb */ #include <avr/io.h> #include <avr/interrupt.h> //uint8_t counter; uint32_t counter; ISR (INT0_vect) { counter++; //PORTD ^= (1<<4); } int main(void) { DDRD &= ~(1<<PD2); DDRD |= (1<<PD4); PORTD = 0x00; EICRA |= (1<<ISC01) | (1<<ISC00); EIMSK |= (1<<INT0); sei(); while (1) { if (counter >= 1000) { PORTD ^= (1<<4); counter= 0; } } }