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.

System Tick Timer

Posted on : Sat , 03 2014 by : virusi

Theory on System Tick Timer :


The System Tick Timer is an integral part of the Cortex-M3. The System Tick Timer is intended to generate a fixed 10 millisecond interrupt for use by an operating system or other system management software.

The System Tick Timer is a 24-bit timer that counts down to zero and generates an interrupt. The intent isto provide a fixed 10 millisecond time interval between interrupts. The System Tick Timer may be clocked either from the CPU clock or from the external pin STCLK. The STCLK function shares pin P3.26 with other functions, and must be selected for use as the System Tick Timer clock. In order to generate recurring interrupts at a specific interval, the STRELOAD register must be initialized with the correct value for the desired interval. A default value is providedin the STCALIB register and may be changed by software. The default value gives a 10 millisecond interrupt rate if the CPU clock is set to 100 MHz.

Let’s calculcate the STRELOAD register value for a 100MHz clock. Cclk is 100MHz.

RELOAD = (cclk / 100) – 1 = 1,000,000 – 1 = 999,999 = 0xF423F4 This is the value that should be enterted in the STRELOAD so we can get a 10 milisecond interrupt.

When the value of RELOAD will be 0 the System Tick Timer will generate a interrupt if STCTRL is set.

LPC1768 Practical Example :


So let’s take a look how we can configure and use the System Tick Timer. Everytime when a System Tick Timer will accure will blink different led’s.

SystemTickTimerApplication
Fig. 1 System Tick Timer Applicatin

AT INITIALIZATION :

1. Configure the clock. In our case it should be configured to 100 MHz. System init is done in system_LPC17xx.c

/* 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 the System Tick Timer. System Tick Timer configuration is done in core_cm3.h.

/* Setup SysTick Timer for 10 msec interrupts  
SystemCoreClock is the current Clock that 
should be devided to 100. */
if( SysTick_Config(SystemCoreClock / 100 ) )
{ 
   /* Capture error */
   while (1);                              
}

AT RUNTIME :

1. In System Tick Timer interrupt blink a LED’s

/* timer intrerupt */
void SysTick_Handler(void) 
{
   /* increment counter necessary in Delay() */  
   LPC_GPIO2->FIOPIN = (1UL< 8)
   {
     currentLed = 0;	
   }
 } 

Download :


If you are interested in the full example then download SystemTickTimer 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