summaryrefslogtreecommitdiff
path: root/include/arch
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-01-16 18:38:21 +0100
committerDaniel Friesel <derf@finalrewind.org>2022-01-16 18:38:21 +0100
commit0d502cd0995600b1399c442697bfba5af4ae9deb (patch)
treec6c923b6cd111603bbf267b0bfac300ab89b83ba /include/arch
parentfb6e2fed7132ae776c62aecc2ee09ad532d482d3 (diff)
msp430fr timer: automatically set TA0CCR for low Hz values
Diffstat (limited to 'include/arch')
-rw-r--r--include/arch/msp430fr5969lp/driver/timer.h11
-rw-r--r--include/arch/msp430fr5994lp/driver/timer.h20
2 files changed, 19 insertions, 12 deletions
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
diff --git a/include/arch/msp430fr5994lp/driver/timer.h b/include/arch/msp430fr5994lp/driver/timer.h
index 9a2c7fe..97bd302 100644
--- a/include/arch/msp430fr5994lp/driver/timer.h
+++ b/include/arch/msp430fr5994lp/driver/timer.h
@@ -56,17 +56,17 @@ class Timer {
TA0CTL |= TACLR;
}
- inline void setup_hz(uint16_t const frequency) { // 2 MHz base
+ inline void setup_hz(uint16_t const frequency) {
TA0CTL = TASSEL__SMCLK | _TA0_MAIN_DIV;
- TA0EX0 = 0;
- TA0CCR0 = 2000000UL / frequency;
- TA0CTL |= TACLR;
- }
-
- inline void setup_hz_low(uint16_t const frequency) { // 250 kHz base
- TA0CTL = TASSEL__SMCLK | _TA0_MAIN_DIV;
- TA0EX0 = 7;
- TA0CCR0 = 250000UL / frequency;
+ if (frequency < 32) {
+ // 2 MHz base
+ TA0EX0 = 7;
+ TA0CCR0 = 250000UL / frequency;
+ } else {
+ // 250 kHz base
+ TA0EX0 = 0;
+ TA0CCR0 = 2000000UL / frequency;
+ }
TA0CTL |= TACLR;
}
#endif