RITIMER ticking on every clock

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

RITIMER ticking on every clock

275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArriaLive on Sat Oct 26 15:41:28 MST 2013
I'm trying to use the Repetitive Interrupt Timer (RIT) for some housekeeping clocking chores on an LPC1830 Xplorer board, but can't seem to get it working as expected.

Here's how I'm setting it up:

/* Setup Repeating Int Timer (RIT) */
LPC_RITIMER->COMPVAL= 180000;                 //Hope to use a calculated value for this, but this is close to the value I expect
                                                                                    // with LPC1830 running at 180MHz, should generate roughly 1ms interrupts
LPC_RITIMER->MASK=0x0;//no mask bits, which should allow compval to determine interrupt
LPC_RITIMER->COUNTER=0x0;//always start at zero
LPC_RITIMER->CTRL= ( (1<<1) /* Timer reset to zero on interrupt */
| (1<<2) /* stop the timer when debugging */
                                                | (1<<3));                 /* Enable */

NVIC_EnableIRQ(RITIMER_IRQn);//Enable the interrupt

I can look at the register entries and they are correct.  The counter appears to count up to the compare value and restarts, however, the interrupt flag (CTRL bit 1) is set immediately, and the RITinterrupt is called.  And it is called with every clock tick.  The RIT doesn't wait until the compare value at all.

I've tried changing the mask, making the compval larger, and more.  I've searched the net for examples of this working, but they all do essentially what I'm doing.  I've scoured the documentation for any detail I might be missing, but I'm not finding anything.  I've even changed Xplorer boards just in case there was a hardware anomaly.  Still no luck.

Can someone provide me a clue of what I'm missing?

Thanks,
EdA
0 Kudos
2 Replies

225 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArriaLive on Sat Oct 26 19:23:34 MST 2013
Thanks for the correction.  Yes, bit 0 on the CTRL flag.

But that wasn't the problem.  I did, however, resolve it.  This I am saying while striking the palm of my hand to my forehead.  ("Doh!").

I needed to clear the interrupt flag.  Apparently without doing that, upon return from the interrupt handler, the handler is immediately called again.

Sorry for the fire drill.

EdA
0 Kudos

225 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cfbsoftware on Sat Oct 26 18:55:44 MST 2013

Quote: ArriaLive
however, the interrupt flag (CTRL bit 1)


No - the interrupt flag is CTRL bit 0.
0 Kudos