This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
hi all,
i am using the RTC and having a problem understanding the priority of the RTCIV. My code sends the time to a display, but it is one minute slow. i have traced this to be the event interrupt (every minute, that sends the time), is being executed before the ready interrupt (on RTCRDY, that updates the time). I was expecting that RTCRDYIFG was higher priority than RTCEVIFG, and on a minute rollover they will both be set (per fig 29-1 in user manual).
#pragma vector = RTC_VECTOR __interrupt void RTC_ISR(void) { switch(__even_in_range(RTCIV, 16)) { case RTCIV_NONE: break; //No interrupts case RTCIV__RTCOFIFG: break; //RTCOFIFG - fault. case RTCIV__RTCRDYIFG: //RTCRDYIFG - triggered just after 1Hz reg-update. //Safest point to Update the RTC internal time sRtcTime.Seconds = HWREG8(RTC_C_BASE + OFS_RTCTIM0_L); sRtcTime.Minutes = HWREG8(RTC_C_BASE + OFS_RTCTIM0_H); sRtcTime.Hours = HWREG8(RTC_C_BASE + OFS_RTCTIM1_L); sRtcTime.DayOfWeek = HWREG8(RTC_C_BASE + OFS_RTCTIM1_H); sRtcTime.DayOfMonth = HWREG8(RTC_C_BASE + OFS_RTCDATE_L); sRtcTime.Month = HWREG8(RTC_C_BASE + OFS_RTCDATE_H); sRtcTime.Year = HWREG16(RTC_C_BASE + OFS_RTCYEAR); Task_SysTick_1s.flag = true; APP_WAKEUP; break; case RTCIV__RTCTEVIFG: //RTCEVIFG - Interrupts every minute Task_MinuteTick.flag = true; APP_WAKEUP; break; break; case RTCIV__RTCAIFG: break; case RTCIV__RT0PSIFG: break; case RTCIV__RT1PSIFG: break; default: break; } }
in the main loop it checks, checks if Task_MinuteTick is set and copies out sRtcTime (Calendar) to another instance and sends it on. I can see with gpio toggles in each case above that EVIFG runs 3.9-4ms before RTCRDY, but i though it would be the other way round?
i have a workaround for it, but just want to know if im misinterpreting how the interrupt vector is working.
thanks,
michael.
I think the key to this is in User Guide (SLAU367P) Sec 29.2.5. RTCRDY isn't really a one-second trigger, though it happens every 1 second. It triggers on the RTCRDY rising edge (128/32768)=~4ms after the one-second transition, once the CPU and RTC clocks have sync-ed. Strictly speaking, you probably shouldn't (and you don't) read the RTC registers during the RTCEVIFG trigger, since I expect RTCRDY=0 then.
Ah of course, thank you! That makes sense, yep i was aware about the keep out window so only read the time on rtcrdy, but just never clicked that it would mean the event irq would go first, i was staring right at it as well in fig 29-1. I was too focused on the user guide saying that RTCRDY is higher priority than RTCEV, which in practise is not the case.
I'm happy the workaround is ok then. the problem was:
Cheers.
**Attention** This is a public forum