summaryrefslogtreecommitdiff
path: root/include/arch
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-01-26 22:25:17 +0100
committerDaniel Friesel <derf@finalrewind.org>2022-01-26 22:25:17 +0100
commitaaa8d4c1622ce340bf57bb2b3c1e4b680587637c (patch)
tree30f6a3b435085d910b5ed326734a0e4b4373ee52 /include/arch
parent36f39d1bbae7b64e45b4ba505c704c04d90ecf79 (diff)
atmega2650 timer: actually use CTC mode
Diffstat (limited to 'include/arch')
-rw-r--r--include/arch/atmega2560/driver/timer.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/include/arch/atmega2560/driver/timer.h b/include/arch/atmega2560/driver/timer.h
index c16fbe4..e12592d 100644
--- a/include/arch/atmega2560/driver/timer.h
+++ b/include/arch/atmega2560/driver/timer.h
@@ -19,17 +19,19 @@ class Timer {
inline void setup_khz(uint16_t const frequency) { // 16 MHz base
OCR4A = frequency ? 16000 / frequency : 65535;
- TCCR4A = _BV(WGM42);
+ TCCR4A = 0;
+ TCCR4B = _BV(WGM42);
prescaler = _BV(CS40);
}
inline void setup_hz(uint16_t const frequency) { // 16 MHz / 256 == 62.5 kHz base
OCR4A = frequency ? 62500 / frequency : 65535;
- TCCR4A = _BV(WGM42);
+ TCCR4A = 0;
+ TCCR4B = _BV(WGM42);
prescaler = _BV(CS42);
}
inline void start(unsigned char const interrupt) {
TCNT4 = 0;
- TCCR4B = prescaler;
+ TCCR4B |= prescaler;
if (interrupt) {
TIMSK4 = _BV(OCIE4A);
}