2025-03-20 7:52 AM
I am using the STMG0B1RET on a custom, battery-powered board. During normal operation pin PC4 is used as UART1 (with an external pull-up resistor). In Standby Mode pin PC4 must be LOW in order to shut down the external device. For this I convert PC4 to GPIO and configure it for pull-down in Standby Mode to achieve the 0V at the output.
It is not working. When the HAL function HAL_PWR_EnterSTANDBYMode() is called the output goes HI.
I studied several posts and discussions about this issue, but no success yet.
The below is the latest code snipped. Wakeup pin 6 is used to exit Standby Mode (that works).
This line seems to pull the output to HI. Why?
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
What else can we try? Thank you!!
/* Convert UART1 IO to a GPIO */ GPIO_InitTypeDef GPIO_InitStruct = {0}; HAL_GPIO_WritePin(UART1_GPIO_Port, UART1_Pin, GPIO_PIN_RESET); /*Configure GPIO pin : UART1_Pin */ GPIO_InitStruct.Pin = UART1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(UART1_GPIO_Port, &GPIO_InitStruct); PWR->PDCRC = PWR_PDCRC_PD4; // Set pull-ups for standby modes PWR->CR4 = PWR_CR4_WP6; // Set wakeup pin 6 to low level PWR->CR3 = PWR_CR3_APC | PWR_CR3_EWUP6; // Enable pin pull configurations and wakeup pins PWR->SCR = PWR_SCR_CWUF; // Clear wakeup flags // Configure MCU low-power mode for CPU deep sleep mode PWR->CR1 |= PWR_LOWPOWERMODE_STANDBY; (void)PWR->CR1; // Ensure that the previous PWR register operations have been completed // Configure CPU core SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; // Enable CPU deep sleep mode // Enter low-power mode for (;;) { __DSB(); __WFI(); }