Question
LPTIM -- 50ms debounce measuring 62ms ???
I have a scope and am triggering on the falling edge of a pushbutton. The LED drive signal is being monitored on another scope channel. The LED is to turn on 50ms after the falling edge of the pushbutton but in reality it is 62ms. LPTIM1 is running at LSE with a divider of 32. Can someone explain why I am not seeing 50ms?? The system clock for CPU1 is 64MHz generated from HSE. I currently am not running anything else.
HAL_Delay is used for keeping the LED on for 100ms....this measurement seems to be working just fine.
ISR Code:
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
HAL_LPTIM_OnePulse_Start_IT(&hlptim1, 50, 0);
if (GPIO_Pin == GPIO_PIN_1)
EXTI->IMR1 &= ~EXTI_IMR1_IM0;
}
void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim)
{
if (hlptim == &hlptim1) //debounce timer
{
HAL_LPTIM_OnePulse_Stop_IT(&hlptim1);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, 0); //LED on
if (HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_1) == GPIO_PIN_RESET)
{
EXTI->PR1 |= EXTI_PR1_PIF1; //clear any that came AFTER debounce
EXTI->IMR1 |= EXTI_IMR1_IM1; //enable / unmask
flag = 1;
}
}
}Main code:
while (1)
{
//SystemClock_Decrease();
//HAL_SuspendTick();
//HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);
if (flag != 0)
{
flag = 0;
//HAL_PWREx_DisableLowPowerRunMode();
//SystemClock_Config();
//HAL_ResumeTick();
HAL_Delay(100);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, 1); //LED off
}
/* USER CODE END WHILE */
//MX_APPE_Process();
/* USER CODE BEGIN 3 */
}