user82375897897928347
user82375897897928347

Reputation: 95

Cortex-M3 - SysTick NVIC Disable - Energy Saving FreeRTOS

I use FreeRTOS on a EFM32GG380F1024. The Cortex-M SysTick is used for the RTOS tick. The low-energy RTC (BURTC) is used during sleep to generate timed wakeup calls. Energy Mode is EM3 (Just Ultra-Low-Frequency still operating).

As soon as FreeRTOS calls me with the suppressTicksAndSleep callback, I do as follows:

  1. Enter Critical Section (Globally disable IRQs) with the call __disable_irq().
  2. Disable (at least I try; won't work currently) the SysTick interrupt with the call to the register SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;.
  3. Setup and start the low-energy RTC (BURTC).
  4. Enter EM3.

The problem is that just after the energy mode entrance, the SysTick interrupt kicks in an wakes the device. This should not be possible because the Energy Mode 3 disables HF and LF clocks, so the Systick counter should not even increment.

Why is this not suspending the SysTick correctly?

NB: Below is a screenshot of my tracealyzer:

https://i.sstatic.net/c6CUO.jpg

Upvotes: 1

Views: 4584

Answers (1)

JimmyB
JimmyB

Reputation: 12620

SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk

You are not clearing any bits in CTRL. That line should probably be like

SysTick->CTRL &= ~(SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk)

to clear all bits for CLKSOURCE and ENABLE.

Upvotes: 5

Related Questions