Stop mode does not work as expected
Hi!
I am using an STM32MP153 and am working on implementing the STOP mode functionality for my application. The MCU shall wake up on a falling edge on pin PI8. The pin PG15 has an interrupt attached to it for another functionality. Before going into stop mode, I must disable the PG15 interrupt for applicational reasons. Going into stop mode and waking up works fine unless I disable the interrupt on PG15. If going to stop mode fails, the power consumption is approx. 830mW and I cannot wake up the system on pin PI8. I cannot explain this behaviour, does anyone have an idea? Thanks a lot!
Here are snippets of my code:
/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GYRO1_INT1_GPIO_Port, &GPIO_InitStruct);
HAL_NVIC_SetPriority(EXTI8_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI8_IRQn);
// (Set up interrupt for PG15...)
// disable EXTI interrupt for Port G, Pin 15
dioConfigStruct_st.Alternate = 0;
dioConfigStruct_st.Mode = GPIO_MODE_IT_OFF;
dioConfigStruct_st.Pin = GPIO_PIN_15;
dioConfigStruct_st.Pull = GPIO_NOPULL;
dioConfigStruct_st.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_ClearPortExti(GPIOG, &dioConfigStruct_st); // If I comment out this line, going to Stop mode works
// go to Stop mode...
/* (C)STOP protection mechanism
* Only the IT with the highest priority (0 value) can interrupt.
* RCC_WAKEUP_IRQn IT is intended to have the highest priority and to be the
* only one IT having this value
* RCC_WAKEUP_IRQn is generated only when RCC is completely resumed from CSTOP
*/
__set_BASEPRI((RCC_WAKEUP_IRQ_PRIO + 1) << (8 - __NVIC_PRIO_BITS));
/* Back up clock context */
rccBackupClocks();
/* Clear the Low Power MCU flags before going into CSTOP */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_STOP);
HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI);
/* ... STOP mode ... */
/* Leaving CStop mode */
/* Test if system was on STOP mode */
if (__HAL_PWR_GET_FLAG(PWR_FLAG_STOP) == 1U)
{
/* Clear the Low Power MCU flags */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_STOP);
}
/* Restore clocks */
ASSERT_THAT(rccRestoreClocks() == HAL_OK, "Restore Clocks failed!");
/* All level of ITs can interrupt */
__set_BASEPRI(0U);
// Enter 'systemctl suspend' in the Linux console
