Skip to main content
Associate III
November 1, 2023
Question

High current consumption in STOP mode

  • November 1, 2023
  • 7 replies
  • 2791 views

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


This topic has been closed for replies.

7 replies

Tesla DeLorean
Guru
November 1, 2023

Look at registers in the NVIC?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
AnsAuthor
Associate III
November 1, 2023

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

ST Employee
November 1, 2023

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.
AnsAuthor
Associate III
November 2, 2023

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_SetSpeedSlow(); 
	hw_IntSavflash(); //Disable all IRQs using HAL function 
	HAL_SuspendTick(); //Time base: Tim3
}

 

 

 

 Post Sleep:

 

 

 

void PostSleepProcessing(uint32_t *ulExpectedIdleTime)
{
	HAL_ResumeTick();
	hw_IntResflash();		//Enable all IRQs
	hw_SetSpeedFast();			
	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 https://youtu.be/B1cUWRpXrPU). Nothing else changed in this file.

 

 

 

			/* Restart SysTick. */
//			portNVIC_SYSTICK_CTRL_REG |= portNVIC_SYSTICK_ENABLE_BIT;

			/* 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" );
				HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI);
//				__asm volatile( "wfi" );
				__asm volatile( "isb" );
			}
			configPOST_SLEEP_PROCESSING( xExpectedIdleTime );

 

 

 

 Hopefully, this much code is enough.

RWeil.2
Associate III
November 2, 2023

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

AnsAuthor
Associate III
November 2, 2023

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