Skip to content

[Bug]: FW V1.9.0 regression in LPTIM setup #77

Description

@morse-evanbenn

Bug Summary

LPTIM1 init hangs at LL_LPTIM_IsActiveFlag_DIEROK(LPTIM1) after update to 1.9.0

Detailed Description

I have some user code after generated LPTIM1_Init:

static void MX_LPTIM1_Init(void)
{

  /* USER CODE BEGIN LPTIM1_Init 0 */

  /* USER CODE END LPTIM1_Init 0 */

  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};

  /** Initializes the peripherals clock
  */
  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPTIM1;
  PeriphClkInit.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_LSI;
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  {
    Error_Handler();
  }

  /* Peripheral clock enable */
  LL_APB3_GRP1_EnableClock(LL_APB3_GRP1_PERIPH_LPTIM1);

  /* USER CODE BEGIN LPTIM1_Init 1 */

  /* USER CODE END LPTIM1_Init 1 */
  LL_LPTIM_Enable(LPTIM1);
  LL_LPTIM_ClearFlag_REPOK(LPTIM1);
  LL_LPTIM_SetRepetition(LPTIM1, 0);

   /* Wait till REPOK Flag is ready */
  while(!LL_LPTIM_IsActiveFlag_REPOK(LPTIM1))
  {
  }
  LL_LPTIM_ClearFlag_ARROK(LPTIM1);
  LL_LPTIM_SetAutoReload(LPTIM1, 65535);

   /* Wait till ARROK Flag is ready */
  while(!LL_LPTIM_IsActiveFlag_ARROK(LPTIM1))
  {
  }
  LL_LPTIM_Disable(LPTIM1);
  LL_LPTIM_SetClockSource(LPTIM1, LL_LPTIM_CLK_SOURCE_INTERNAL);
  LL_LPTIM_SetPrescaler(LPTIM1, LL_LPTIM_PRESCALER_DIV1);
  LL_LPTIM_SetUpdateMode(LPTIM1, LL_LPTIM_UPDATE_MODE_IMMEDIATE);
  LL_LPTIM_SetCounterMode(LPTIM1, LL_LPTIM_COUNTER_MODE_INTERNAL);
  LL_LPTIM_TrigSw(LPTIM1);
  LL_LPTIM_SetInput1Src(LPTIM1, LL_LPTIM_INPUT1_SRC_GPIO);
  LL_LPTIM_SetInput2Src(LPTIM1, LL_LPTIM_INPUT2_SRC_GPIO);
  /* USER CODE BEGIN LPTIM1_Init 2 */

  LL_LPTIM_Enable(LPTIM1);

  LL_LPTIM_ClearFlag_DIEROK(LPTIM1);
  LL_LPTIM_EnableIT_CC1(LPTIM1);
  while (!LL_LPTIM_IsActiveFlag_DIEROK(LPTIM1))
  {
  }
  LL_LPTIM_StartCounter(LPTIM1, LL_LPTIM_OPERATING_MODE_CONTINUOUS);

  /* Enable LPTIM1 autonomous mode to wake up from stop modes. */
  LL_SRDAMR_GRP1_EnableAutonomousClock(LL_SRDAMR_GRP1_PERIPH_LPTIM1AMEN);

  /* USER CODE END LPTIM1_Init 2 */

}

After updating from FW 1.8.0 to FW 1.9.0 this code hangs at the LL_LPTIM_IsActiveFlag_DIEROK while loop. I am unclear what has changed between those versions. I see there was a change to the LL_LPTIM_Disable function: STMicroelectronics/stm32u5xx-hal-driver@4ef3465

If I add a HAL_Delay(1) after LL_LPTIM_Enable it seems to work. Is that sufficient? I was unable to find a similar delay in the HAL_LPTIM implementation so I am not sure why it would be required here.

Attached a minimal ioc file repro for U585, note the LPTIM uses a slow LSI clock and the HCLK is high - without those changes I do not reproduce the hang.

lptim_repro.zip

Expected Behavior

no hang

Actual Behavior

hang

Environment

No response

Severity

None

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghalHAL-LL driver-related issue or pull-request.internal bug trackerIssue confirmed and logged into the internal bug tracking systemlptimLow-Power Timer

Type

Projects

Status
Analyzed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions