2024-06-20 11:16 AM
Hi all,
When I wake up from Standby mode and reinitialize the pins and peripherals, they still don't work. Below is my STBY_SysHwRestore() routine, where I reinitialize clocks, pins and peripherals, but the rest of the code does nothing when they accessing the pins and peripherals. I have looked into the BLE_HeartRate example and copied the CPUcontextSave and CPUcontextRestore from the start up file. What confuses me on the BLE_HeartRate example is that it doesn't need to reinitialize clocks when leaving the standby mode, while on my application it needs, otherwise it get weird behaviour.
QUESTION 1: What is the correct way to reinitialize pins and peripherals when waking up from standby mode?
QUESTION 2: After waking up from standby mode due to a wake-up timer (registered on the hw_timerserver.c module), if I start a task on the sequencer directly from the wake-up timer callback, the CPU hangs for some reason. This stuff is really hard to debug due to the nature of the standby mode. Why is the CPU hanging???
void STBY_SysHwRestore(void)
{
/* USER CODE BEGIN STBY_SysHwRestore_1 */
/* USER CODE END STBY_SysHwRestore_1 */
APPD_Init();
Init_Smps();
Init_Exti();
HAL_Init();
WRITE_REG(SCB->VTOR, STBY_BackupVTOR);
HW_IPCC_Init();
WRITE_REG(IPCC->C1MR, STBY_BackupIpccC1MR);
if( !LL_HSEM_1StepLock( HSEM, CFG_HW_RCC_SEMID ) )
{
LL_RCC_SetClkAfterWakeFromStop(LL_RCC_STOP_WAKEUPCLOCK_HSI);
LL_HSEM_ReleaseLock( HSEM, CFG_HW_RCC_SEMID, 0 );
}
LL_HSEM_ReleaseLock( HSEM, CFG_HW_PWR_STANDBY_SEMID, 0 );
HW_TS_Init(hw_ts_InitMode_Limited, &hrtc);
LL_PWR_EnableSRAM2Retention();
/* USER CODE BEGIN STBY_SysHwRestore_2 */
MX_APPE_Config();
SystemClock_Config();
PeriphCommonClock_Config();
MX_GPIO_Init();
MX_USART1_UART_Init();
/* USER CODE END STBY_SysHwRestore_2 */
return;
}
Solved! Go to Solution.
2024-07-15 02:57 AM
The problem was on file app_debug.c, on routines APPD_EnableCPU2(), APPD_SetCPU2GpioConfig() and APPD_BleDtbCfg(). For some reason CubeMX adds code there that changes the state of your pins, without informing you in any possible way. The icing on the cake is that the code is added under /* USER CODE BEGIN xxxx */ comments which is supposed to be reserved for user code. I couldn't be more grateful to ST for the number of days I spent on this.
2024-06-21 01:02 AM
@STTwo-32 can you help here?
2024-07-15 02:57 AM
The problem was on file app_debug.c, on routines APPD_EnableCPU2(), APPD_SetCPU2GpioConfig() and APPD_BleDtbCfg(). For some reason CubeMX adds code there that changes the state of your pins, without informing you in any possible way. The icing on the cake is that the code is added under /* USER CODE BEGIN xxxx */ comments which is supposed to be reserved for user code. I couldn't be more grateful to ST for the number of days I spent on this.