cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L151 Stop mode power consumption

muhammaduzairafzal45
Associate III
Posted on November 20, 2014 at 12:47

I am trying to get lowest power mode(in stop mode) of STM32L151RB. According to datasheet, power consumption in lowest achievable mode is below 14uA. But I am getting 40uA minimum on my device. I have tried different combination and i have disabled every thing(ADC,USART,Timers,USB,SPI) which i can but i am unable to get anywhere near 14uA. What I am doing wrong ? Only thing which is enable are some IOs which are necessary to keep running my board(like JTAG,Accelerometer interrupt pin,USB detection pin etc).Can anyone guide me please?

Another question ... When I declare JTAG pins(PA.13,PA.14) as AN_Input to lower power consumption,code hangs after executing those line. I have seen many codes which declare JTAG pins as input whch means it's normal to change AF of those pins.Why my code hangs after making those pins as analog input?

ADC_Channel_Init(DISABLE);

ADC_StopConversion();

RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, DISABLE); 

USART_Cmd(USART1, DISABLE);

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, DISABLE); 

USART_Cmd(USART2, DISABLE);

/* DisableSPI1 */

RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, DISABLE); 

SPI_Cmd(SPI1, DISABLE);

/* Disable SPI2 */

RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, DISABLE); 

SPI_Cmd(SPI2, DISABLE);

Timer_Init(Timer2,DISABLE);

Timer_Init(Timer3,DISABLE);

//Power off USB

PowerOff();

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, DISABLE);

NVIC_InitStructure.NVIC_IRQChannel = USB_LP_IRQn;

NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;

NVIC_Init(&NVIC_InitStructure);

Delay_ms(500);

/* To stop the sys tick for avoid IT */

SysTick->CTRL = 0;

SysTick->CTRL  &= ~SysTick_CTRL_TICKINT_Msk;        // systick IRQ off

//////////////////////////////// Enaabling STM32L deep sleep mode

PWR_FastWakeUpCmd(DISABLE);

// Disable PVD 

PWR_PVDCmd(DISABLE);

// Enable Ultra low power mode 

 PWR_UltraLowPowerCmd(ENABLE);

// Disable FLASH during SLeep  

FLASH_SLEEPPowerDownCmd(ENABLE);

// Enable the PWR APB1 Clock 

RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

// Configure the MSI frequency 

RCC_MSIRangeConfig(RCC_ICSCR_MSIRANGE_0);

// Select MSI as system clock source 

RCC_SYSCLKConfig(RCC_SYSCLKSource_MSI);

// Wait until MSI is used as system clock source 

while (RCC_GetSYSCLKSource() != 0x00);

// Select the Voltage Range 3 (1.2V) 

PWR_VoltageScalingConfig(PWR_VoltageScaling_Range3);

// Wait Until the Voltage Regulator is ready 

while (PWR_GetFlagStatus(PWR_FLAG_VOS) != RESET);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC | RCC_AHBPeriph_GPIOD, ENABLE);

GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;

GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_InitStructure.GPIO_Speed = GPIO_CLOCK_SPEED;

GPIO_Init(GPIOD, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;

GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_InitStructure.GPIO_Speed = GPIO_CLOCK_SPEED;

GPIO_Init(GPIOB, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11/* | GPIO_Pin_12 */| GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;

GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_InitStructure.GPIO_Speed = GPIO_CLOCK_SPEED;

GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 |GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 /*| GPIO_Pin_11 | GPIO_Pin_12 *//*| GPIO_Pin_13 | GPIO_Pin_14 */| GPIO_Pin_15;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;

GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_InitStructure.GPIO_Speed = GPIO_CLOCK_SPEED;

GPIO_Init(GPIOA, &GPIO_InitStructure);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, DISABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC | RCC_AHBPeriph_GPIOD | RCC_AHBPeriph_GPIOH, DISABLE);

#stm32 #stm32l #power #stop-mode
5 REPLIES 5
stm322399
Senior
Posted on November 20, 2014 at 14:39

At 40µa you are very near to the target, and it proves that you have no major mistakes in GPIO config (I did not check in details).

I did the same, and won the very last µA by configuring RI_HYSCRx registers to disable Schmitt trigger of all ports. This could be what miss you.

--

laurent

chen
Associate II
Posted on November 20, 2014 at 16:04

Hi

You should also disconnect the debugger when you make the measurement.

It can add spurious current or load.

muhammaduzairafzal45
Associate III
Posted on November 21, 2014 at 05:31

Thanks for replying. 

Yes you are right about disconnecting debugger. I had already removed debugger. With debugger around 200uA is consumed and after removing it,current goes to 40uA. I will also check RI_HYSCRx. Is it possible thant the JTAG pins are also drawing current. Why cannot I configure them as Analog input?

chen
Associate II
Posted on November 21, 2014 at 12:02

''Is it possible thant the JTAG pins are also drawing current. Why cannot I configure them as Analog input?''

Possibly - I do not know.

If you do config them, then you will loose the ability to debug when the processor goes into Stop mode.

(It is possible to debug in some of the low power mode BUT the processor is not really in the low power mode it is just pretending. It just sets the register bits to simulate low power mode(s) but the processor is being clocked as normal if you debug in low power modes)

johng.pollock9
Associate
Posted on December 17, 2014 at 16:31

How are you measuring? Do you have a regulator in your system?