From dca6dd35dc27d48f593d1cfdff5d35e2dfb95968 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 14 Dec 2016 13:24:08 +0000 Subject: [PATCH] Reduce the value of the LPTMR CMR by one. --- IOTeensy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOTeensy.cpp b/IOTeensy.cpp index 4afe045..5e3d24e 100644 --- a/IOTeensy.cpp +++ b/IOTeensy.cpp @@ -131,7 +131,7 @@ void CIO::startInt() SIM_SCGC5 |= SIM_SCGC5_LPTIMER; // Enable Low Power Timer Access LPTMR0_CSR = 0; // Disable LPTMR0_PSR = LPTMR_PSR_PBYP; // Bypass prescaler/filter - LPTMR0_CMR = EXTERNAL_OSC / 24000; + LPTMR0_CMR = (EXTERNAL_OSC / 24000) - 1; // Frequency divided by CMR + 1 LPTMR0_CSR = LPTMR_CSR_TPS(2) | // Pin: 0=CMP0, 1=xtal, 2=pin13 LPTMR_CSR_TMS; // Mode Select, 0=timer, 1=counter LPTMR0_CSR |= LPTMR_CSR_TEN; // Enable