Keil Logo

ARM: SysTick system timer does not generate interrupts


Information in this knowledgebase article applies to:

  • MDK-ARM any version
  • Cortex-M processor series
  • CMSIS-Core

SYMPTOM

I am verifying the clock setup of my system and it appears that the SysTick system timer does not work. I have created the following program to verify that:

volatile uint32_t ticks;

void SysTick_Handler (void) {
  ticks++;
}

int main (void) {
  SystemCoreClockUpdate();
  SysTick_Config(SystemCoreClock/100);      /* Generate interrupt each 10 ms  */
  while (1);
}

When I set a breakpoint to the SysTick_Handler function using the debugger, I can see that this never got called. What could be the reason for that?

CAUSE

There can be several reasons for that.

  • Some devices or processor cores do not implement a SysTick system timer. Check that your device has actually a SysTick_Handler
  • The SysTick timer may use an external clock source that is inactive. Verify the value in the SysTick CTRL register.
  • The exception vector for the SysTick_Handler is incorrect.

RESOLUTION

A potential solution is to change the CMSIS-CORE SysTick_Init function as shown below:

void SysTick_Init(void) {
    SysTick->CTRL = 0;
    systicks = 0;
    SysTick->VAL = 0; /* Load the SysTick Counter Value */
    SysTick->CTRL = (SysTick_CTRL_TICKINT_Msk   |  /* Enable SysTick exception */
                     SysTick_CTRL_ENABLE_Msk) |    /* Enable SysTick system timer */
                     SysTick_CTRL_CLKSOURCE_Msk;   /* Use processor clock source */
}

MORE INFORMATION

SEE ALSO

Last Reviewed: Wednesday, January 25, 2017


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.