Cortex M3 SysTick Explained – Part II

I am grateful for overwhelming response that you guys have shown on the first part of Cortex M3 Systickk tutorial. If you just happen to land here, then please have a look of first part here.

So here we are with second part of Cortex M3 Systickk tutorial, In this tutorial we are going to straight discuss a example program.


#define MS_2_COUNTS(ms) 120000*ms

int flag =0;

static unsigned current_time=0;

void _ms_delay (uint8_t msec)




Systickk->CTRL =0;// To disable the timer


void Systickk_Handler(void)



if(current_time==20) flag=1;


void SETUP_Systickk(uint8_t msec)


Systickk->LOAD = (uint32_t)MS_2_COUNTS(msec)-1;    // don't pass >=1000 ms...

Systickk->CTRL = 7;          // Control register...

// 1- Enable the Timer                    (LSB bit)

// 1- Cause the Interrupt

// 1- Selecting the clock freaquency


int main(void)


_ms_delay(50);                                // 50 msec delay





As we discussed in our first part, the first thing we need to do is, setting up the systickk timer.

Systickk timer configuration:Cortex M3 Systick

LOAD register: This is the register which is used to store the number of ticks to generate the interrupt.

CTRL register:Here,

Most LSB bit is for enabling the timer

The next bit is for causing the interrupt when the load register get empty by decrementing tick by tick.

Next bit is for selecting the clock frequency.

In _ms_delay function we are calling the function SETUP_Systickk which will configure the Systickk timer. And then we just need to wait until the flag variable get positive value.

Here, for every 20nsec interrupt occurs and then control goes to Systickk_Handler function in which current time variable get incremented.

Until flag the value get changed this interrupt keep on occurs for our selected clock frequency. Once we reached the limit, then the flag value get changed and then we are disabling the Systickk timer.

Please guys comment to help others to understand this post more easily, please check here for more embedded related posts.

Related posts:

About author

This article was written by admin

Admin has over twenty years experience in the electronics industry, largely dedicated to embedded software. A frequent presenter at conferences and seminars and author of numerous technical articles. Working presently as Development Manager in India. A firm Believer in Knowledge grows when it shared.


Comments (2)
  1. henrylaredo says - Posted: February 26, 2013

    very clear example! well done Friend!

  2. vinay says - Posted: August 3, 2013

    Hi one basic question! its say in ARM CM3 guide that systick interrupt is async! i still didnt get why interrupt when systick logic works on system clk!! it should come sync with clk! could you please explain this?!

Leave your comment

Your email address will not be published. Required fields are marked *