Author: Not specified Language: c
Description: Not specified Timestamp: 2017-10-01 21:28:17 +0000
View raw paste Reply
#include <avr/io.h>
#define F_CPU 8000000UL
#include <util/delay.h>
#include <avr/interrupt.h>
int main(void){
        sei(); // enables interrupts
        DDRD = 0xFF; // sets all pins in PORTD to output
        TCNT1 = 34285; // sets the counter of Timer 1 to 34285
        TIMSK1 = 0b00000001; // enables interrupts through timer overflow
        TCCR1B = 0b00000100; // sets the clock source and prescaler to 256
        for(;;);
}

ISR(TIMER1_OVF_vect){
        PORTD ^= 0xFF; // sets all pins in PORTD to high
        TCNT1 = 34285; // sets the counter of Timer 1 to 34285
}
View raw paste Reply