Timer1 does not count in LPC1778

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 18, 2016 by lpcware
Content originally posted in LPCWare by mostafanfs on Tue Mar 08 02:35:01 MST 2016
I wanted to measure the width of a incoming pulse to an IO pin using Timer1 in LPC1778. The IO pin is not a CAP pin so I figured to do it simply by starting the timer when the pulse goes to low state and reading TC register after the pulse goes to high state. Peripheral clock is 60 MHz and I set PR register to 0. In PCONP register TImer1 is enabled by default.

LPC_TIM1->TCR  = 0x02; 
LPC_TIM1->IR   = 0x02; 
LPC_TIM1->CTCR = 0;    
LPC_TIM1->TC   = 0;    
LPC_TIM1->PR   = 0;    
LPC_TIM1->MCR  = 0x18; 

while(ISO7816_READ_DATA_BIT); // wait on high state
LPC_TIM1->TC = 0;  // clear Timer Counter
LPC_TIM1->TCR = 0x01 ;// start Timer
while(!ISO7816_READ_DATA_BIT); // wait on low state
oneBitTime = LPC_TIM1->TC;  // pulse width
LPC_TIM1->TCR = 0x02; // stop Timer

But oneBitTime is zero meaning the timer was not running or counting.
Is it missing something ?