My goal is to measure a sensor frequency in between 50kHz to 120kHz for a high resolution. As the first step I want to divide this frequency to be able for handle on the LPC111x.
Therefore I am using that signal as an external input on PIO3_5 to the Timer/counter using the Timer/Counter setup:
LPC_IOCON->PIO3_5 = (LPC_IOCON->PIO3_5 & ~(0x3FF)) | 0x21; //set up pin (sec 7.4.17) (no pull up, Hyst enable)
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<7)|(1<<16)|(1<<6); //enable clock signal CT16B0 (sec 3.5.14)
LPC_TMR16B0 ->PR = 0; //no preclear (sec 18.7.4)
LPC_TMR16B0 ->MR0 = 200; //compare-counter(sec 18.7.7)
LPC_TMR16B0 ->MR1 = 0;
LPC_TMR16B0 ->MCR = 0x03; //TC Reset on MR0 Match, enable Interrupt (sec 18.7.6)
LPC_TMR16B0->EMR = 0x30; //do nothing (sec 18.7.10)
LPC_TMR16B0 ->PWMC = 0; //no PWM Mode, (sec 18.7.12)
LPC_TMR16B0 ->CTCR = 05; // (sec 18.7.11) counter mode on rising edge, CT16Bn_CAP0
LPC_TMR16B0 ->TCR = 02; //reset (sec 18.7.2)
LPC_TMR16B0 ->TCR = 01; //GO (sec 18.7.2)
For the first test I am reading in a polling loop the LPC_TMR16B0->TC and expecting random values, but getting just zero.
I am not going to use the Capture.
May be I am not understanding some basics in using the external Counter input.