STM32L151 Stop mode power consumption
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