Showing results for 
Search instead for 
Did you mean: 

High current consumption in STOP mode

Associate III

EDIT: The program is stopping at _WFI() but the current consumption is too high (3.9mA). 

I'm using STM32L476 processor and while trying to enter stop mode (tried both with and without tickless mode), the program never waits at _WFI(). Is there a way to know what interrupt caused the wakeup? Or which interrupts are enabled while entering into the stop mode because I have tried to disable all the interrupts?

Software Used: STMCubeIDE


Look at registers in the NVIC?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..

I did but can't find a comprehensive guide on all the NVIC registers.

ST Employee

Hello @Ans

I'm not sure WFI() is being executed and you entered stop mode since you're measuring current in mA.

Could you elaborate more or perhaps show some code? how do you plan to wake-up from stop mode? 

If NVIC registers are not comprehensible, you can check which interrupts are enabled in CubeMX> System core> NVIC. 

Also, you can check this article 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Associate III

So, when I debug the code, it's waiting at WFI(). As far as wakeup is concerned, I have enabled EXTI on PF10. 

This is my pre sleep function:




void PreSleepProcessing(uint32_t *ulExpectedIdleTime)
	osTimerStop(mt_TimerInt);	// TimerB0  stop
	ein_EinFktInitslow();          //Stop timers
	hw_IntSavflash();            //Disable all IRQs using HAL function 
	HAL_SuspendTick();          //Time base: Tim3




 Post Sleep:




void PostSleepProcessing(uint32_t *ulExpectedIdleTime)
	hw_IntResflash();		//Enable all IRQs
	osTimerStart(mt_TimerInt, _MTZ_50ms*50);	// TimerB0  starten	
	ein_EinFktInitAlle(); 		//now activate timers






vPortSuppressTicksAndSleep Function's snippet from port.c file. Commented out the 2nd and 15 line and added 14th to make it compatible for tickless mode (followed this tutorial Nothing else changed in this file.




			/* Restart SysTick. */

			/* Sleep until something happens.  configPRE_SLEEP_PROCESSING() can
			set its parameter to 0 to indicate that its implementation contains
			its own wait for interrupt or wait for event instruction, and so wfi
			should not be executed again.  However, the original expected idle
			time variable must remain unmodified, so a copy is taken. */
			xModifiableIdleTime = xExpectedIdleTime;
			configPRE_SLEEP_PROCESSING( xModifiableIdleTime );
			if( xModifiableIdleTime > 0 )
				__asm volatile( "dsb" ::: "memory" );
//				__asm volatile( "wfi" );
				__asm volatile( "isb" );
			configPOST_SLEEP_PROCESSING( xExpectedIdleTime );




 Hopefully, this much code is enough.

Associate III

Re: If NVIC registers are not comprehensible, you can check which interrupts are enabled in CubeMX> System core> NVIC. 
I do know which interrupts are enabled and I've tried to disable them in Pre Sleep routine as you can see. Issue is the program still don't stop at wfi() sometimes. I needed some way to know what interrupts are still active even after I disable them. I was looking for a guide for NVIC registers but couldn't find any. 

Associate III

I hope you are not measuring the current while you are debugging. While debugging, the current consumption is increased.

Associate III

I know. The diff of current is almost 1-2mA while in debugging mode.