cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L010,in STOP mode 16 uA instead of <1uA

Diego Colombo
Associate III

Hi,

asking help for a behaviour that i was not able to find in previous discussions.

i'm using for the first time this value line microcontroller :

STM32L010K4T6 ,other production details printed on case are GQ20T VG CHN74815.

I im using it on an empty PCB, only mounting the microcontroller,some filter caps on VDD ,RC on reset and 5 pins programming connector,no other components that can be accused of leakages.

The software is minimal,generated with CubeMx,no peripheralor systick interrupt are activated.I use a sooftware delay to have the program running for few seconds,just to read the current changing when STOP mode enters.The code produces on X_NUCLEO_LPM01A board the following measurements:345 uA in RUN and 16,5 uA in STOP.

Forcing all pins in analog mode does not change nothing.My doubt is if i'm actually in STOP mode.I should wake from STOP to verify it,and i'll do it soon.

By now thanks for any hint or link to previous discussions on the same issue.

Diego

Milan,Italy

int main(void)
{
  unsigned int count=1000000;
  HAL_Init();
  SystemClock_Config();
  while(count--);
  Enter_Stop();
  while (1){}
}
void Enter_Stop( void )
{	
	//RCC->IOPENR |= RCC_IOPENR_GPIOAEN;
	RCC->APB1ENR &= ~( RCC_APB1ENR_PWREN );
	DBGMCU->CR  &= ~0x2;
 
	PWR->CR |= PWR_CR_FWU | PWR_CR_ULP | PWR_CR_LPSDSR;
	/* Prepare to enter stop mode */
	PWR->CR &= ~( PWR_CR_PDDS ); // Enter stop mode when the CPU enters deepsleep
	RCC->CFGR |= RCC_CFGR_STOPWUCK; // HSI16 oscillator is wake-up from stop clock
	SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; // low-power mode = stop mode
	__disable_irq();
 
	I2C1->CR1 &= ~I2C_CR1_PE;  // Address issue 2.5.1 in Errata
	__WFI(); // enter low-power mode
}

1 REPLY 1
Diego Colombo
Associate III

Solved,but nont completely understood.I did 1 error at least

I had a look in the Hal function HAL_PWR_EnterSTOPMode

Calling it instead the one i used(adapted from an example found on a website) i obtained a reduption of consumptions,7 uA instead of 16.

Comparing i noticed that RCC->APB1ENR &= ~( RCC_APB1ENR_PWREN ); increases the current about 13 uA,very strange because it sounds like something that should turn off some power,but actually it is the clock of the power interface,so,if not previously enabled: RCC->APB1ENR |=( RCC_APB1ENR_PWREN );

Then at first glance appeared that the PWR->CR register was at first copied in a variable where bits are modified,and so i did.This is the function i used,with some add for my specific circuit,it drains 390 nA,

void Enter_Stop( void )
{
	  /* Enable Clocks */
 
	volatile uint32_t temp,tmpreg=0;
	RCC->IOPENR |= RCC_IOPENR_GPIOAEN |RCC_IOPENR_GPIOBEN;
	RCC->APB1ENR |=( RCC_APB1ENR_PWREN );//aggiunge consumo,14ua
 
 
	temp= ( GPIO_MODER_MODE15_Msk  | GPIO_MODER_MODE5_Msk );
	GPIOA->MODER |= temp; // PA0 is in Input mode
	temp= ( GPIO_MODER_MODE5_Msk | GPIO_MODER_MODE4_Msk | 
               GPIO_MODER_MODE3_Msk );
	GPIOB->MODER |= temp; // PA0 is in Input mode
	RCC->IOPENR &= ~ (RCC_IOPENR_GPIOAEN  | RCC_IOPENR_GPIOBEN);
	EXTI->IMR |= EXTI_IMR_IM6; // interrupt request from line 6 not masked
	EXTI->RTSR |= EXTI_FTSR_TR6; //falling trigger enabled for input line 0
 
	// Enable interrupt in the NVIC
	NVIC_EnableIRQ( EXTI4_15_IRQn );
	NVIC_SetPriority( EXTI4_15_IRQn, MY_PRIORITY );
 
	//DBGMCU->CR  &= ~0x2;
 
	tmpreg = PWR->CR;
	CLEAR_BIT(tmpreg, (PWR_CR_PDDS | PWR_CR_LPSDSR));
 
	 /* Set LPSDSR bit according to PWR_Regulator value */
	 SET_BIT(tmpreg, PWR_LOWPOWERREGULATOR_ON | PWR_CR_ULP);
 
	  /* Store the new value */
         PWR->CR = tmpreg;
 
	
	//RCC->CFGR |= RCC_CFGR_STOPWUCK; // HSI16 oscillator is wake-up from stop clock
	SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; // low-power mode = stop mode
	//__disable_irq();
 
	//Idd_SaveContext();
	//I2C1->CR1 &= ~I2C_CR1_PE;  // Address issue 2.5.1 in Errata
	__WFI(); // enter low-power mode
}