cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with RTC and 1Hz interrupt

Nickelgrass
Senior
Posted on September 18, 2016 at 09:40

Hello,

I have been hanging on this problem since days and have googeld a very lot but can not solve this.

I am working with a Nucleo F411RE and TrueStudio. I want to generate a 1Hz interrupt with the RTC. The system is running and the RTC is nicely running too. I can see the Seconds count and it is very accurate holding the time. So I assume that all is configured correctly regarding the RTC itself. But I can not get the interrupt to work. The WUTIE is set and the WUT is enabled. I checked that all by looking at the register.

I have tryed the Tamp-Stamp-IRQ and the Wakeup-IRQ. But either nothing happens or the interrupt ends up in the ''Infinite_Loop''. 

My code regarding the interrupt setup:

rtc_unlock();

B_OUT(RTC->CR, bit14|bit10|bit2);

rtc_lock();

B_SET(EXTI->IMR, bit22);

B_SET(EXTI->RTSR, bit22);

B_SET(EXTI->SWIER, bit22);

NVIC_SetPriorityGrouping(0);

NVIC_SetPriority(RTC_WKUP_IRQn, 10);

NVIC_EnableIRQ(RTC_WKUP_IRQn);

In the startup_stm32f411xe.s I looked up the funktionname from the RTC_WKUP_IRQHandler and set my IRQhandler to that name. Is there any advice on this, I am getting desperately on this one. How can I get the interrupt to jump into my function? 

void RTC_WKUP_IRQHandler()

{

B_SET(EXTI->PR, bit22);

NUCLEO_LED_ON;

}

Do I have to specify my function somehow to tell the compiler to use it?

Am greatfull for any tips.

Thanks, regards
3 REPLIES 3
adam23
Associate II
Posted on September 20, 2016 at 15:31

It depends on if you are using any template/example/OS. But yes the address of RTC_WKUP_IRQHandler has to be present in interrupt vector table on right place. It is not placed there ''auto magically''.

adam23
Associate II
Posted on September 20, 2016 at 18:33

Oh, is the WU not used only for wake up from sleep/standby? From spec of similar STM32

When the periodic wakeup interrupt is enabled by setting the WUTIE bit in the RTC_CR2 register, it can exit the device from low-power modes.

The periodic wakeup flag can be routed to the RTC_ALARM output provided it has been enabled through bits OSEL[1:0] of RTC_CR register. RTC_ALARM polarity can be configured through the POL bit in the RTC_CR register.

So you may have to set the RTC_ALARM...

Nickelgrass
Senior
Posted on September 26, 2016 at 08:20

Thanks for the reply. Of course i did use the function from the vectortable.

The hint with the Alarm worked and I simply put the vectortable from the .s file in an own vectortable in a .c file and now I can enter my own function names. 

Many thanks!