cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L151 Turn Pin to High state in stanby mode

Hoang Loc
Associate II

Hi Community. In my project, I use stanby mode with RCT interrupt to wake up to save power. Although I set all pin to Ananog In, the pin is still go to logic high after chip go to stanby mode. That make Bust Power IC is turn on. Please help me. I am new in with STM32L serial chip

I use this function for stanby mode: PWR_EnterSTANDBYMode.

4 REPLIES 4
Mohamed Aymen HZAMI
ST Employee

Hello Hoang,

Can you please share your code to try to solve your problem !

Best Regards,

Mohamed Aymen.

No, I am find solution for this. I change to Stop mode use LSI but stm32 can't wake up. I don't know why.

Mohamed Aymen HZAMI
ST Employee

Hello Hoang,

Are you using the RTC as wake up source ?

Regards,

Mohamed Aymen.

Yes, this mode is defined: STANDBY_RTC_LSI_MODE

This is example code I used for my project.

#elif defined (STANDBY_RTC_LSI_MODE)
void StandbyRTCLSIMode_Measure(void)
{
	 NVIC_InitTypeDef  NVIC_InitStructure;
	/* Enable GPIOs clock */
	  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC, ENABLE);
	/* Configure the LED_pin as output push-pull for LD3 & LD4 usage*/
	    GPIO_InitStructure.GPIO_Pin = LD_GREEN_GPIO_PIN | LD_BLUE_GPIO_PIN;
	    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
	    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
	    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
	    GPIO_Init(LD_GPIO_PORT, &GPIO_InitStructure);
 
	    /* Force a low level on LEDs*/
	    GPIO_LOW(LD_GPIO_PORT,LD_GREEN_GPIO_PIN);
	    GPIO_LOW(LD_GPIO_PORT,LD_BLUE_GPIO_PIN);
	//  /* Wait Until Key button pressed */
 
	    /* Enable the RTC Wakeup Interrupt */
	      NVIC_InitStructure.NVIC_IRQChannel = RTC_WKUP_IRQn;
	      NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
	      NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
	      NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	      NVIC_Init(&NVIC_InitStructure);
  /* Allow access to RTC */
  PWR_RTCAccessCmd(ENABLE);
 
  /*!< LSI Enable */
  RCC_LSICmd(ENABLE);
 
  /*!< Wait till LSI is ready */
  while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
  {}
 
  /*!< RTC Clock Source Selection */
  RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
 
  /* Enable the RTC Clock */
  RCC_RTCCLKCmd(ENABLE);
 
  /* Wait for RTC APB registers synchronisation */
  RTC_WaitForSynchro();  
 
  /* Enable Ultra low power mode */
  PWR_UltraLowPowerCmd(ENABLE);
 
  /* RTC Wakeup Interrupt Generation: Clock Source: RTCCLK_Div16, Wakeup Time Base: ~4s 
     RTC Clock Source LSI ~37KHz  
  */
  RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16);
  RTC_SetWakeUpCounter(0x2421);
 
  /* Clear PWR WakeUp flag */
  PWR_ClearFlag(PWR_FLAG_WU);
  
  /* Clear RTC WakeUp (WUTF) flag */
  RTC_ClearFlag(RTC_FLAG_WUTF);
 
  /* Enable the Wakeup Interrupt */
  RTC_ITConfig(RTC_IT_WUT, ENABLE);
 
  /* Enable Wakeup Counter */
  RTC_WakeUpCmd(ENABLE); 
 
  /* Request to enter STANDBY mode */
  PWR_EnterSTANDBYMode();
  
  /* Infinite loop */
  while (1)
  {
	  /* Toggle The LED1 */
	 	  GPIO_TOGGLE(LD_GPIO_PORT,LD_GREEN_GPIO_PIN);
 
	     /* Inserted Delay */
	     for(index = 0; index < 0x5FF; index++);
  }
}

Now, I change to STOP_RTC_LSI_MODE, but I won't better. because I deal with other problem here. I actually got stuck with this. I used MSP430 TI chip before, I work exactly as the code reference.

I have STM32L152c-discovery kit. In the reference design, ST use pin PA.0 to wake up source, that why I can test in real project use RTC wake up source.