Late timer

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

Late timer

673 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jdurand on Sat Aug 25 12:55:31 MST 2012
LPC1754
LPCXpresso
Red Probe +

I'm seeing something odd with the timer...

I set up three MCR in the timer while it's reset and then let it run. The interrupts are coming in about 4% later than they should.  I've tested this at a bit over 1mS to almost 23mS.

I've tested SystemCoreClock by looking at continuous serial data and the serial baud rate comes out just fine.

Is there some way the debugger could slow the timer?  Any other way the timer could run slower than the serial port since they're both on the same PCLK?

Here's the setup:
LPC_TIM0->TCR = 0b10;
LPC_TIM0->MR0 =200;
LPC_TIM0->MR1 = 225;
LPC_TIM0->MR2 = 22850;  
LPC_TIM0->MCR = 1<<6 | 1<<3 | 1;
LPC_TIM0->TCR = 0b01;

I have a test point on one pin that I set low when I start the timer and high when MR2 interrupt hits.
Labels (1)
0 Kudos
2 Replies

666 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jdurand on Sat Aug 25 17:03:54 MST 2012
Found it!

I missed subtracting 1 from the Prescale Register (LPC_TIM0->PR) and since my prescale was 25, that made me 4% slow.  Now all is well.
0 Kudos

666 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jdurand on Sat Aug 25 13:45:23 MST 2012
Just to test things, I set up PWM1 to run at 100Hz and checked it with my logic analyzer.  It's running at 99.955853Hz which says my SystemCoreClock is within 0.04% of 100MHz.

So...why is Timer 0 running over 4% slow?
0 Kudos