STM32N6 Power modes in Zephyr
Cannot wake from Stop mode using LPTIM1
Board: STM32N6570-DK (STM32N657X0, Cortex-M55)
RTOS: Zephyr 4.4.0
Goal: Enter Stop mode and wake periodically via LPTIM1 auto-reload interrupt (~200ms)
What works:
Sleep mode (WFI without SLEEPDEEP) — enters and wakes correctly from GPIO EXTI and LPTIM
LPTIM1 initialization — confirmed running, ISR fires (verified via counter incrementing in HAL_LPTIM_AutoReloadMatchCallback)
LPTIM1 EXTI line 52 enabled — EXTI->IMR2 |= EXTI_IMR2_IM52 via __HAL_LPTIM_LPTIM1_EXTI_ENABLE_IT()
NVIC LPTIM1_IRQn enabled — interrupt registered and working in normal (non-Stop) operation
Clock restore after Stop — SystemClock_Restore() re-enables HSE, PLLs (PLL1/2/3), IC muxes back to 800 MHz
What does NOT work:
Stop mode entry → CPU never wakes. After HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI), the MCU halts permanently. No interrupt wakes it.
LPTIM1 configuration:
__HAL_RCC_LPTIM1_CLK_ENABLE();
// Clock: LSI (~32 kHz)
RCC_PeriphCLKInitTypeDef pclk = {0};
pclk.PeriphClockSelection = RCC_PERIPHCLK_LPTIM1;
pclk.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_LSI;
HAL_RCCEx_PeriphCLKConfig(&pclk);
hlptim1.Instance = LPTIM1;
hlptim1.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC;
hlptim1.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1;
hlptim1.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE;
hlptim1.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE;
hlptim1.Init.CounterSource = LPTIM_COUNTERSOURCE_INTERNAL;
hlptim1.Init.Period = 6399; // ~200ms
HAL_LPTIM_Init(&hlptim1);
// EXTI wakeup line
__HAL_LPTIM_LPTIM1_EXTI_ENABLE_IT(); // EXTI->IMR2 |= IM52
// NVIC
HAL_NVIC_SetPriority(LPTIM1_IRQn, 7, 0);
HAL_NVIC_EnableIRQ(LPTIM1_IRQn);
// Start counter
HAL_LPTIM_Counter_Start_IT(&hlptim1);
Stop mode entry:
HAL_SuspendTick();
HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI);
// Never reaches here
Approaches tried:
Direct HAL call from thread context (video_sleep()) — LPTIM started, then HAL_PWR_EnterSTOPMode. Never wakes.
Via Zephyr PM framework (pm_state_set in idle thread) — same result. PM policy selects state, LPTIM started, Stop entered, never wakes.
HAL_PWR_EnterSLEEPMode instead — works perfectly. Both LPTIM and GPIO wake the CPU. Confirms the NVIC/EXTI path is correct for non-SLEEPDEEP WFI.
Verified EXTI IMR2 bit 52 set before Stop entry.
Verified NVIC LPTIM1_IRQn enabled before Stop entry.
Tried with/without HAL_SuspendTick() — no difference.
LSI confirmed running — LPTIM counter advances (verified by reading CNT register before Stop).
Questions:
On STM32N6, are there additional PWR registers that need to be configured for EXTI line 52 (LPTIM1) to wake from Stop? (e.g., PWR wakeup enable register specific to N6?)
Does LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC keep the LPTIM clocked during Stop, or should we use a different clock source setting?
Is there a known issue with Stop mode wakeup on the STM32N6570-DK with the current STM32Cube HAL v1.0?
Does the STM32N6 require the LPTIM to be in a specific mode (not counter mode) for Stop wakeup? The N6 reference manual mentions "timeout mode" for wakeup — is HAL_LPTIM_TimeOut_Start_IT required instead of HAL_LPTIM_Counter_Start_IT?
Please help.
