After hours seeking info and testing FT90x RTC Interrupt, I finally managed to make it work!!!
The point is to read the RTC_EOI_CONST_BIT register inside the interrupt to reset it properly...
Here is how to do it with a 1 second (RTC_CMR set to 32 !?!) interrupt:
Code: Select all
char RTC_int = 0; // Interrupt occurs
// -----------------------------------------------------------------------------
void RTC_Interrupt() iv IVT_RTC_IRQ ics ICS_AUTO {
if (RTC_EOI_CONST_BIT == 0) RTC_int = 1;
}
// -----------------------------------------------------------------------------
void Main() {
RTC_WEN_bit = 1; // Wrap enabled
RTC_MASK_bit = 0; // Interrupt masked
RTC_CMR = 32; // Counter Match Register
RTC_CLR = 0;
RTC_IEN_bit = 1; // Interrupt enabled
RTC_EN_bit = 1; // Counter enabled
GLOBAL_INTERRUPT_MASK_bit = 0;
while (1) {
if (RTC_int) {
// your code here, triggered every second
RTC_int = 0;
}
}
molto999