cancel
Showing results for 
Search instead for 
Did you mean: 

STOP mode and STM32L152~ 440 uA

JAN R
Associate III

Dear,

I have Nucelo board with STM32L152RE. I have just made a simple project with CubeMX:

After reset - blink 5 times by LED and then go to STOP mode. After pushing a button repeat whole proces again and again. Button is on EXTI13.

My problem is that power consumption is about 440 uA and I can not reach better results. (MY nucleo is in original state - no external parts are connected).

My SYSCLK is MSI with 2.097 MHz

Can you help me with power consumption please?

Thank you very much. Jan.

int main(void)
{
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
 
  while (1)
  {
	  for(uint8_t i=0;i<5;i++)
	  {
		  LL_GPIO_TogglePin(LD2_GPIO_Port,LD2_Pin);
		  LL_mDelay(200);
	  }
          
        /* disable Systick timer */
	  SysTick->CTRL  &=~ SysTick_CTRL_ENABLE_Msk;
        
         /*Set all pins as analog*/
	  LL_GPIO_InitTypeDef gpio_initstruct = {LL_GPIO_PIN_ALL, LL_GPIO_MODE_ANALOG,
				          LL_GPIO_SPEED_FREQ_HIGH, LL_GPIO_OUTPUT_PUSHPULL,
				                                         LL_GPIO_PULL_NO, LL_GPIO_AF_0};
 
	  LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA |
			                            LL_AHB1_GRP1_PERIPH_GPIOB |
			                          //  LL_AHB1_GRP1_PERIPH_GPIOC |     
			                            LL_AHB1_GRP1_PERIPH_GPIOD |
			                            LL_AHB1_GRP1_PERIPH_GPIOE |
			                            LL_AHB1_GRP1_PERIPH_GPIOF |
			                            LL_AHB1_GRP1_PERIPH_GPIOG |
			                            LL_AHB1_GRP1_PERIPH_GPIOH);
 
			   LL_GPIO_Init(GPIOA, &gpio_initstruct);
			   LL_GPIO_Init(GPIOB, &gpio_initstruct);
			  // LL_GPIO_Init(GPIOC, &gpio_initstruct); /* because of EXTI - button to wakeup*/
			   LL_GPIO_Init(GPIOD, &gpio_initstruct);
			   LL_GPIO_Init(GPIOE, &gpio_initstruct);
			   LL_GPIO_Init(GPIOF, &gpio_initstruct);
			   LL_GPIO_Init(GPIOG, &gpio_initstruct);
			   LL_GPIO_Init(GPIOH, &gpio_initstruct);
 
			   LL_AHB1_GRP1_DisableClock(LL_AHB1_GRP1_PERIPH_GPIOA |
			                            LL_AHB1_GRP1_PERIPH_GPIOB |
			                          //  LL_AHB1_GRP1_PERIPH_GPIOC | /* because of EXTI - button to wakeup*/
			                            LL_AHB1_GRP1_PERIPH_GPIOD |
			                            LL_AHB1_GRP1_PERIPH_GPIOE |
			                            LL_AHB1_GRP1_PERIPH_GPIOF |
			                            LL_AHB1_GRP1_PERIPH_GPIOG |
			                            LL_AHB1_GRP1_PERIPH_GPIOH);
 
		 /* Enable Power Clock */
		LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
 
		LL_PWR_EnableUltraLowPower();
 
		LL_PWR_SetRegulModeLP(LL_PWR_REGU_LPMODES_LOW_POWER);
 
		LL_PWR_SetPowerMode(LL_PWR_MODE_STOP);
 
		LL_LPM_EnableDeepSleep();
		
                __WFI();
	
                //HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI);
	       
                /*enable Systick after wakeup*/
                 SysTick->CTRL  |= SysTick_CTRL_ENABLE_Msk;
              
	         MX_GPIO_Init();
       }
  }

2 REPLIES 2
RN
Senior

try with analog mode for all the unused GPIOC pins.

JAN R
Associate III

Thank you, but I tried it, Every single pin is set as Analog....