Hello everybody!
I'm working with K60N512, I'm trying to develop an odometer. I guess the best way to accomplish that is with the pulse counter, to measure wheel pulses, and then get the speed and distance with a simple conversion.
But I can not make the counter to increment.
This is how I configure the LPTMR0:
| SIM_SCGC5 |= SIM_SCGC5_LPTIMER_MASK; | | // Enable LPT Module |
// Reset LPTMR module
LPTMR0_CSR = 0x00;
LPTMR0_PSR = 0x00;
LPTMR0_CMR = 0x00;
// I choose PRESCALER = 1, because it says 0 is not supported on pusle counter mode
LPTMR0_PSR = LPTMR_PSR_PRESCALE(1) | LPTMR_PSR_PBYP_MASK; // bypass glicth filter
| LPTMR0_CSR |= LPTMR_CSR_TPS(2); | // Input pin select |
LPTMR0_CSR &= ~LPTMR_CSR_TPP_MASK; // Rising Edge
LPTMR0_CSR |= LPTMR_CSR_TMS_MASK; // Timer as Pulse Counter
LPTMR0_CSR |= LPTMR_CSR_TEN_MASK; // Turn on LPTMR
Then I've got a function generator (square wave) connected to PTC5 (LPTMR0_ALT2), but the counter valur remains zero.
Am I missing something?
Thanks in advance!!
Best Regards,
SebaS