cancel
Showing results for 
Search instead for 
Did you mean: 

Find out a wakeup source on STM32H7

AlexSmart
Senior

Im trying to put STM32H743 in stop mode with wakeup from external interrupt.

So far core wakes up immediately after

HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE);

EXTI_CPUPRx registers all set to 0, so what wakes up the CPU? Is there any additional falgs that indicates the wakeup source?

14 REPLIES 14
Peter BENSCH
ST Employee

This can be caused by SYSTICK, which should be disabled before going to STOP.

Regards

/Peter

In order 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.
AlexSmart
Senior

Disabled a systick, doesnt work either. Maybe there is something im doing wrong. With step by step debug it never goes to stop mode, when running without debug, it wakes up one time, and then never wakes, exti on dedicated pin does not work either

EXTI_HandleTypeDef hexti_USB_VBUS;
 
void WakeUpSourcesInit(void)
{
	EXTI_ConfigTypeDef ExtiConfig;
 
	ExtiConfig.Line 			= EXTI_LINE_9; 
	ExtiConfig.Mode 			= EXTI_MODE_EVENT;
	ExtiConfig.Trigger 			= EXTI_TRIGGER_RISING;
	ExtiConfig.GPIOSel 			= EXTI_GPIOA;
	ExtiConfig.PendClearSource 	= EXTI_D3_PENDCLR_SRC_NONE;
	HAL_EXTI_SetConfigLine(&hexti_USB_VBUS, &ExtiConfig);
}
 
void DevStop(void)
{
	while(1)
	{
		HAL_SuspendTick();
		
		HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE);
		
		HAL_ResumeTick();
		LED1_GPIO_Port->ODR ^= LED1_Pin;
		SYSCLKConfig_STOP();
	}
}

AlexSmart
Senior

Still struggling with wakeup reason. Does anyone have an idea. Here is EXTI and PWR registers immediately after wakeup

0693W00000FB1bFQAT.jpg0693W00000FB1cIQAT.jpg 

The 'H7 is an overly complicated beast, and its EXTI is no exception. I don't use it, so following is only from reading the RM.

There are two kinds of EXTI signals - "configurable" and "direct", see EXTI Event input mapping table. Configurable are "legacy" and latch within EXTI in the Pending register(s) - that are all the "real" external interrupts from pins, for example.

Direct signals don't latch within EXTI, they just pass through resynchronization and are subject to gating (CPUIMRx registers, which by default are enabled for all Direct signals). So, for Direct signals, you are supposed to find trace at their source, based on what Wakeup interrupts have you enabled in the individual peripherals.

Also, if you use Cube/HAL, it's Cube/HAL which may get in your way by clearing the pending registers. Using Cube/HAL you agree to play along its own rules, written or not; and to accept its limited scope of "usual usage cases".

JW

AlexSmart
Senior

All peripherals are off at this point. So it is a "direct" event because I see nothing in CPUIMRx registers. Have no idea how to find a cause...

> All peripherals are off at this point.

Clear all CPUIMRx registers. Still wakeup?

JW

AlexSmart
Senior

Yes, same

Are you sure it goes to sleep at all? How exactly do you test that?

Do you use WFI or WFE?

Could M7_DWT_SLPCNT register give any further insight?

JW

AlexSmart
Senior

It goes like this

while(1)
	{
		HAL_SuspendTick();
		SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
 
		HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE);
		
		if (__HAL_RTC_WAKEUPTIMER_EXTI_GET_FLAG())
		{
			LED1_GPIO_Port->ODR |= LED1_Pin;
			__HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG(); 
		}
		else
		{
			LED1_GPIO_Port->ODR &= ~LED1_Pin;
		}
		__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&RTCHandle, RTC_FLAG_WUTF);
 
		HAL_ResumeTick();
		SYSCLKConfig_STOP();
	}

with

 __WFE ();

in

void HAL_PWR_EnterSLEEPMode (uint32_t Regulator, uint8_t SLEEPEntry)

Didn't know about M7_DWT_SLPCNT, it stays 0. Does that mean that core does not go into sleep? Or some event already active by the time I call WFE?