2020-04-02 10:27 PM
I am using a STM32F746G-DISCO to develop a touch screen interface to an audio amplifier.
I am testing the standby mode starting from this discussion:
after switch-on I read about 0.4A and 0.3A with backlight off.
In standby mode I read about 0.2A because the backlight go up when enter in standby.
Here the code:
BSP_LCD_SetFont (&Font24);
BSP_LCD_DisplayStringAt(MUTE_X, MUTE_Y, STANDBY, LEFT_MODE);
delayMs(2000);
BSP_LCD_DisplayStringAt(MUTE_X, MUTE_Y, NULL7, LEFT_MODE);
/* Assert display enable LCD_DISP pin - probably not necessary */
//HAL_GPIO_WritePin(LCD_DISP_GPIO_PORT, LCD_DISP_PIN, GPIO_PIN_RESET);
/* Assert backlight LCD_BL_CTRL pin - run good */
HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_PORT, LCD_BL_CTRL_PIN, GPIO_PIN_RESET);
delayMs(2000);
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
HAL_PWR_EnterSTANDBYMode();
2020-04-03 01:07 AM
Starting from the example I have the same situation, LED1 keep off during sleep mode but backlight is go on, why ?
int main(void)
{
#define LCD_BL_CTRL_PIN GPIO_PIN_3
#define LCD_BL_CTRL_GPIO_PORT GPIOK
/* Enable the CPU Cache */
CPU_CACHE_Enable();
/* Configure LED1 */
//BSP_LED_Init(LED1);
/* Turn on LED1 */
//BSP_LED_On(LED1);
HAL_Init();
SystemClock_Config();
__HAL_RCC_PWR_CLK_ENABLE();
/* Check and handle if the system was resumed from StandBy mode */
if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
{
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
/* Exit Ethernet Phy from low power mode */
ETH_PhyExitFromPowerDownMode();
/* Exit USB Phy from low power mode */
USB_PhyExitFromLowPowerMode();
}
GPIO_InitTypeDef gpio_init_structure;
//*********************************************************************
// GPIO BL
//*********************************************************************
__HAL_RCC_GPIOK_CLK_ENABLE();
gpio_init_structure.Pin = GPIO_PIN_3;
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
//gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOK, &gpio_init_structure);
HAL_GPIO_WritePin(GPIOK, GPIO_PIN_3, GPIO_PIN_SET);
//*********************************************************************
// GPIO LED
//*********************************************************************
__HAL_RCC_GPIOI_CLK_ENABLE();
gpio_init_structure.Pin = GPIO_PIN_1;
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOI, &gpio_init_structure);
HAL_GPIO_WritePin(GPIOI, GPIO_PIN_1, GPIO_PIN_SET);
while(1)
{
/* Configure USER Button */
BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);
UserButtonStatus = 0;
/* Wait until USER button is pressed to enter the Low Power mode */
while(UserButtonStatus == 0x00)
{
HAL_GPIO_TogglePin(GPIOI, GPIO_PIN_1); // LED
HAL_Delay(200);
}
while(BSP_PB_GetState(BUTTON_KEY) != RESET)
{
}
HAL_GPIO_WritePin(GPIOK, GPIO_PIN_3, GPIO_PIN_RESET); // BL
HAL_GPIO_WritePin(GPIOI, GPIO_PIN_1, GPIO_PIN_RESET); // LED
HAL_Delay(5000);
USB_PhyEnterLowPowerMode();
ETH_PhyEnterPowerDownMode();
SleepMode_Measure();
HAL_Delay(5000);
//*********************************************************************
// GPIO BL
//*********************************************************************
__HAL_RCC_GPIOK_CLK_ENABLE();
gpio_init_structure.Pin = GPIO_PIN_3;
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
//gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOK, &gpio_init_structure);
//*********************************************************************
// GPIO LED
//*********************************************************************
__HAL_RCC_GPIOI_CLK_ENABLE();
gpio_init_structure.Pin = GPIO_PIN_1;
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOI, &gpio_init_structure);
HAL_GPIO_WritePin(GPIOK, GPIO_PIN_3, GPIO_PIN_SET); // BL
HAL_GPIO_WritePin(GPIOI, GPIO_PIN_1, GPIO_PIN_SET); // LED
}
}
2020-04-03 03:13 AM
Solved excluding the disable of GPIOK
void SleepMode_Measure(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* Disable USB Clock */
__HAL_RCC_USB_OTG_HS_CLK_DISABLE();
__HAL_RCC_USB_OTG_HS_ULPI_CLK_DISABLE();
/* Disable Ethernet Clock */
__HAL_RCC_ETH_CLK_DISABLE();
/* Configure all GPIO as analog to reduce current consumption on non used IOs */
/* Enable GPIOs clock */
__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_GPIOF_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOI_CLK_ENABLE();
__HAL_RCC_GPIOJ_CLK_ENABLE();
// __HAL_RCC_GPIOK_CLK_ENABLE();
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Pin = GPIO_PIN_All;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOJ, &GPIO_InitStruct);
//HAL_GPIO_Init(GPIOK, &GPIO_InitStruct);
/* Disable GPIOs clock */
__HAL_RCC_GPIOA_CLK_DISABLE();
__HAL_RCC_GPIOB_CLK_DISABLE();
__HAL_RCC_GPIOC_CLK_DISABLE();
__HAL_RCC_GPIOD_CLK_DISABLE();
__HAL_RCC_GPIOE_CLK_DISABLE();
__HAL_RCC_GPIOF_CLK_DISABLE();
__HAL_RCC_GPIOG_CLK_DISABLE();
__HAL_RCC_GPIOH_CLK_DISABLE();
__HAL_RCC_GPIOI_CLK_DISABLE();
__HAL_RCC_GPIOJ_CLK_DISABLE();
//__HAL_RCC_GPIOK_CLK_DISABLE();
/* Configure USER Button */
BSP_PB_Init4(BUTTON_KEY, BUTTON_MODE_EXTI);
/* Suspend Tick increment to prevent wakeup by Systick interrupt.
Otherwise the Systick interrupt will wake up the device within 1ms (HAL time base) */
HAL_SuspendTick();
/* Request to enter SLEEP mode */
HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
/* Resume Tick interrupt if disabled prior to sleep mode entry */
HAL_ResumeTick();
/* Exit USB Phy from LowPower mode */
USB_PhyExitFromLowPowerMode();
/* Exit Ethernet Phy from LowPower mode */
ETH_PhyExitFromPowerDownMode();
}
2020-04-08 12:04 PM
> LED1 keep off during sleep mode but backlight is go on, why ?
Because in STANDBY mode the pins go to high impedance state. There is no current for a LED, but back-light input has a pull-up resistor on it.
> Solved excluding the disable of GPIOK
Disabling GPIO clock doesn't loose it's state. Now the state is preserved because you replaces STANDBY with SLEEP mode. SLEEP mode is actually full running mode, except the core CPU clock is stopped. It's the thing idle task should do all the time under normal running, not a power down for MCU. The mode you are looking for is the STOP mode, in which GPIOs can keep it's state but most other MCU parts can be powered off.