2025-10-13 11:12 AM - last edited on 2025-10-14 12:37 AM by Imen.D
Hello everyone,
I have a problem with my STM32L011G4U6, I want to put it in stop mode or in standby mode, but the two modes are not taken into account, only the sleep mode works, I must surely make a mistake but where? here is my function:
void Enter_MCU_Sleep(void) {
HAL_Delay(1000);
HAL_UART_Transmit(&huart2, (uint8_t *)"Dort\r\n", 33, 300);
// Configurer et lancer le timer
__HAL_TIM_SET_COUNTER(&htim2, 0);
HAL_TIM_Base_Start_IT(&htim2); // Timer doit générer une IT de réveil
// Désactiver les périphériques pour réduire la consommation
//HAL_ADC_DeInit(&hadc);
HAL_UART_DeInit(&hlpuart1);
HAL_UART_DeInit(&huart2);
//__HAL_RCC_ADC1_CLK_DISABLE();
__HAL_RCC_LPUART1_CLK_DISABLE();
HAL_NVIC_DisableIRQ(EXTI4_15_IRQn);
HAL_NVIC_DisableIRQ(DMA1_Channel2_3_IRQn);
HAL_NVIC_DisableIRQ(DMA1_Channel4_5_IRQn);
// Désactiver le RTC et l'oscillateur LSE
HAL_RTCEx_DeactivateWakeUpTimer(&hrtc); // Désactiver le wakeup timer
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
__HAL_RCC_RTC_DISABLE(); // Désactiver l'horloge RTC
//__HAL_RCC_USART2_CLK_DISABLE();
__HAL_TIM_CLEAR_FLAG(&htim2, TIM_FLAG_UPDATE);
__HAL_TIM_CLEAR_IT(&htim2, TIM_IT_UPDATE);
// Entrer en STOP mode
HAL_SuspendTick();
//HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI); // ou STOP
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
//HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
//HAL_PWR_EnterSTANDBYMode();
HAL_TIM_Base_Stop_IT(&htim2); // Stopper le timer
HAL_ResumeTick();
// ⚡️ Après STOP
SystemClock_Config(); // Rétablir les clocks
HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);
HAL_NVIC_EnableIRQ(DMA1_Channel2_3_IRQn);
HAL_NVIC_EnableIRQ(DMA1_Channel4_5_IRQn);
// Réinitialiser les périphériques
MX_GPIO_Init();
// MX_ADC_Init();
MX_LPUART1_UART_Init();
// MX_USART2_UART_Init();
HAL_Delay(3000); // Stabilisation modem
HAL_UART_Transmit(&huart2, (uint8_t *)"Réveil\r\n", 23, 300);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET); // PA5 à l'état bas
HAL_Delay(2000); // Attendre 1 seconde
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); // PA5 à l'état haut
//gps_and_battery_task();
//gestion_sms_etat();
//boucle1();
//check_moduleori_ready();
HAL_Delay(1000);
}
2025-10-27 3:08 AM - edited 2025-10-27 3:19 AM
@fanfan6966 wrote:buy a ready-made board from the manufacturer?? What will that do for me?
As explained, it will give you a known-good starting point.
It reduces the number of unknowns - which is always good when when trying to solve a problem.
It will also give a well-known platform - which makes it much easier for complete strangers to help you remotely.
As it stands, you haven't given any details of your custom board at all - so we have no idea what you're running on.
Also, we haven't see the complete code.
How to write your question to maximize your chances to find a solution
@fanfan6966 wrote:If the solution is to buy a ready-made product, then we must stop all DIY initiatives, and consume like sheep.
No, that is not the solution.
Nobody suggested that it would be the solution.
It is just a well tried & tested approach to help identify the problem.
Especially when you are new to the platform.
2025-10-31 12:38 PM - last edited on 2025-11-01 5:07 AM by Andrew Neil
Hello, after testing several examples from the GitHub repository, it's the same; it seems something is preventing the module from sleeping. I added a small display function, and it wakes up in a loop:
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1
Hello World 1