cancel
Showing results for 
Search instead for 
Did you mean: 

RTC random interrupt

tarzan2
Associate III
Posted on September 30, 2016 at 18:22

Hello

I have 2 PCB with STM32L476. The same code is running on each PCB (both board have been programmed with the STlink-utility and the same binary file). The RTC is configured to provide a 1Hz IRQ. The RTC clock is the 32kHz LSI.

On the first PCB, the RTC is working perfectly since months.

***On the second PCB, the RTC was working up to tonight, 3AM.***

The RTC provides something like a 2Hz IRQ with a lot of jitter :

- First IRQ @ T0 + 656ms

- Second IRQ @ T1 + 566ms

- Third IRQ @ T2 + 746ms

- ...

code : 

/* RTC init function */

void MX_RTC_Init(void)

{

  RTC_TimeTypeDef sTime;

  RTC_DateTypeDef sDate;

  RTC_AlarmTypeDef sAlarm;

    /**Initialize RTC and set the Time and Date 

    */

  hrtc.Instance = RTC;

  hrtc.Init.HourFormat = RTC_HOURFORMAT_24;

  hrtc.Init.AsynchPrediv = 127;

  hrtc.Init.SynchPrediv = 249;

  hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;

  hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;

  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.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;

  sTime.StoreOperation = RTC_STOREOPERATION_RESET;

  HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN);

  sDate.WeekDay = RTC_WEEKDAY_MONDAY;

  sDate.Month = RTC_MONTH_JANUARY;

  sDate.Date = 1;

  sDate.Year = 0;

  HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN);

    /**Enable the Alarm A 

    */

  sAlarm.AlarmTime.Hours = 0;

  sAlarm.AlarmTime.Minutes = 0;

  sAlarm.AlarmTime.Seconds = 0;

  sAlarm.AlarmTime.SubSeconds = 0;

  sAlarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;

  sAlarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET;

  sAlarm.AlarmMask = RTC_ALARMMASK_ALL;

  sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_ALL;

  sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;

  sAlarm.AlarmDateWeekDay = 1;

  sAlarm.Alarm = RTC_ALARM_A;

  HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BIN);

}

The timeline provided by IAR shows a double IRQ... 

At this point I do not understand anything anymore... Thank you for your help

0690X00000605S4QAI.png

1 REPLY 1
Posted on September 30, 2016 at 20:46

Don't see any IRQ code.

Presumably this is a system being actively debugged/traced? Can you output useable telemetry without that? ie time stamp against DWT_CYCCNT or a 32-bit timer running at 1MHz or core speed, output to serial terminal. GPIO to a scope, etc.

The LSI (+/-5%) isn't exactly what I'd call stable, at least on the other STM32 I've used. Not using L4 here. Also going to be sensitive to supply voltage.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..