cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_RTCEx_SetWakeUpTimer_IT issue (STM32L475RC)

adrian
Associate III

Hi,

I'm really struggling with this, I cannot find any reason for the problem I'm seeing, I've looked at the example code in the firmware packages and I have identical code to the examples.

I'm using HAL to configure the project, the RTC is clocked from LSE which is up and running.

I call:

    MX_RTC_Init();

And I can see that the registers change as expected.

I then call:

 HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);

HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0x5000, RTC_WAKEUPCLOCK_RTCCLK_DIV16);

Which should result the RTC_WKUP_IRQHandler being called, but it never is.

If I look after 10 seconds at the RTC status registers I can see that WUTF is set.

I've tried adding:

__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&hrtc, RTC_FLAG_WUTF);

In various places as it seems that may be required after reading around, but it makes no difference, I cannot get the interrupt to fire, other interrupts from other peripherals are working fine.

My HAL_RTC_MspInit has the following code:

  __HAL_RCC_RTC_ENABLE();

 HAL_NVIC_SetPriority(RTC_WKUP_IRQn, 0, 0);

 HAL_NVIC_EnableIRQ(RTC_WKUP_IRQn);

Any suggestions?

14 REPLIES 14
adrian
Associate III
void main(void)
{
	HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
 
	SystemClock_Config();
	HAL_Init();
	MX_RTC_Init();
 
	HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
	__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&hrtc, RTC_FLAG_WUTF);
 
	HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 1000, RTC_WAKEUPCLOCK_RTCCLK_DIV16);
	
	while(1);
}
 
void RTC_WKUP_IRQHandler(void)
{
	HAL_RTCEx_WakeUpTimerIRQHandler(&hrtc);
}

I literally have this as the application with a breakpoint set in RTC_WKUP_IRQHandler and it doesn't get there. I'm absolutely baffled.

adrian
Associate III

Bump, anybody?

adrian
Associate III

ST Staff?

adrian
Associate III

I've now duplicated the code from the example and it still doesn't work.

What am I missing here?

RTC_CR.WUTIE is set?

Is the corresponding EXTI line configured for proper (rising) edge and enabled in EXTI?

Check by reading out the appropriate registers content.

JW

@Community member​ 

I assume you meant WUTE, yes that's enabled.

The EXTI is set correctly.

No, I mean WUTIE,

JW

Sorry, I didn't see it in my list - been staring at this way too long.

Yep, it's set.

I don't know, then. Sorry.

JW