Timer1 does not count in LPC1778

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Timer1 does not count in LPC1778

247 Views
lpcware
NXP Employee
NXP Employee
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 ?
Labels (1)
0 Kudos
1 Reply

211 Views
lpcware
NXP Employee
NXP Employee
bump
0 Kudos