cancel
Showing results for 
Search instead for 
Did you mean: 

MCU not stopping at sleepmode in freertos

HZaib.1
Associate III

I am using stm32l496 

 

I am trying to enter sleepmode in freertos, but for some reason the system does not enter it. 

GLOBAL void SleepMode_Activate(void) {


	unsigned int sleep;
		  flag  = 1;
	/*Disable display task if not already disabled*/
	if (mt_TaskStatus(_TN_ANZ) != _SLEEPING) {
		mt_Terminate(_TN_ANZ);	//Disabled Display
	}

	/*Turn off lcd and other stuff*/
	vw_SlowHwAus();
	/*disables COMs if necessary*/
	/*Enable there alternate wakeup pins of COM*/
	vw_ComBeenden();
	slowspeed_timers = 1;
	/*Enable interrupt on buttons, before they were working in timer*/
	tas_Starten();
	mt_TimerDis();
	osThreadTerminate(Tasks_ID[_TN_KZR]);
	SleepMode_DisableUart();


    hw_SetSpeedSlow();
	HAL_SuspendTick();
	  SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;



		 HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);

	//************** Slow Section Start
	do {
		hw_Wdr();

	//	bib_Nop025us();
		// because of Instruction Que
		if (bSekNeu)		    // meanwhile a change of seconds takes place ?
		{
			bSekNeu = 0;
			vw_TestNetzSlow();	// Check supply
		}
	} while (bBedienReq == 0 && bUmwReq == 0// bMinNew == 0 is included in bUmwReq
	&& SioReq == 0 && MeldReq == 0);// as long as no key, no min, no SIO, no message
	//************** Slow End section



   //__HAL_FLASH_SLEEP_POWERDOWN_DISABLE();
   /* System is Low Power Run mode when exiting Low Power Sleep mode,
       disable low power run mode and reset the clock to initialization configuration */
    HAL_PWREx_DisableLowPowerRunMode();

   hw_SetSpeedFast();

   /* Resume Tick interrupt if disabled prior to Low Power Sleep mode entry */
   HAL_ResumeTick();
   SysTick->CTRL  |= SysTick_CTRL_TICKINT_Msk;
	slowspeed_timers = 0;
	mt_TimerEn();
	uhr_LiesRtc();			// Complete time
	vw_ComReact();			// V2.0

	//osKernelRestoreLock(lock)


}

 

I also disabled systick and  my base timer. I made sure no interrupts are being generated, but still I cant go into sleepmode. I think this is some kind of a bug. I am not using tickless idle right now for some reasons. 

 

1 REPLY 1
Sarra.S
ST Employee

Hello @HZaib.1, sorry for the delayed answer, 

Your code seems ok, use a debugger to step through the code and check if the HAL_PWR_EnterSLEEPMode() is being called and check the status of the power control flags after attempting to enter sleep mode

 

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.