Line 14: Line 14:
 
==Code==
 
==Code==
 
<html>
 
<html>
<script src="https://gist.github.com/raghavendrahassy/7c56d76b6fd53f991875.js"></script>
+
<script src="https://gist.github.com/raghavendrahassy/cbf6fd9571ac6e8fc0c5.js"></script>
 
</html>
 
</html>
  

Revision as of 14:52, 22 March 2016

Basics

TIMSK
Timer/Counter Interrupt Mask Register
D7 D6 D5 D4 D3 D2 D1 D0
- - TICIE1 OCIE1A OCIE1B TOIE1 - -

Code

#include<avr/io.h>
#include<avr/interrupt.h>
#define LED PD4
ISR (TIMER1_OVF_vect) // Timer1 ISR
{
PORTD ^= (1 << LED);
TCNT1 = 63974; // for 1 sec at 16 MHz
}
int main()
{
DDRD = (0x01 << LED); //Configure the PORTD4 as output
TCNT1 = 63974; // 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)
{
}
}