diff options
Diffstat (limited to 'kernel/time/mcu/atmega2560')
-rw-r--r-- | kernel/time/mcu/atmega2560/timer.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/kernel/time/mcu/atmega2560/timer.c b/kernel/time/mcu/atmega2560/timer.c index 663df02..e3ab6eb 100644 --- a/kernel/time/mcu/atmega2560/timer.c +++ b/kernel/time/mcu/atmega2560/timer.c @@ -10,7 +10,9 @@ void timer_init() { TCCR3B = (1 << WGM32); // turn on CTC mode: TCCR3B |= (1 << CS32) | (0 << CS31) | (1 << CS30); // set to 1024 prescaler - OCR3A = 770; + + unsigned int hz_counter = F_CPU / (2 * 1024 * HZ) - 1; + OCR3A = hz_counter; sei(); } @@ -23,7 +25,7 @@ void timer_stop() { } ISR(TIMER3_COMPA_vect, ISR_NAKED) { - SAVE_CONTEXT(); + SAVE_CONTEXT(); sched_tick(); sei(); RESTORE_CONTEXT(); |