LPC11C24 external clock counter mode

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by lerlacher on Sat May 24 10:30:20 MST 2014

I'm trying to capture an encoder signal (a light barrier) using the timer module in counting mode with external clock on the capture pin.

Here is my code (formatted version: http://pastie.org/private/kdic1jfdhge0pnwfv6ola):
void eli_light_init() {

//configure capture input
LPC_IOCON->R_PIO1_0 &= ~0x1F;
LPC_IOCON->R_PIO1_0 |= (0x2 << 3) | 0x3;

//enable clock

//configure timer block
LPC_TMR32B1->PR = 0x0;  // disable Prescaler
LPC_TMR32B1->MCR&= ~(0xFFF);// disable matching
LPC_TMR32B1->EMR&= ~(0xFFF);// disable match outputs
LPC_TMR32B1->CCR&= ~(0x3);// disable capture copy
LPC_TMR32B1->CTCR&= ~(0xF);// clear count control
LPC_TMR32B1->CTCR|=  (0x1);// set count control to capture rising edge

//reset value of counter
LPC_TMR32B1->TC = 0;

//reset and enable timer
LPC_TMR32B1->TCR |= 0x3;
LPC_TMR32B1->TCR &= ~(0x2);

uint32_t eli_light_read(uint8_t reset) {
uint32_t value = LPC_TMR32B1->TC;

// reset
if (reset) {
LPC_TMR32B1->TC = 0;

return value;

I am testing this by just poking the PIO1_0 pin with a multimeter tip that is connected to VDD and a breakpoint with the condition "value > 0" in the read function. I have verified that the init function is called and that the read function is regularly called as well. The breakpoint never fires.

Am I setting up the control registers correctly? Is it kosher to enable the pulldown (is the pulldown even connected when the capture function is configured?) on the capture pin? Anything else?

Any help is muchly appreciated.