2014-11-20 03:47 AM
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-mode2014-11-20 05:39 AM
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. -- laurent2014-11-20 07:04 AM
Hi
You should also disconnect the debugger when you make the measurement. It can add spurious current or load.2014-11-20 08:31 PM
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?2014-11-21 03:02 AM
''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)2014-12-17 07:31 AM