Last active
August 29, 2015 14:05
-
-
Save sternenseemann/e8128af5bd2b8cd665fe to your computer and use it in GitHub Desktop.
avr blink program
This file contains hidden or 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
#define F_CPU 10000000UL | |
#include <avr/io.h> | |
#include <avr/interrupt.h> | |
#define BLINKPIN (1 << DDA0) | |
int main(void) { | |
DDRA = BLINKPIN; | |
PORTA = DDRA; | |
// disable Interrupts in order to setup | |
// timer interrupts | |
cli(); | |
// enable compare mode | |
TCCR1A = (1 << WGM01); | |
// prescaler 1024 | |
TCCR1B = CS12 | CS10; | |
// around 10Hz | |
OCR1A = 975; | |
// enable compare | |
TIMSK |= (1 << OCIE1A); | |
// avtivate interrupts again | |
sei(); | |
while(1) | |
; | |
return 0; | |
} | |
ISR (TIMER1_COMPA_vect) { | |
PORTA ^= BLINKPIN; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment