#include<avr/interrupt.h>
#define DDRF *(volatile char*)0x30
#define PORTF *(volatile char*)0x31
#define DDRD *(volatile char*)0x2a
#define PIND *(volatile char*)0x29
#define EICRA *(volatile char*)0x69
#define EIMSK *(volatile char*)0x3d
#define TCCR1A *(volatile char*)0x80
#define TCCR1B *(volatile char*)0x81
#define TCNT1 *(volatile unsigned short*)0x84
#define OCR1A *(volatile unsigned short*)0x88
#define TIMSK1 *(volatile short*)0x6f
void initPort();
void init_ExtInt();
void init_Timer();
void setup() {
initPort();
init_ExtInt();
init_Timer();
while(1){}
}
void initPort(){
DDRF = 0xff;
DDRD = 0x00;
}
void init_Timer(){
TCCR1A = 0X00;
TCCR1B = 0X00 ;
TCNT1 = 0x00; //Clear timer current value
OCR1A = 60000; //Set timer value
TIMSK1 = 0x02; //Enable output compare A match interrupt
}
void init_ExtInt(){
//INT0 is for PORT D Pin 0
EICRA = 0x03; //INT0 Raising edge
EIMSK = 0x01; //INT0 Interrupt enable
}
ISR(TIMER1_COMPA_vect){
TCCR1B = 0X00;
TCNT1 = 0x00;
PORTF = 0x00;
}
ISR(INT0_vect){
PORTF = 0x01;
TCCR1B = 0X0c ; //CTC mode and 256 prescalar
}
void loop() {
}