SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: SysTick interrupt doesn’t trigger (Arm Cortex M0)
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

SysTick interrupt doesn’t trigger (Arm Cortex M0)

Neil Salmon
Last updated: October 5, 2023 9:58 am
Neil Salmon 7 Min Read
Share
SHARE

The SysTick interrupt not triggering on an ARM Cortex M0 microcontroller is often caused by improper configuration of the SysTick registers or failing to enable SysTick interrupts. The SysTick timer is a simple countdown timer built into the Cortex M0 that can generate periodic interrupts for operating system or task scheduling. This article will guide you through troubleshooting and solving the issue of the SysTick interrupt not firing.

Contents
Overview of the SysTick TimerSteps to Enable the SysTick TimerCommon Mistakes Preventing Interrupt GenerationHandler/ISR TroubleshootingScope Capture for DebuggingSoftware BreakpointsPeripheral Register AccessOS Configuration IssuesSummary

Overview of the SysTick Timer

The SysTick timer is a 24-bit countdown timer that is integrated into all Cortex M0 cores. It has several key registers that control its operation:

  • SYST_CSR – Control and status register
  • SYST_RVR – Reload value register
  • SYST_CVR – Current value register

To generate periodic interrupts, the SYST_RVR is loaded with a reload value. This value is copied to the SYST_CVR register which then counts down to 0. When it reaches 0, it triggers the SysTick interrupt and reloads the SYST_RVR value to start again.

The SYST_CSR register controls enabling the counter, interrupt, and clock source. Bits can be set to enable interrupts, use the internal processor clock, and start the timer counting down.

Steps to Enable the SysTick Timer

To properly enable SysTick interrupts, follow these steps:

  1. Load the SYST_RVR register with your desired reload value. This sets the period of the timer.
  2. Set the SYST_CVR register to the same value as SYST_RVR to initialize it.
  3. Set the CLKSOURCE bit in SYST_CSR to use the processor clock.
  4. Set the TICKINT bit in SYST_CSR to enable SysTick interrupts.
  5. Set the ENABLE bit in SYST_CSR to start the timer.

Once enabled, the SysTick timer will decrement the CVR register until it reaches 0, then reload the RVR value and generate a SysTick interrupt if enabled. The interrupt can call an interrupt service routine to execute periodic code.

Common Mistakes Preventing Interrupt Generation

There are a few common configuration errors that could result in the SysTick interrupt not firing properly:

  • Forgetting to enable SysTick interrupts in the SYST_CSR register
  • Failing to set up the interrupt handler/ISR in your code
  • Setting the wrong clock source – should be processor clock, not external reference clock
  • Not starting the timer by setting the ENABLE bit
  • Setting a reload value of 0, which disables the timer

Always carefully check your SysTick initialization code against the steps outlined earlier. Enable interrupts in the SYST_CSR register, set up an interrupt handler, use the processor clock, and start the timer.

Handler/ISR Troubleshooting

If the SysTick configuration registers are set up properly but you still don’t get an interrupt, the problem may be with how the interrupt handler is set up in code.

Be sure to:

  • Define an ISR/handler function for the SysTick interrupt
  • Specify the correct IRQ number for SysTick in the microcontroller’s NVIC
  • Enable the SysTick IRQ line in the NVIC
  • Set the correct priority if using priorities

On Cortex M0, the SysTick IRQ number is IRQ #15. Make sure your handler function is being linked correctly and that the interrupt line is enabled and prioritized properly in the nested vectored interrupt controller (NVIC) settings.

Scope Capture for Debugging

One good way to debug the issue is to capture the SysTick registers right when an interrupt should occur using a scope or logic analyzer. This can reveal:

  • If the CVR register is counting down properly
  • If the interrupt actually signals when CVR hits 0
  • Any discrepancy between CVR and RVR values

Monitor the ENABLE bit to see if the timer stops prematurely. Check that it reloads CVR with RVR when the counter expires. This can help identify any incorrect behavior or register values.

Software Breakpoints

Set a breakpoint at the first line of your SysTick_Handler() ISR function. If code execution never hits it, then the processor is not actually entering the ISR when SysTick expires. This indicates an issue generating the interrupt request.

You can also set a breakpoint in the startup code that enables interrupts globally to ensure it is executing. Comment out portions of your handler code to isolate any faults.

Peripheral Register Access

One other cause could be invalid access to SysTick registers from software. Make sure your code properly accesses the SysTick registers in the core peripheral memory map. Confirm it is using the correct bus, clock speeds, and any peripheral libraries provided by the vendor.

Attempting to access insecure registers without the proper bus control can fail to modify SysTick settings. Check your initialization and configuration code carefully for any invalid register writes.

OS Configuration Issues

If you are using an RTOS or operating system, make sure SysTick is not reserved for use by the OS scheduler. The OS configuration may need to be modified to allow application access to SysTick.

Look for any OS hooks into the SysTick_Handler. The OS may override application interrupt handlers or block access to system timers like SysTick that it relies on.

Summary

In summary, getting the SysTick interrupt to trigger properly requires:

  • Correct configuration of the SYST_CSR, SYST_RVR, and SYST_CVR registers
  • Enabling SysTick interrupts in SYST_CSR
  • Defining and linking the SysTick_Handler() ISR
  • Proper NVIC vector table setup
  • No OS reservation of the SysTick timer
  • Valid software access to SysTick registers

Carefully go through each step outlined here to identify and correct any potential issues. Double check OS and peripheral library integration. Leverage debugging techniques like register capture and breakpoints to gain visibility. With consistent configuration and integration, getting periodic SysTick interrupts running properly on Cortex M0 is usually manageable.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article ARM Cortex Reset Button and Debug Interface (SWD)
Next Article ARM Cortex M0 Interrupts not working
Leave a comment Leave a comment

Leave a Reply Cancel reply

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

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

What is the bus interface in the Cortex-M3 processor?

The bus interface in the Cortex-M3 processor provides the connection…

8 Min Read

What is the difference between ARM and x64 assembly?

ARM and x64 refer to two different instruction set architectures…

10 Min Read

ARM Cortex M0 vs Arduino

ARM Cortex M0 and Arduino are both popular microcontroller platforms…

8 Min Read

ARM Cortex M NonMaskable Interrupt is NonClearable also?

The short answer is yes, the NonMaskable Interrupt (NMI) on…

7 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account