Skip to main content
Graduate
November 1, 2023
Question

High current consumption in STOP mode

  • November 1, 2023
  • 3 replies
  • 2755 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.

    3 replies

    Graduate II
    November 1, 2023

    Look at registers in the NVIC?

    AnsAuthor
    Graduate
    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 

    AnsAuthor
    Graduate
    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.

    Explorer
    November 2, 2023

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

    AnsAuthor
    Graduate
    November 2, 2023

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