2019-01-10 07:26 AM
Dear all,
I have a board with only the STM32F765VIT6 and I program through the stlink with a power supply of 3.3V (.
At start of program i tried
Like i have any connected pin, i did not configure pin to analog input like adviced in AN4749.
I have got still 5mA, any default configuration help will be pleased.
Thanks,
Solved! Go to Solution.
2019-01-10 08:50 AM
I do not understand your remark "Like i have any connected pin, i did not configure pin to analog input like adviced in AN4749." You must configure every unused pin as analog! Otherwise floating inputs with draw substantial current.
2019-01-10 08:50 AM
I do not understand your remark "Like i have any connected pin, i did not configure pin to analog input like adviced in AN4749." You must configure every unused pin as analog! Otherwise floating inputs with draw substantial current.
2019-01-11 01:48 AM
Thanks for your answer but i did it and it does not change the consumption
Here are my test code :
SCB->VTOR = FLASH_BASE | 0x0;
//HAL_DBGMCU_EnableDBGStandbyMode();
HAL_PWR_EnableBkUpAccess();
// ART Configuration
__HAL_FLASH_PREFETCH_BUFFER_DISABLE();
// Overclocking
HAL_PWREx_DisableOverDrive(); // Disable the overdrive mode
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);
// Voltage Regulator
HAL_PWR_DeInit();
HAL_PWREx_EnableFlashPowerDown();
HAL_PWREx_DisableBkUpReg(); // Disable the backup regulator
//__HAL_RCC_PWR_CLK_DISABLE();
//__HAL_RCC_SYSCFG_CLK_DISABLE(); // APB2 Clock for EXT I
//HAL_PWR_DisablePVD(); // Disable the power voltage detector
//HAL_PWREx_DisableMainRegulatorLowVoltage();
//HAL_PWREx_DisableLowRegulatorLowVoltage(); // Disable the overdrive mode
// GPIO Disable
__HAL_RCC_GPIOA_CLK_DISABLE(); //__GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_DISABLE(); //__GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_DISABLE(); //__GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_DISABLE(); //__GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_DISABLE(); //__GPIOB_CLK_ENABLE();
uint i;
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;
GPIO_InitStructure.Pull = GPIO_NOPULL;
for (i=0;i<13;i++) {
GPIO_InitStructure.Pin = i;
HAL_GPIO_Init( GPIOA, &GPIO_InitStructure);
}
// PIN A13/A141 for pg
GPIO_InitStructure.Pin = 15;
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
for (i=0;i<16;i++) {
GPIO_InitStructure.Pin = i;
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
}
for (i=0;i<16;i++) {
GPIO_InitStructure.Pin = i;
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
}
for (i=0;i<16;i++) {
GPIO_InitStructure.Pin = i;
HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
}
for (i=0;i<16;i++) {
GPIO_InitStructure.Pin = i;
HAL_GPIO_Init(GPIOE, &GPIO_InitStructure);
}
// clear global wake-up flag
PWR->CSR2 &= ~(PWR_CSR2_EWUP6 | PWR_CSR2_EWUP5 | PWR_CSR2_EWUP4 | PWR_CSR2_EWUP3 | PWR_CSR2_EWUP2 | PWR_CSR2_EWUP1); // FREQUENCY CHRIS
PWR->CR2 |= PWR_CR2_CWUPF6 | PWR_CR2_CWUPF5 | PWR_CR2_CWUPF4 | PWR_CR2_CWUPF3 | PWR_CR2_CWUPF2 | PWR_CR2_CWUPF1; // FREQUENCY CHRIS
HAL_PWR_DisableBkUpAccess();
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
//HAL_PWR_EnterSTOPMode((PWR_CR1_LPDS | PWR_CR1_LPUDS | PWR_CR1_FPDS | PWR_CR1_UDEN), PWR_STOPENTRY_WFI);
//HAL_PWREx_EnterUnderDriveSTOPMode(PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON, PWR_STOPENTRY_WFI);
2019-01-17 05:33 AM
Dear all,
Effectively the secret for low power is to have all the unused pins in analog mode but without forgetting to enable the gpio port clock.
Here is the simple code finally :
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
/* GPIO ADC config*/
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.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_15;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); // A13-A14 for PG
GPIO_InitStruct.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;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/*Configure GPIO pins : PH0 PH1 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1;
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
HAL_PWREx_EnterUnderDriveSTOPMode(PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON, PWR_STOPENTRY_WFI); // 200uA
//HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); // 0.450mA
Thanks