diff options
author | marcoveeneman <marco-veeneman@hotmail.com> | 2015-03-20 20:21:38 +0100 |
---|---|---|
committer | marcoveeneman <marco-veeneman@hotmail.com> | 2015-03-20 20:21:38 +0100 |
commit | 87e99fedd8e5016c9e81d97e7e93400ac03e96a7 (patch) | |
tree | 3518c12ca3c966178fe73458901d6a37660c31d7 | |
parent | 930d2d6de00a1d5423b0363d2abd86879a1f5051 (diff) | |
download | ChibiOS-Contrib-87e99fedd8e5016c9e81d97e7e93400ac03e96a7.tar.gz ChibiOS-Contrib-87e99fedd8e5016c9e81d97e7e93400ac03e96a7.tar.bz2 ChibiOS-Contrib-87e99fedd8e5016c9e81d97e7e93400ac03e96a7.zip |
Changed the Tiva tickless timer implementation to use the timer in down mode. It's working for WGPT5 now.
-rw-r--r-- | os/hal/ports/TIVA/LLD/st_lld.c | 5 | ||||
-rw-r--r-- | os/hal/ports/TIVA/LLD/st_lld.h | 32 |
2 files changed, 26 insertions, 11 deletions
diff --git a/os/hal/ports/TIVA/LLD/st_lld.c b/os/hal/ports/TIVA/LLD/st_lld.c index 6b47503..1a9fbe6 100644 --- a/os/hal/ports/TIVA/LLD/st_lld.c +++ b/os/hal/ports/TIVA/LLD/st_lld.c @@ -248,14 +248,13 @@ void st_lld_init(void) TIVA_ST_TIM->CTL = 0; TIVA_ST_TIM->CFG = GPTM_CFG_CFG_SPLIT; /* Timer split mode */ TIVA_ST_TIM->TAMR = (GPTM_TAMR_TAMR_PERIODIC | /* Periodic mode */ - GPTM_TAMR_TACDIR | /* Count up */ + /*GPTM_TAMR_TACDIR |*/ /* Count up */ GPTM_TAMR_TAMIE | /* Match interrupt enable */ GPTM_TAMR_TASNAPS); /* Snapshot mode */ - //TIVA_ST_TIM->TAPR = (ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1; + TIVA_ST_TIM->TAPR = (ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1; /* in up mode (used by tickless mode) the prescaler register extends the TAV * and TAR registers. How to solve this? In down mode it is working better * because the prescaler really works as prescaler. */ - //TIVA_ST_TIM->CTL = (GPTM_CTL_TAEN | GPTM_CTL_TASTALL); TIVA_ST_TIM->CTL = (GPTM_CTL_TAEN | /* Timer A enable */ GPTM_CTL_TASTALL); /* Timer A stall when paused */ diff --git a/os/hal/ports/TIVA/LLD/st_lld.h b/os/hal/ports/TIVA/LLD/st_lld.h index 0db601a..aadc966 100644 --- a/os/hal/ports/TIVA/LLD/st_lld.h +++ b/os/hal/ports/TIVA/LLD/st_lld.h @@ -206,7 +206,8 @@ extern "C" { static inline systime_t st_lld_get_counter(void) { #if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING - return (systime_t) TIVA_ST_TIM->TAV/((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); + return (systime_t) 0xffffffff - TTIVA_ST_TIM->TAV; + //return (systime_t) TIVA_ST_TIM->TAV/((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); //return (systime_t) ((TIVA_ST_TIM->TAV >> 16) | (TIVA_ST_TIM->TAPV << 16))/((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); #else return (systime_t) 0; @@ -238,10 +239,18 @@ static inline void st_lld_start_alarm(systime_t time) // TIVA_ST_TIM->ICR = 0xffffffff; // TIVA_ST_TIM->IMR = GPTM_IMR_TAMIM; - uint64_t settime = time * ((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); +// uint64_t settime = time * ((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); +// +// TIVA_ST_TIM->TAPMR = (uint16_t) ((settime >> 32) & 0xffff); +// TIVA_ST_TIM->TAMATCHR = (uint32_t) (settime); +// +// TIVA_ST_TIM->ICR = TIVA_ST_TIM->MIS; +// TIVA_ST_TIM->IMR = GPTM_IMR_TAMIM; + + //uint64_t settime = time * ((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); - TIVA_ST_TIM->TAPMR = (uint16_t) ((settime >> 32) & 0xffff); - TIVA_ST_TIM->TAMATCHR = (uint32_t) (settime); + //TIVA_ST_TIM->TAPMR = (uint16_t) ((settime >> 32) & 0xffff); + TIVA_ST_TIM->TAMATCHR = (uint32_t) 0xffffffff - settime; TIVA_ST_TIM->ICR = TIVA_ST_TIM->MIS; TIVA_ST_TIM->IMR = GPTM_IMR_TAMIM; @@ -282,10 +291,15 @@ static inline void st_lld_set_alarm(systime_t time) // // TIVA_ST_TIM->TAPMR = (uint16_t) temp; - uint64_t settime = time * ((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); +// uint64_t settime = time * ((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); +// +// TIVA_ST_TIM->TAPMR = (uint16_t) ((settime >> 32) & 0xffff); +// TIVA_ST_TIM->TAMATCHR = (uint32_t) (settime); + + //uint64_t settime = time * ((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); - TIVA_ST_TIM->TAPMR = (uint16_t) ((settime >> 32) & 0xffff); - TIVA_ST_TIM->TAMATCHR = (uint32_t) (settime); + //TIVA_ST_TIM->TAPMR = (uint16_t) ((settime >> 32) & 0xffff); + TIVA_ST_TIM->TAMATCHR = (uint32_t) (0xffffffff - settime); #else (void)time; #endif @@ -312,7 +326,9 @@ static inline systime_t st_lld_get_alarm(void) // return (systime_t) temp; //return (systime_t) (TIVA_ST_TIM->TAPR << 16 | TIVA_ST_TIM->TAR >> 16); - return (systime_t) ((TIVA_ST_TIM->TAV >> 16) | (TIVA_ST_TIM->TAPV << 16))/((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); + //return (systime_t) ((TIVA_ST_TIM->TAV >> 16) | (TIVA_ST_TIM->TAPV << 16))/((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); + + return (systime_t) TIVA_ST_TIM->TAR; #else return (systime_t) 0; #endif |