cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L151 stop mode problem!

michelemancini2
Associate III
Posted on July 10, 2013 at 09:51

Hi,

I want to try to send stm32l1 in stop mode (in my experiment I want it never wakes up).

My code works but the current is not

equal

to datasheet!!

In the datasheet the uC in stop mode is around ~2uA

In my experiment I have ~15uA!!

This my code:

int main()

{

SystemInit();

SystemCoreClockUpdate();

PWR_VoltageScalingConfig(PWR_VoltageScaling_Range3);

while (PWR_GetFlagStatus(PWR_FLAG_VOS) != RESET) ;

RTC_ITConfig(RTC_IT_WUT, DISABLE);

LCD_Cmd(DISABLE);

while (LCD_GetFlagStatus(LCD_FLAG_ENS) == SET);

//******************************************** GPIO IN LOW MODE ********************************************

GPIO_InitTypeDef GPIO_InitStructure;

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB,ENABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC,ENABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD,ENABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOH,ENABLE);

/* Configure all GPIO port pins in Analog input mode (trigger OFF) */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_400KHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIOA->MODER = 0xFFFFFFFF;

GPIOB->MODER = 0xFFFFFFFF;

GPIOC->MODER = 0xFFFFFFFF;

GPIOD->MODER = 0xFFFFFFFF;

GPIOE->MODER = 0xFFFFFFFF;

GPIOH->MODER = 0xFFFFFFFF;

/* all GPIOA */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;

GPIO_Init(GPIOA, &GPIO_InitStructure);

/* All GPIOC except PC13 which is used for mesurement */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;

GPIO_Init(GPIOC, &GPIO_InitStructure);

/* all GPIOB except PB6 and PB7 used for LED*/

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All ;

GPIO_Init(GPIOB, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All ;

GPIO_Init(GPIOD, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All ;

GPIO_Init(GPIOH, &GPIO_InitStructure);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,DISABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB,DISABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC,DISABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD,DISABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOH,DISABLE);

PWR_PVDCmd(DISABLE);

//******************************************** RUN 4 Mhz in low power ********************************************

PWR_FastWakeUpCmd(DISABLE);

SetHSICLKToMSI(RCC_MSIRange_6,NoDIV2,WITHRTC) ;

SysTick->CTRL = 0;

RCC->APB1ENR = 0;

PWR_UltraLowPowerCmd(ENABLE);

while(1){

/* Enter Stop Mode permanently !!!!*/

PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);

}

3 REPLIES 3
Amel NASRI
ST Employee
Posted on July 10, 2013 at 10:28

Hello Michele,

The pins configuration isn't so clean compared to the comments. This config should be enough to put pins in analog input mode:

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE); 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB,ENABLE); 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC,ENABLE); 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD,ENABLE); 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOE,ENABLE); 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF,ENABLE); 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOG,ENABLE); 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOH,ENABLE); 
GPIOA->MODER = 0xFFFFFFFF; 
GPIOB->MODER = 0xFFFFFFFF; 
GPIOC->MODER = 0xFFFFFFFF; 
GPIOD->MODER = 0xFFFFFFFF; 
GPIOE->MODER = 0xFFFFFFFF; 
GPIOF->MODER = 0xFFFFFFFF; 
GPIOG->MODER = 0xFFFFFFFF; 
GPIOH->MODER = 0xFFFFFFFF; 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,DISABLE); 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB,DISABLE); 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC,DISABLE); 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD,DISABLE); 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOE,DISABLE); 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF,DISABLE); 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOG,DISABLE); 
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOH,DISABLE);

I listed all ports and depending on your package you can choose only the available ones. This is just for check, not sure it is the problem root cause. -Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

michelemancini2
Associate III
Posted on July 10, 2013 at 12:02

I have checked,

I have 64pin I have this port:

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

All ports are disable but I have 15uA

instead of

~2uA
michelemancini2
Associate III
Posted on July 10, 2013 at 13:35

target

reached

! now <2uA !!

The code work but the difference are the order of function:

before (~15uA):

//RUN 4MHZ

  PWR_FastWakeUpCmd(DISABLE);

  SetHSICLKToMSI(RCC_MSIRange_6,NoDIV2,WITHRTC) ;     

  SysTick->CTRL = 0;     

  RCC->APB1ENR = 0;

  PWR_UltraLowPowerCmd(ENABLE);  

 

After(<2uA)

//RUN 4MHZ 

  PWR_FastWakeUpCmd(DISABLE);

  PWR_PVDCmd(DISABLE);

  PWR_UltraLowPowerCmd(ENABLE);

  RCC->APB1ENR = 0;

  SysTick->CTRL = 0;      

  SetHSICLKToMSI(RCC_MSIRange_6,NoDIV2,WITHRTC) ;