-
-
Save urmil0071/9ccd43c29adea87a504605f09b55024f to your computer and use it in GitHub Desktop.
Execute ISR to blink LED 3 times using TC1 interrupt (MLP=Do Nothing) (ISR=Blink Built In LED 3 times after 1 second interval)
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 <Arduino.h> | |
void setup() | |
{ | |
pinMode(13,OUTPUT); | |
digitalWrite(13,LOW); | |
TCCR1A=0x00; /// Timer 1 normal mode | |
TCCR1B=0x00; ///Timer 1 off | |
TCNT1=0xC2F7; /// Timer 1 preset value | |
bitWrite(SREG,7,1); /// Enable global interrupt | |
bitWrite(TIMSK1,0,1); /// Enable TIMER1_OVF interrupt | |
bitWrite(TIFR1,2,1); /// TOV1 Clear | |
TCCR1B=0x05; /// Timer 1 ON | |
} | |
ISR(TIMER1_OVF_vect) | |
{ | |
interrupts(); ///Enable Global Interrupt again at ISR | |
TCCR1B=0x00; /// Timer 1 off | |
TCNT1=0xC2F7; ///Preset value for 1 second | |
for (int i=0;i<=2;i++) | |
{ | |
digitalWrite(13,LOW); | |
delay(500); | |
digitalWrite(13,HIGH); | |
delay(500); | |
digitalWrite(13,LOW); | |
} | |
bitWrite(TIFR1,2,1); /// TOV1 Clear | |
TCCR1B=0x05; /// Timer 1 ON | |
} | |
void loop() | |
{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment