2024-10-11 03:11 AM
Hi all,
I'm trying to acheive STOP mode on my stm32f405, but ir's hard to come down 1mA as de datasheet say < 100uA. So to explain my project :
- STM32F405 Freertos
- 3 i2c capteur (power of captor is managed by switch)
- 1 spi flash nand w25n01
My clock conf
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 4;
RCC_OscInitStruct.PLL.PLLN = 168;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 7;
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_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) {
// Error_Handler();
}
}
Here is my function for going in stop mode
vTaskSuspendAll(); close_log_file(); power_off_led(); desactive_i2c_captors(); //switch off vcc for i2c captor HAL_DBGMCU_DisableDBGStopMode(); HAL_ADC_DeInit(&hadc1); W25n01g_deselect(); GPIO_InitTypeDef GPIO_InitStructure; __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); GPIO_InitStructure.Pin = GPIO_PIN_All; GPIO_InitStructure.Mode = GPIO_MODE_ANALOG; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.Pin = GPIO_PIN_All; GPIO_InitStructure.Pin &= ~(GPIO_PIN_8); GPIO_InitStructure.Pin &= ~(GPIO_PIN_11); GPIO_InitStructure.Mode = GPIO_MODE_ANALOG; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.Pin = GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11; GPIO_InitStructure.Mode = GPIO_MODE_ANALOG; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); HAL_SuspendTick(); taskEXIT_CRITICAL(); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
if I understand correctly the stop mode deactivates all the clocks, so I don't need to make calls __HAL_RCC_USART1_CLK_DISABLE for example, so in my case my 1mA consumption should be come to GPIO ? SHould I do something with my clock source or not ?
Solved! Go to Solution.
2024-10-15 02:49 AM
You need to post the full schematic of your board: at the microamp level, the hardware design is also an important part of the system.
@SBaro.11 wrote:- 3 i2c capteur (power of captor is managed by switch)
Sorry, don't know what you mean by "capteur" here - hence a schematic with part numbers would be clearer.
As @jiangfan said, starting with an ST example would be a good way to check if your hardware is OK.
See also:
https://community.st.com/t5/stm32-mcus/tips-for-using-stm32-low-power-modes/ta-p/621007
2024-10-13 08:46 PM
First, you may try with example project from ST to see if your hardware board is OK or not, for example this project:
2024-10-14 11:35 PM
Yes I'll try it.
Did I understand the documentation correctly when I said that in stop mode it is not necessary to stop the device clocks ? For example if I used usart1 I don't have to call
__HAL_RCC_USART1_CLK_DISABLE
2024-10-15 02:40 AM
You may read chapter 5 Power controller (PWR) about STOP mode of RM0090 for STM32F405. most device clocks stopped in STOP mode except LSI/LSE/RTC/... (may be on by configuration). So, I tend to agree with you - no need to call __HAL_RCC_USART1_CLK_DISABLE
2024-10-15 02:49 AM
You need to post the full schematic of your board: at the microamp level, the hardware design is also an important part of the system.
@SBaro.11 wrote:- 3 i2c capteur (power of captor is managed by switch)
Sorry, don't know what you mean by "capteur" here - hence a schematic with part numbers would be clearer.
As @jiangfan said, starting with an ST example would be a good way to check if your hardware is OK.
See also:
https://community.st.com/t5/stm32-mcus/tips-for-using-stm32-low-power-modes/ta-p/621007