#include <avr/io.h>
#define F_CPU 16000000UL // Define CPU frequency as 1 MHz for delay calculations
#include <util/delay.h>
//**https://docs.arduino.cc/retired/hacking/hardware/PinMapping2560/
#include <avr/interrupt.h>
volatile uint8_t count=0;
// Function prototypes
void aufgabe1(void);
void aufgabe2(void);
int main(void) {
// Initialize PortB as output
DDRB = 0xFF; // Set all pins of Port B as outputs
PORTB = 0xFF; // Initially turn off all LEDs
aufgabe1(); // Call Aufgabe1 for LED bouncing with delay
//aufgabe2(); // Call Aufgabe2 for LED bouncing using Timer1 delay
}
void aufgabe1(){
uint8_t flag=1;
//SW2 neg. edge -> INT0-PD0, ISC0 1/0=10
//SW3 neg. edge -> INT1-PD1, ISC1 1/0=10
sei();
//order is important
//MCUCR
EICRA|=(1<<ISC11) | (1<<ISC01)|(1<<ISC10) | (1<<ISC00);
//EICRA&=~((1<<ISC10) | (1<<ISC00));
//GICR
EIMSK|= (1<<INT1) | (1<<INT0);
//DDRD=0x00;
//PORTD |= (1<<PD0) | (1<<PD1);
while(1){
PORTB=count;
}
}
ISR(INT0_vect){
count++;
//while(PIND || ~(1<<PD0));
}
ISR(INT1_vect){
count--;
}