LPTIM3 配置如下:
static void MX_LPTIM3_Init(void)
{
/* USER CODE BEGIN LPTIM3_Init 0 */
/* USER CODE END LPTIM3_Init 0 */
/* USER CODE BEGIN LPTIM3_Init 1 */
/* USER CODE END LPTIM3_Init 1 */
hlptim3.Instance = LPTIM3;
hlptim3.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC;
hlptim3.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1;
hlptim3.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE;
hlptim3.Init.Period = 99;
hlptim3.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE;
hlptim3.Init.CounterSource = LPTIM_COUNTERSOURCE_INTERNAL;
hlptim3.Init.Input1Source = LPTIM_INPUT1SOURCE_GPIO;
hlptim3.Init.Input2Source = LPTIM_INPUT2SOURCE_GPIO;
hlptim3.Init.RepetitionCounter = 0;
if (HAL_LPTIM_Init(&hlptim3) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN LPTIM3_Init 2 */
/* USER CODE END LPTIM3_Init 2 */
}
启动 LPTIM3 :
if (HAL_LPTIM_TimeOut_Start_IT(&hlptim3, TIMEOUT) != HAL_OK)
{
Error_Handler();
}
|