I have some problems with configuring Timer0 to decode signals from Quadrature encoder.
For lower frequency it kind of works, although count is off by 4 ? Is that because of PLL ?
Lets say I have 100Hz signal, I would get 24-26 interrupts ?
On frequencies above 2-3kHz, I dont get a single interrupt call. Why would that happen ?
My setup function looks like:
LPC_SYSCON->ASYNCAPBCTRL = 1;
LPC_ASYNC_SYSCON->ASYNCAPBCLKCTRLSET = _BV(13);
LPC_ASYNC_SYSCON->ASYNCPRESETCTRLCLR = _BV(13);
IOMux io_chnA (0, 26, FuncEnum::B0_CAP3); io_chnA.setI2CMode(false);
IOMux io_chnB (0, 25, FuncEnum::B0_CAP2); io_chnB.setI2CMode(false);
LPC_TIMER0->CCR |= _BV(9) | _BV(10) | _BV(11); //capture 0.3 raising edge, falling edge, interrupt
LPC_TIMER0->TCR = 1;
NVIC_EnableIRQ (CT32B0_IRQn);
NVIC_SetPendingIRQ (CT32B0_IRQn);
Interrupt function like:
extern "C" void CT32B0_IRQHandler ()
{
if (IS_BIT_ENABLED(LPC_TIMER0->IR, TIMER_IR_CR3)){ //chnA interrupt
LPC_TIMER0->IR |= _BV(TIMER_IR_CR3);
LPC_TIMER0->TCR |= _BV(1);
}
LPC_TIMER0->TCR &= ~_BV(1);
}
My microcontroller is running at 96Mhz PLL. No prescale on Timer.
Why is capture not triggered on >3kHz ?