cancel
Showing results for 
Search instead for 
Did you mean: 

RTC-STM32F0 wakeup timer with LSE

ingenieria
Associate
Posted on May 24, 2015 at 20:48

I've startup a board using STM32F072 ( new with ST :) ) ,but cannot get the RTC wake up timer to work, i can see the RTC  Registers are moving using LSE 32K crystal in debug mode, thus RTC->DR increase every second.

i want:

to use the 1 second interrupt to activate some flags and to awake from STOP mode

this is the startup code generated with Cube.

 RTC_TimeTypeDef sTime;

 RTC_DateTypeDef sDate;

   /**Initialize RTC and set the Time and Date

   */

 hrtc.Instance = RTC;

 hrtc.Init.HourFormat = RTC_HOURFORMAT_24;

 hrtc.Init.AsynchPrediv = 127;

 hrtc.Init.SynchPrediv = 255;

 hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;

 hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;

 hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;

 HAL_RTC_Init(&hrtc);

 sTime.Hours = 0;

 sTime.Minutes = 0;

 sTime.Seconds = 0;

 sTime.SubSeconds = 0;

 sTime.TimeFormat = RTC_HOURFORMAT12_AM;

 sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;

 sTime.StoreOperation = RTC_STOREOPERATION_RESET;

 HAL_RTC_SetTime(&hrtc, &sTime, FORMAT_BIN);

 sDate.WeekDay = RTC_WEEKDAY_MONDAY;

 sDate.Month = RTC_MONTH_JANUARY;

 sDate.Date = 1;

 sDate.Year = 0;

 HAL_RTC_SetDate(&hrtc, &sDate, FORMAT_BIN);

   /**Enable the WakeUp

   */

 HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 16, RTC_WAKEUPCLOCK_RTCCLK_DIV16);

//  NVIC_SetPriority(RTC_IRQn, 0);   

//  NVIC_EnableIRQ(RTC_IRQn);      // - with or without this the result is the same the interrupt never enters.

// -------------------------- this is the interrupt, that never enters ----------------------

void RTC_IRQHandler(void){

RTC->ISR &=~ RTC_ISR_WUTF;

TFlags1S.Val=0xFFFF;

}
1 REPLY 1
fenugrec
Associate II
Posted on May 26, 2015 at 03:23

Hi, I don't use Cube/HAL but it sounds like you may be missing an ''enable wakeup int'' somewhere in your initialization. Have you checked the actual contents of the RTC_CR and RTC_ISR registers while your code is running ? I'd check the WUTIE, and maybe WUTE and WUTF bits.