Hi,
In using LPTMR to count the pulse.
here is the snip shot of the code
void lptmr_pulse_count(uint32 count_val, int pc_src, int psg_src)
{
// Reset LPTMR module
lptmr_clear_registers();
// For interupt handler
lptmr_mode = LPT_CNTR_MODE;
// Enable LPT Interrupt in NVIC
enable_irq(LPTMR_IRQ_NUM); // LPTMR Vector is 101. IRQ# is 101-16=85
// Set up the interrupt vector for counter == compare val
// Set the compare value
LPTMR0_CMR = count_val;
// Set up LPTMR to bypass prescaler clock
LPTMR0_PSR = (LPTMR_PSR_PBYP_MASK | LPTMR_PSR_PCS(psg_src));
// select pulse counter mode, pulse counter clk src, and interrupt enable.
LPTMR0_CSR |= LPTMR_CSR_TMS_MASK | LPTMR_CSR_TPS(pc_src) | LPTMR_CSR_TIE_MASK;
LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;
lptmr_intrpt = 0;
return;
}
count_value = 0xFFFF
clock source is LPO.
in oscilloscope I counted the pulse it is 22 but in CNR register the value is 69.. please see the image for the pulse