Skip to main content
MVanb.1
Associate II
April 3, 2020
Question

LPTIM1 not running

  • April 3, 2020
  • 4 replies
  • 1387 views

Hello,

I'm using the STM32H750VB and want to use the LPTIM1 to wakeup for CSTOP.

But i'm not able to let the LPTIM1 run.

Code:

  SysInt_RegisterIsr(WAKEUP_PIN_IRQn, WakeUpPinInterrupt);

  SysInt_SetPriority(WAKEUP_PIN_IRQn, 1, 0);

  SysInt_EnableIsr(WAKEUP_PIN_IRQn);

  SysInt_RegisterIsr(LPTIM1_IRQn, LowPowerTimerInterupt);

  SysInt_SetPriority(LPTIM1_IRQn, 0, 0);

  SysInt_EnableIsr(LPTIM1_IRQn);

  LSI_ClockEnable();

  /* ### - 1 - Re-target the LSI to Clock the LPTIM Counter ################# */

  /* Select the LSI clock as LPTIM peripheral clock */

  RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPTIM1;

  RCC_PeriphCLKInitStruct.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_LSI;

  HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct);

  LptimHandle.Instance = LPTIM1;

  LptimHandle.Init.Clock.Source    = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC;

  LptimHandle.Init.Clock.Prescaler  = LPTIM_PRESCALER_DIV16;

  LptimHandle.Init.Trigger.Source   = LPTIM_TRIGSOURCE_0;

  LptimHandle.Init.Trigger.ActiveEdge = LPTIM_ACTIVEEDGE_RISING;

  LptimHandle.Init.CounterSource   = LPTIM_COUNTERSOURCE_INTERNAL;

  LptimHandle.Init.Input1Source    = LPTIM_INPUT1SOURCE_GPIO;

  LptimHandle.Init.Input2Source    = LPTIM_INPUT2SOURCE_GPIO;

  /* Initialize LPTIM peripheral according to the passed parameters */

  HAL_LPTIM_Init(&LptimHandle);

  /* Period = 65535

  * Pulse = 32767

  * According to this configuration (LPTIMER clocked by LSI & compare = 32767,

  * the Timeout period = (compare + 1)/LSI_Frequency = 1s

  */

  HAL_LPTIM_TimeOut_Start_IT(&LptimHandle, 0xFFFF, 0x8000);

This topic has been closed for replies.

4 replies

TDK
April 3, 2020

Enable the clock with __HAL_RCC_LPTIM1_CLK_ENABLE before you use the peripheral.

"If you feel a post has answered your question, please click ""Accept as Solution""."
MVanb.1
MVanb.1Author
Associate II
April 3, 2020

  Hey, thank you for the remark, but i already do this at startup:

/* ## - 1 - Enable LPTIM clock ############################################ */

  __HAL_RCC_LPTIM1_CLK_ENABLE();

  /* ## - 2 - Force & Release the LPTIM Periheral Clock Reset ############### */

  /* Force the LPTIM Periheral Clock Reset */

  __HAL_RCC_LPTIM1_FORCE_RESET();

  /* Release the LPTIM Periheral Clock Reset */

  __HAL_RCC_LPTIM1_RELEASE_RESET();

MVanb.1
MVanb.1Author
Associate II
April 3, 2020

i checked this registers:

ControlFreak
Associate III
August 19, 2020

I had similar issue as that of MVanb.1. TDK's comment helped me a lot. Thanks