Created
March 22, 2016 09:20
-
-
Save raghavendrahassy/7c56d76b6fd53f991875 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<avr/io.h> | |
#include<avr/interrupt.h> | |
#define LED PD4 | |
ISR (TIMER1_OVF_vect) // Timer1 ISR | |
{ | |
PORTD ^= (1 << LED); | |
TCNT1H=0xF9; // Reload the 16-bit count value | |
TCNT1L=0xE6; // in timer1 count registers | |
} | |
int main() | |
{ | |
DDRD = (0x01 << LED); //Configure the PORTD4 as output | |
TCNT1=63976; // for 1 sec at 16 MHz | |
TCCR1A = 0x00; | |
TCCR1B = (1<<CS10) | (1<<CS12);; // Timer mode with 1024 prescler | |
TIMSK = (1 << TOIE1) ; // Enable timer1 overflow interrupt(TOIE1) | |
sei(); // Enable global interrupts by setting global interrupt enable bit in SREG | |
while(1) | |
{ | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment