You are not logged in

Log in into our community

Log in so you acess some hidden content

* Fields are required.

Register into our community!

Sign up now for some good content

* Fields are required.

Lost something?

Enter your username or email to reset your password.

* Fields are required.

Repetitive Interrupt Timer (RIT)

Posted on : Sat , 03 2014 by : virusi

THEORY ON RIT :


The Repetitive Interrupt Timer provides a versatile means of generating interrupts at specified time intervals, without using a standard timer. It is intended for repeating interrupts that aren’t related to Operating System interrupts. However, it could be used as an alternative to the Cortex-M3 System Tick Timer.

Repetitive Timer counter begins counting up from 00000000h. Whenever the counter value equals the value programmed into the RICOMPVAL register the interrupt flag will be set. If the enable_clr bit is low (default state), a valid comparison ONLY causes the interrupt flag to be set. It has no effect on the count sequence. Counting continues as usual. When the counter reaches FFFFFFFFh it rolls-over to 00000000h on the next clock and continues counting. If the enable_clr bit is set to ‘1’ a valid comparison will also cause the counter to be reset to zero. Counting will resume from there on the next clock edge. Counting can be halted in software by writing a ‘0’ to the Enable_Timer bit – RICTRL(2). Counting will also be halted when the processor is halted for debugging provided the Enable_Break bit – RICTRL(1) is set. Both the Enable_Timer and Enable_Break bits are set on reset.

The interrupt flag can be cleared in software by writing a ‘1’ to the Interrupt bit – RICTRL(0). Software can load the counter to any value at any time by writing to RICOUNTER. The counter (RICOUNTER), RICOMPVAL register, RIMASK register and RICTRL register can all be read by software at any time.

LIC1768 PRACTICAL EXAMPLE :


In this application let’s blink some led’s using Repetitive Interrupt Timer. Whenever a Repetitive Interrupt occurs will change the compare value this will lead to increasing of the LED’s blinking. So what we have to do is configure the RTI and in RTI interrupt turn on/off the LED’s and increase the compare value.

SystemTickTimerApplication
Fig.1 Repetitive Interrupt Timer application

AT INITIALIZATION :

1. Configure MCU clock

/* initialize clocks */
SystemInit();

2. Configure LED’s port as output.

/* Configure P 2.00... P 2.07 as output */
LPC_GPIO2->FIODIR   = ((1UL<< 0)|(1UL<< 1)|
  			     (1UL<< 2)|(1UL<< 3)|
                             (1UL<< 4)|(1UL<< 5)|
                             (1UL<< 6)|(1UL<< 7)) ;
/* turn off all the LEDs */            
LPC_GPIO2->FIOCLR = 0x000000FF;	 

3. Configure RIT

 /* Configure RIT */
 void ConfigureRIT(void)
 {
 	 /* enable RIT in PCON register */
	 LPC_SC->PCONP |= ENABLE_PCRIT; 
	 /* Clear CTRL register */
	 LPC_RIT->RICTRL = 0UL;
	 /* Set Compare val */
	 LPC_RIT->RICOMPVAL = 0x3FFFFUL;
	 /* clear RIC counter */
	 LPC_RIT->RICOUNTER = 0UL;
	 /* Set CTRL register */
	 LPC_RIT->RICTRL = RITENCLR|
                  	   RITENBR|
			   RITEN;
	 /* enable RIT interrupt */
	 NVIC_EnableIRQ(RIT_IRQn); 
 } 

IN INTERRUPT :

1. Turn on/off LED’s ,clear RICTRL register and increase compare value

 void RIT_IRQHandler(void)
 {
   currentState = (currentState == 0UL) ? 0xFFUL : 0UL ;
   LPC_GPIO2->FIOPIN = currentState;
   /* Clear CTRL interrupt */
   LPC_RIT->RICTRL |= RITINT;	
   /* chage compare value */
   LPC_RIT->RICOMPVAL += 0xFF; 
 }

Download :


If you are interested in the full example then download RIT example.
Last updated on Mon , 03 2014
SHARE THIS PAGE :

This page is waiting for your comment.

Share and Leave a comment.

You must be logged in to post a comment.

Back to Top