diff --git a/src/main.c b/src/main.c --- a/src/main.c +++ b/src/main.c @@ -72,6 +72,10 @@ int main(void) adc_stop(); HAL_Delay(1000); + __DBGMCU_CLK_ENABLE() ; // (RCC->APB2ENR |= (RCC_APB2ENR_DBGMCUEN)) + HAL_EnableDBGStopMode(); // SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); + + while (1) { // TODO: Disable GPIO port clocking when not needed! @@ -123,9 +127,11 @@ int main(void) // Enter sleep mode: wait for interrupt //HAL_PWR_EnterSLEEPMode(0, PWR_SLEEPENTRY_WFI); + __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); - // We have woken up! + // We have woken up! Clear wakeup flag + __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); // This is hopefully the only timer that needs to stay alive in idle mode // last_wspr_tx_time += 0; // move this timer forward based on sleep length