]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/timer.c
move sys timer setup from main to timer.c
[z180-stamp.git] / avr / timer.c
index 1b1598540f82090c3dbe56e7610e33280342734e..03c86c82235053196418980ff6fb818a7206dada 100644 (file)
@@ -47,6 +47,15 @@ ISR(TIMER4_COMPA_vect)
        tick_10ms = i;
 }
 
+/*--------------------------------------------------------------------------*/
+
+void setup_timer(void)
+{
+       PRR1 &= ~_BV(PRTIM4);
+       OCR4A = F_CPU / 1000 - 1;       /* Timer4: 1000Hz interval */
+       TCCR4B = (0b00<<WGM42)|(0b001<<CS40); /* Normal Mode, Prescaler 1 */
+       TIMSK4 = _BV(OCIE4A);           /* Enable Output Compare A interrupt */
+}
 
 /*--------------------------------------------------------------------------*/