Skip to content

Instantly share code, notes, and snippets.

@enjoycowboy
Created March 19, 2017 01:16
Show Gist options
  • Save enjoycowboy/2956984ca69b11e363c063e941d6060b to your computer and use it in GitHub Desktop.
Save enjoycowboy/2956984ca69b11e363c063e941d6060b to your computer and use it in GitHub Desktop.
8mhz 1s timer
TIMSK1 = (1<<OCIE1A); // output capture enable
TCCR1B = (1<<WGM12)|(1<<CS12)|(0<<CS11)|(0<<CS10); //prescaler 256
OCR1A = 0x7A11; //31.250 * 256 = 8.000.000
TCNT1 = 0;
sei(); //system enable interrupt
ISR(TIMER1_COMPA_vect){
i++;
TCNT1=0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment