Usage example
Generate an alarm intetrrupt every 10 minutes between AM7:00 and AM7:59.
[GUI setting example]
Real-time clock |
Used | |||
RTC |
Used | |||
Real-time clock operation setting |
Used | |||
Hour-system selection |
24-hour | |||
Set real-time clock initial value |
Used 04/01/2018 00:00:00 | |||
Enable output of RTC1HZ pin (1 Hz) |
Unused | |||
Use alarm detection function |
Used | |||
Set alarm initial value |
Used | |||
Week day |
Sunday Monday Tuesday Wednesday Thursday Friday Saturday | |||
Hour: Minute |
AM 07:00 | |||
Used as alarm interrupt function (INTRTC) |
Used | |||
Used as condtant-period interrupt function (INTRTC) |
Unused | |||
Priority(INTRTC) |
Low |
[API setting example]
r_main.c
void main(void)
{
R_MAIN_UserInit();
/* Start user code. Do not edit comment generated here */
/* Enable the real-time clock */
R_RTC_Start();
/* Start the alarm operation */
R_RTC_Set_AlarmOn();
while (1U)
{
;
}
/* End user code. Do not edit comment generated here */
}
r_cg_rtc_user.c
/* Start user code for global. Do not edit comment generated here */
volatile rtc_alarm_value_t alarm_val;
/* End user code. Do not edit comment generated here */
static void r_rtc_callback_alarm(void)
{
/* Start user code. Do not edit comment generated here */
/* Get alarm value */
R_RTC_Get_AlarmValue((rtc_alarm_value_t *)&alarm_val);
if ((alarm_val.alarmwm + 0x10U) <= 0x59U)
{
alarm_val.alarmwm += 0x10U;
/* Set alarm value */
R_RTC_Set_AlarmValue(alarm_val);
}
else
{
/* Stop the alarm operation */
R_RTC_Set_AlarmOff();
}
/* End user code. Do not edit comment generated here */
}