Merge pull request #3140 from gebart/pr/kinetis-hwtimer-isr-off-by-1

kinetis: hwtimer fix off-by-1 in LPTMR ISR
This commit is contained in:
Joakim Gebart 2015-06-02 19:23:10 +02:00
commit 7a9f6f9796

View File

@ -202,7 +202,11 @@ unsigned long hwtimer_arch_now(void)
void isr_lptmr0(void)
{
stimer.counter32b += (uint32_t)LPTIMER_DEV->CMR;
/* The timer counter is reset to 0 when the compare value is hit, add the
* compare value to the 32 bit counter. Add 1 for counting the 0'th tick as
* well (TCF asserts when CNR equals CMR and the counter increases) */
stimer.counter32b += (uint32_t)LPTIMER_DEV->CMR + 1;
/* clear compare flag (w1c bit) */
LPTIMER_DEV->CSR |= LPTMR_CSR_TCF_MASK;