cancel
Showing results for 
Search instead for 
Did you mean: 

Periodic wakeup interrupt does not raise

DUrbano
Associate III
Posted on November 12, 2014 at 10:33

Hi at all,

I'm working on an stm32f4 trying to use the RTC periodic interrupt but it doesn't work; I'm using an RTC with a 768KHz external oscillator and a working frequency of 1Hz. The RTC set-up is quite simple:


HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc)

{

/* Check the RTC peripheral state */

if
(hrtc == NULL)

{

return
HAL_ERROR;

}


/* Check the parameters */

assert_param(IS_RTC_HOUR_FORMAT(hrtc->Init.HourFormat));

assert_param(IS_RTC_ASYNCH_PREDIV(hrtc->Init.AsynchPrediv));

assert_param(IS_RTC_SYNCH_PREDIV(hrtc->Init.SynchPrediv));

assert_param (IS_RTC_OUTPUT(hrtc->Init.OutPut));

assert_param (IS_RTC_OUTPUT_POL(hrtc->Init.OutPutPolarity));

assert_param(IS_RTC_OUTPUT_TYPE(hrtc->Init.OutPutType));


if
(hrtc->State == HAL_RTC_STATE_RESET)

{

/* Initialize RTC MSP */

HAL_RTC_MspInit(hrtc);

}


/* Set RTC state */

hrtc->State = HAL_RTC_STATE_BUSY; 


/* Disable the write protection for RTC registers */

__HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);


/* Set Initialization mode */

if
(RTC_EnterInitMode(hrtc) != HAL_OK)

{

/* Enable the write protection for RTC registers */

__HAL_RTC_WRITEPROTECTION_ENABLE(hrtc); 


/* Set RTC state */

hrtc->State = HAL_RTC_STATE_ERROR;


return
HAL_ERROR;

} 

else

{ 

/* Clear RTC_CR FMT, OSEL and POL Bits */

hrtc->Instance->CR &= ((uint32_t)~(RTC_CR_FMT | RTC_CR_OSEL | RTC_CR_POL));

/* Set RTC_CR register */

hrtc->Instance->CR |= (uint32_t)(hrtc->Init.HourFormat | hrtc->Init.OutPut | hrtc->Init.OutPutPolarity);


/* Configure the RTC PRER */

hrtc->Instance->PRER = (uint32_t)(hrtc->Init.SynchPrediv);

hrtc->Instance->PRER |= (uint32_t)(hrtc->Init.AsynchPrediv << 16);


/* Exit Initialization mode */

hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT; 


hrtc->Instance->TAFCR &= (uint32_t)~RTC_TAFCR_ALARMOUTTYPE;

hrtc->Instance->TAFCR |= (uint32_t)(hrtc->Init.OutPutType); 


/* Enable the write protection for RTC registers */

__HAL_RTC_WRITEPROTECTION_ENABLE(hrtc); 


/* Set RTC state */

hrtc->State = HAL_RTC_STATE_READY;


return
HAL_OK;

}

}

like the interrupt configuration:


HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock)

{

uint32_t tickstart = 0;


/* Check the parameters */

assert_param(IS_WAKEUP_CLOCK(WakeUpClock));

assert_param(IS_WAKEUP_COUNTER(WakeUpCounter));


/* Process Locked */

__HAL_LOCK(hrtc);


hrtc->State = HAL_RTC_STATE_BUSY;


/* Disable the write protection for RTC registers */

__HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);


__HAL_RTC_WAKEUPTIMER_DISABLE(hrtc);


/* Get tick */

tickstart = HAL_GetTick();


/* Wait till RTC WUTWF flag is set and if Time out is reached exit */

while
(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == RESET)

{

if
((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)

{

/* Enable the write protection for RTC registers */

__HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);


hrtc->State = HAL_RTC_STATE_TIMEOUT; 


/* Process Unlocked */

__HAL_UNLOCK(hrtc);


return
HAL_TIMEOUT;

} 

}


/* Configure the Wakeup Timer counter */

hrtc->Instance->WUTR = (uint32_t)WakeUpCounter;


/* Clear the Wakeup Timer clock source bits in CR register */

hrtc->Instance->CR &= (uint32_t)~RTC_CR_WUCKSEL;


/* Configure the clock source */

hrtc->Instance->CR |= (uint32_t)WakeUpClock;


/* RTC WakeUpTimer Interrupt Configuration: EXTI configuration */

__HAL_RTC_EXTI_ENABLE_IT(RTC_EXTI_LINE_WAKEUPTIMER_EVENT);


EXTI->RTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT;


/* Configure the Interrupt in the RTC_CR register */

__HAL_RTC_WAKEUPTIMER_ENABLE_IT(hrtc,RTC_IT_WUT);


/* Enable the Wakeup Timer */

__HAL_RTC_WAKEUPTIMER_ENABLE(hrtc);


/* Enable the write protection for RTC registers */

__HAL_RTC_WRITEPROTECTION_ENABLE(hrtc); 


hrtc->State = HAL_RTC_STATE_READY; 


/* Process Unlocked */

__HAL_UNLOCK(hrtc);


return
HAL_OK;

}

but however the interrupt does not start. I'm quite sure the problem is in the configuration (I'm using the CubeMX generated API), but I can't understand where is it. Please could anyone help me ? Regards #bug-needsfixing-firmware
7 REPLIES 7
stm32cube-t
Senior III
Posted on November 13, 2014 at 17:30

Hello,

There is a known MX issue (#

272065

will be fixed in 4.6).

Can you please add the following macro to the

HAL_RTC_MspInit

() function:

__HAL_RCC_RTC_ENABLE();

Let us know if you still have an issue.

Thanks.

DUrbano
Associate III
Posted on November 14, 2014 at 11:58

Thank you very much...I made two things:

1) add, as you told me, the

__HAL_RCC_RTC_ENABLE();

instructions;

2) add in HAL_RTCEx_SetWakeUpTimer_IT, the clear flag instrtuction

__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF); just before the interrupt enable.

All it works now...please, could you tell me where I can find this ''known issue'' ?

Thanks again

stm32cube-t
Senior III
Posted on January 09, 2015 at 13:13

It will be part of STM32CubeMX 4.6 release notes.

Posted on January 21, 2015 at 17:14

It would be very helpful to us struggling users out here if you would publish ''known issues'' between releases.  ie: we understand that there are delays between releases where you try to clean up as many issues as you can.  However if it is several months between releases, and you know about issues that you are working to fix, publishing at least what they are once you have verified them, even without fixes, would save people like this poster and the rest of us hours and days finding out that there is an issue you are already aware of.  I have run into a number myself, and your support team is good at replying, but you could save yourselves lots of time answering the same question over and over by just posting the ones you know about before they are incorporated into a new release so we can check them before we waste your time.

rchris
Associate II
Posted on May 04, 2015 at 15:09

Hi,

when will this issue be solved for the STM32F2? Keil Pack Installer just overwrote the manual change I did to the file, so I had to edit it again. Will there still be support for the STM32F2 or should I go to F4?

MikeAtETI
Associate III
Posted on May 14, 2015 at 12:54

I can confirm I need to patch HAL_RTCEx_SetWakeUpTimer_IT for the STM32L0* cubemx firmware as well (as per item 2 in d.urbano's message) :(

Mike

 

From: d.urbano

Posted: Friday, November 14, 2014 11:58 AM

Subject: Periodic wakeup interrupt does not raise

Thank you very much...I made two things:

1) add, as you told me, the

__HAL_RCC_RTC_ENABLE();

instructions;

2) add in HAL_RTCEx_SetWakeUpTimer_IT, the clear flag instrtuction

__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF); just before the interrupt enable.

All it works now...please, could you tell me where I can find this ''known issue'' ?

Thanks again

sschocke
Associate
Posted on November 30, 2015 at 20:30

I have just tested the newest STM32Cube_FW_L1_V1.4 and I have the same problem. I have had to manually patch the stm32l1xx_hal_rtc_ex.c file and add the following to the HAL_RTCEx_SetWakeUpTimer_IT function.

/* Configure the clock source */
hrtc->Instance->CR |= (uint32_t)WakeUpClock;
/* RTC WakeUpTimer Interrupt - Clear any existing flags */
__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF);
/* RTC WakeUpTimer Interrupt Configuration: EXTI configuration */
__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT();

If I do not add the

__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG

(hrtc, RTC_FLAG_WUTF);

the interrupt is never raised.

Hope this helps someone else. Sebastian