RTC Alarm Mode interrupt

Hi,

In my application i use the RTC module with the clock source from an external 32k. On top of this module i have a top level ‘time’ module managing day clock and date.

From my basic rtc module, i have a working example where a trigger the RTC clock interrupt every second.
Everything is running fine until i tried to configure the RTC hardware module with the alarm mode.
I have been unsuccessfull so far to configure the RTC module with a periodic alarm interrupt.

This puzzles me the RTC hw module is quite simple, am i missing something obvious?

My RTC test module source file:
rtc.c (12,5 Ko)

My working example with clock interrupt with a trace output every second:

rtcInit(&handleRtcClock, false);
rtcEnableInterrupt();
rtcStart();

static void handleRtcClock(void)
{
    aconPrintf(" rtc clock ISR triggered");
}

The example with the alarm interrupt:

rtcInit(&handleRtcAlarm, true);
rtcEnableInterrupt();
rtcStart();

static void handleRtcAlarm(void)
{
    aconPrintf(" rtc alarm ISR triggered");
}

@sylvain.mariteau For the comprehension, can you provide the value of the following macros:

RTC_CNT_TICKS_REF
RTC_CNT_TICKS_OSC32K_PER_SECOND
RTC_CNT_TICKS_OSC32K_PER_DAY
RTC_CNT_TICKS_MIN_DAY_OSC32K

Here the missing header file:
rtc.h (4,0 Ko)

1 Like

@sylvain.mariteau I didn’t detect any obvious problem in your code. When configured with 1s, both alarm and clock IRQ behave the same way even if triggered by different IRQ handlers. It seems the configuration, the interrupt settings and so on have been managed correctly, so both should work…

3 Likes

Hi rvs,

I have the same behavior as sylvain. On the other hand, when the RTC alarm mode is chosen and RSL10 goes to sleep, it’s waked up by this alarm.
What example did you sue to have the alarm IRQ triggered ?
Best regards,

When the CM3 is sleeping:

  • RTC alarm interrupt is able to wakeup the CM3
  • RTC clock interrupt can’t be triggered

When the CM3 is running:

  • RTC clock interrupt can be triggered
  • RTC alarm seems not able to be triggered. I haven’t tested this point, but I didn’t find anything in the RSL10 Hardware Reference indicating it isn’t possible… So, either I missed something or ON Semiconductor should make this explicit…

Can ON Semiconductor experts confirm that RTC_ALARM_IRQHandler can’t be triggered when the CM3 is running?

Thank your rvs for answer.

Yes, may be there is a special configuration to achieve that.

Best regards,

@rvs @Embed

The RTC alarm should be OK with RTC_ALARM_IRQHandler when the CM3 is running.
The key is “CLEAR WAKEUP_RTC_ALARM Flag”.

void RTC_ALARM_IRQHandler(void)
{
ACS_WAKEUP_CTRL->RTC_ALARM_WAKEUP_CLEAR_ALIAS=WAKEUP_RTC_ALARM_CLEAR_BITBAND;
timestamp = Sys_RTC_Value();
Sys_GPIO_Toggle(LED_DIO);
}

blinky_RTC_ALARM.7z (859.2 KB)

Thank you for using our community forum!

1 Like

Now, I have my test code with the alarm ISR trigerred every 1 second as expected.

I do also clear the flag prior enabling the alarm interrupt. If it is already raised, the ISR shall never trigger. Without this it might work somehow as i reckon during my investigations having somehow once a single alarm ISR trigerred after configuring RTC module :

ACS_WAKEUP_CTRL->RTC_ALARM_WAKEUP_CLEAR_ALIAS=WAKEUP_RTC_ALARM_CLEAR_BITBAND;
                NVIC_SetPriority(RTC_ALARM_IRQn,0x7);
                NVIC_ClearPendingIRQ(RTC_ALARM_IRQn);
                NVIC_EnableIRQ(RTC_ALARM_IRQn);