RTC problem
I'm working on some code to set the RTC alarm, and I've gone through all the resources I can find on how to set this up correctly, but it's just not working. If you could take a look and see if I've missed anything, or something is in the wrong order, I would really appreciate it.
I've just hard coded some dummy values for simplicity. &sharpdefine USE_HSI RTC_TimeTypeDef current_time_base;// a typedef struct
RTC_DateTypeDef current_date_base;// a typedef struct
RTC_AlarmTypeDef alarm_time_base;// a typedef struct
RTC_Format_TypeDef time_format = RTC_Format_BCD;// a typedef enum
RTC_InitTypeDef initialization_constants_base;// a typedef struct
void
main(void
) { RTC_DeInit(); enableInterrupts(); initialization_constants_base.RTC_HourFormat =0
; initialization_constants_base.RTC_AsynchPrediv =124
;// for HSI
initialization_constants_base.RTC_SynchPrediv =1999
;// for HSI
if
(RTC_Init(&initialization_constants_base) == SUCCESS); CLK_RTCClockConfig(CLK_RTCCLKSource_HSI, CLK_RTCCLKDiv_64);// for HSI
current_time_base.RTC_H12 = RTC_H12_AM;// 24 hour format
current_time_base.RTC_Hours =0x17
;// 5pm
current_time_base.RTC_Minutes =0x43
;// 43 minutes
current_time_base.RTC_Seconds =0x28
;// 28 seconds
if
(RTC_SetTime(time_format, ¤t_time_base) == SUCCESS); current_date_base.RTC_WeekDay = RTC_Weekday_Monday;// I don't care about the day of the week
current_date_base.RTC_Month =0x12
;// December
current_date_base.RTC_Date =0x17
;// 17th
current_date_base.RTC_Year =0x15
;//2015
if
(RTC_SetDate(time_format, ¤t_date_base) == SUCCESS); alarm_time_base.RTC_AlarmMask = RTC_AlarmMask_None;// Alarm goes off if the entire exact time matches
alarm_time_base.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;// I don't care about the day of the week
alarm_time_base.RTC_AlarmDateWeekDay =0x00
;// wait 0 days
alarm_time_base.RTC_AlarmTime.RTC_H12 = RTC_H12_AM;// 24 hour format
alarm_time_base.RTC_AlarmTime.RTC_Hours =0x00
;// wait 0 hours
alarm_time_base.RTC_AlarmTime.RTC_Minutes =0x00
;// wait 0 minutes
alarm_time_base.RTC_AlarmTime.RTC_Seconds =0x12
;// wait 12 seconds
RTC_ITConfig(RTC_IT_ALRA, ENABLE); RTC_OutputConfig(RTC_Output_Alarm, RTC_OutputPolarity_High); RTC->CR2 |= RTC_CR2_ALRAIE; RTC_SetAlarm(time_format, &alarm_time_base);if
(RTC_AlarmCmd(ENABLE) == SUCCESS); }And I have this piece of code in my stm8l15x_it.c file:
INTERRUPT_HANDLER(RTC_IRQHandler,4
) { nop(); RTC_ClearITPendingBit(RTC_IT_ALRA); }And the interrupt never happens.
#rtc #rtc-stm8l #problem #stm8l #stm8