2023-11-05 11:24 PM
I've implemented STOP 1 mode on STM32L476 using HAL function. The current consumption is >1mA even in STOP mode while I've disabled all the clocks. I'm unable to understand this.
2023-11-06 02:19 PM
A little more information would help potential supporters to understand your problem. Please show us how you activated STOP1?
What is connected to the STM32L476 while you are measuring the current consumption (debugger via SWD or JTAG, inputs etc. to other circuit parts)?
Regards
/Peter
2023-11-06 10:28 PM
Let me share the code flow:
1. I'm decreasing the MSI clock to 100KHz. I do know STOP1 mode turns off all clocks except for LSI and LSE but still decreasing the clocks shows significant decrease in current, almost 2-3 mA.
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
{
Error_Handler();
}
/** Configure LSE Drive Capability
*/
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE|RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSICalibrationValue = 64;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_0;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
{
Error_Handler();
}
2. Secondly, I'm setting all GPIOs as Analog and deinitializing all the peripherals:
GPIOB->MODER |= 0xFFFFFFFF;
GPIOC->MODER |= 0xFFFFFFFF;
GPIOD->MODER |= 0xFFFFFFFF;
GPIOE->MODER |= 0xFFFFFFFF;
GPIOG->MODER |= 0xFFFFFFFF;
GPIOH->MODER |= 0xFFFFFFFF;
GPIOI->MODER |= 0xFFFFFFFF;
HAL_FMC_MspDeInit();
HAL_UART_MspDeInit(&huart1);
HAL_UART_MspDeInit(&huart2);
HAL_UART_MspDeInit(&huart3);
HAL_UART_MspDeInit(&huart4);
HAL_UART_MspDeInit(&huart5);
HAL_ADC_MspDeInit(&hadc1);
HAL_CRC_MspDeInit(&hcrc);
HAL_SPI_MspDeInit(&hspi1);
HAL_TIM_Base_MspDeInit(&htim1);
HAL_TIM_Base_MspDeInit(&htim2);
HAL_TIM_Base_MspDeInit(&htim4);
HAL_TIM_Base_MspDeInit(&htim5);
HAL_TIM_Base_MspDeInit(&htim6);
HAL_TIM_Base_MspDeInit(&htim17);
3. Next up, I'm using this HAL function to enter STOP1 mode:
HAL_PWREx_EnterSTOP1Mode(PWR_SLEEPENTRY_WFI);
4. There's an EXTI enabled on PF10 to wake the device from stop mode and it's working fine.
I'm able to achieve current as low as 700uA without debugger connected (1.07mA with SWD connected).
I'm using Nordic's Power profiler kit II to measure the current.
This much info is enough? Let me know if you need any other details.
Am I doing something wrong?