From 0d502cd0995600b1399c442697bfba5af4ae9deb Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 16 Jan 2022 18:38:21 +0100 Subject: msp430fr timer: automatically set TA0CCR for low Hz values --- include/arch/msp430fr5969lp/driver/timer.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include/arch/msp430fr5969lp') diff --git a/include/arch/msp430fr5969lp/driver/timer.h b/include/arch/msp430fr5969lp/driver/timer.h index c07ae4e..160074a 100644 --- a/include/arch/msp430fr5969lp/driver/timer.h +++ b/include/arch/msp430fr5969lp/driver/timer.h @@ -58,8 +58,15 @@ class Timer { inline void setup_hz(uint16_t const frequency) { // 2 MHz base TA0CTL = TASSEL__SMCLK | _TA0_MAIN_DIV; - TA0EX0 = 0; - TA0CCR0 = 2000000UL / frequency; + if (frequency < 32) { + // 2 MHz base + TA0EX0 = 7; + TA0CCR0 = 250000UL / frequency; + } else { + // 250 kHz base + TA0EX0 = 0; + TA0CCR0 = 2000000UL / frequency; + } TA0CTL |= TACLR; } #endif -- cgit v1.2.3