Skip to main content
Explorer
April 18, 2025
Question

Issue with starting when power is disconnected from STM32L0

  • April 18, 2025
  • 1 reply
  • 611 views

Hello, 

I am using STM32L0 microcontroller in my device. I put my device in deep sleep and wakeup using the same button by sorting SYS_WAKEUP2 pin and nearby PC14 is used as an Input pin (pulled-up). 

The issue is when I disconnect & reconnect USB power to the my device, it does not start at all. Below I have attached my code and circuit.

SYS_WAKEUP2 pin:

JeetS_0-1744973349809.png

 

BOOT0 & NRST connection:

JeetS_1-1744973395102.png

 

System wakeup pin and connection with button: 

JeetS_2-1744973450395.png

JeetS_3-1744973461618.png

 

Here is my code to go into deep sleep which used for "long press ON":

	if(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_14)== GPIO_PIN_SET)
	{
		// Start the equipment
		HAL_GPIO_WritePin(PERIPHERAL_EN_GPIO_Port, PERIPHERAL_EN_Pin, SET);
		HAL_Delay(20);
		lcd_init();
		ClearLCD();
		StartTick = HAL_GetTick();
		char strr[20];
	 while(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_14)== GPIO_PIN_SET)
	 {
		 FinalTick = HAL_GetTick();
		 TickCount = FinalTick-StartTick;
		 if((TickCount % 1000) == 0)
		 {
 init_columnset(3, 20);
 sprintf(strr,"Wakeup in %u ",PowerOn);
 GLCD_Bold_String(3, &strr);
			 PowerOn++;
		 }
		 if(PowerOn>=5) break;

	 } // end of while loop
	 if(PowerOn<5)
	 {
	 init_columnset(3, 15);
	 GLCD_Bold_String(3, "Shutting Down... ");
	 HAL_Delay(1000);
	 HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2);
	 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
	 HAL_SuspendTick();
	 HAL_PWR_EnterSTANDBYMode();
	 }

	} // end of If condition
	else
	{
		//shutdown
 init_columnset(3, 15);
 GLCD_Bold_String(3, "Shutting Down... ");
 HAL_Delay(1000);
 HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2);
 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
 HAL_SuspendTick();
 HAL_PWR_EnterSTANDBYMode();
	}

 

 

Please help me to solve this issue, Thank you so much for the help.

 

 

    This topic has been closed for replies.

    1 reply

    ST Employee
    April 22, 2025

    Hello @JeetS

    As far as I can see; BOOT0 is pulled down, NRST is pulled up, seems correct! 

    Are you sure of the stability of the power supply? 

    And what do you exactly mean by "it does not start at all", are you having some code to blink an LED or send a msg over UART for example and it's not working as expected? or the your device is not powered at all?