Skip to main content
adrian
Associate III
November 22, 2018
Question

HAL_RTCEx_SetWakeUpTimer_IT issue (STM32L475RC)

  • November 22, 2018
  • 14 replies
  • 5917 views

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?

This topic has been closed for replies.

14 replies

adrian
adrianAuthor
Associate III
November 22, 2018
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
adrianAuthor
Associate III
November 23, 2018

Bump, anybody?

adrian
adrianAuthor
Associate III
November 26, 2018

ST Staff?

adrian
adrianAuthor
Associate III
November 27, 2018

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

What am I missing here?

waclawek.jan
Super User
November 27, 2018

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

adrian
adrianAuthor
Associate III
November 28, 2018

@Community member​ 

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

The EXTI is set correctly.

waclawek.jan
Super User
November 28, 2018

No, I mean WUTIE,

JW

adrian
adrianAuthor
Associate III
November 28, 2018

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

Yep, it's set.

waclawek.jan
Super User
November 28, 2018

I don't know, then. Sorry.

JW

ST Technical Moderator
November 29, 2018

Hello @adrian​ ,

There is a problem in the "stm32l4xx_hal_rtc_ex.c" file within the new version of STM32CubeL4 V1.13.0: The macro '__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT();' is missing in the HAL_RTCEx_SetWakeUpTimer_IT function (for other devices than STM32L412xx/STM32L422xx).

To fix this issue: the macro __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT()" in the HAL_RTCEx_SetWakeUpTimer_IT function should be added instead of "__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT" ( in line 912)

Hope this helps you.

Please keep us informed about your update.

Kind Regards,

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
adrian
adrianAuthor
Associate III
November 30, 2018

This did indeed fix the issue, I now get the Wakeup interrupt!

Many thanks

ST Technical Moderator
December 3, 2018

 We have already passed this issue along to our development team for fix in the coming release.

Kind Regards,

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
waclawek.jan
Super User
December 3, 2018

I asked above about exti, and adrian answered

> The EXTI is set correctly.

which I assume he said after reading out and checking the relevant EXTI registers bits.

Or not?

JW

adrian
adrianAuthor
Associate III
December 3, 2018

Apparently it wasn't, I must have looked at the wrong register as it looked like it was set, but clearly wasn't.

The fix correctly fixes it, sounds like you correctly identified it but I just didn't see it.