2023-02-14 09:34 PM
2023-06-27 08:52 PM
Hi,
Finally, I tested and confirmed that the problem was caused by the clock frequency lower than the signal to be counted. I changed the clock from LSE to HSE. It is working now.
W.K. Tam
2023-02-17 02:39 AM
Hello @W.K. Tam,
Please share as more details as possible to help you solve your issue.
Try read out and check the LPTIM1 registers and share the result.
Imen
2023-02-19 10:18 PM
Hi Imen,
Thanks for your response.
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure LSE Drive Capability
*/
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
/** Configure the main internal regulator output voltage
*/
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS_PWR;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
// RCC_OscInitStruct.LSIDiv = RCC_LSI_DIV1;
RCC_OscInitStruct.HSEDiv = RCC_HSE_DIV1;
// RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Configure the SYSCLKSource, HCLK, PCLK1 and PCLK2 clocks dividers
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK3|RCC_CLOCKTYPE_HCLK
|RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1
|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.AHBCLK3Divider = RCC_SYSCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
Error_Handler();
}
}
After I commented the following section of code in function HAL_LPTIM_Counter_Start of stm32wlxx_hal_iptim.c, it works.
/* Wait for the completion of the write operation to the LPTIM_ARR register */
// if (LPTIM_WaitForFlag(hlptim, LPTIM_FLAG_ARROK) == HAL_TIMEOUT)
// {
// return HAL_TIMEOUT;
// }
I am not sure whether it has any hidden issues with the code commented.
W.K. Tam
2023-02-20 11:26 AM
Hi @W.K. Tam,
Please check if the time internal clock is missing for LPTIM1.
Maybe you have similar issue that reported on github:
Imen
2023-06-27 12:22 AM
Hi @Imen.D
Thanks for your reply. I did try to follow recommendation stated in the github but failed. I keep commenting the section of code as stated in my previous message for continuing our development works. Anyway, it may have unexpected issues for doing that. I need to solve the problem. I would like to check with you whether the LPTIM clock source should be higher frequency than the external trigger signal. As I use LSE 32.768 kHz as the clock source of LPTIM1, the signal to be count is 339 kHz. Is it the cause of problem ? Thanks.
Kind regards,
W.K. Tam
2023-06-27 08:52 PM
Hi,
Finally, I tested and confirmed that the problem was caused by the clock frequency lower than the signal to be counted. I changed the clock from LSE to HSE. It is working now.
W.K. Tam