2025-05-22 11:08 PM
Hello,
I'm using LPUART1 (STM32U0) for modbus communication and using STOP2 mode to go sleep until new modbus query has requested.
Strange things happen, on console I can see prints like "Target is not responding, retrying...".
Here is my clock configuration, which I want to reconfirm
And the STOP2 mode logic, here tried to toggle LED after wakeup, but it is observed that sometimes it works and sometimes not. Actually, if I disable function enterLowPowerMode() then everything works fine also no print message on consol (like "Target is not responding, retrying...")
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE2);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
Error_Handler();
}
}
void Scheduler::enterLowPowerMode()
{
HAL_UARTEx_EnableStopMode(&hlpuart1);
HAL_SuspendTick();
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
HAL_ResumeTick();
SystemClock_Config();
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
}
Guide me for the current clock configuration or anything missing to take care while going to STOP2 mode.
Thanks,
Nitin
2025-05-23 3:15 AM
Hello,
It looks like the system is wakeup now, but I didn't do any changes, it's just issue with my python script.
Now I can see during wakeup it takes time to respond to UART, and that is the reason it goes in timeout while Modbus read of particular address read. Once I disable low power mode it works fine, but when enable sometime it success and sometime fails, but it we add timeout for read then it takes time but read successfully.
Now how it can be handled LPUART during wakeup, so that it should work fine.
Thansk,
Nitin