I am using STM32G031F6 microcontroller and I set up Stop Mode. code :
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
PWR->CR1 = (PWR->CR1 & ~PWR_CR1_LPMS) | PWR_CR1_LPMS_0;
SCB->SCR |= (uint32_t)SCB_SCR_SLEEPDEEP_Msk;
DBG->CR |= DBG_CR_DBG_STOP;
__WFI();
SCB->SCR &= (uint32_t)~SCB_SCR_SLEEPDEEP_Msk;
SystemCoreClockUpdate();
SysTick_Config((SystemCoreClock / 1000));
The problem I have now is that when I program with st link, it consumes 300uA in stop mode, while it should be 4uA. But when I completely cut off the power and reconnect it, the current consumption is 4uA. What should I do so that after programming the current will be 4uA and there is no need to cut off the power supply?
Debugger may enable a bit which keeps the processor running during low-power modes. There may be some setting in your toolchain (IDE) to prevent this.