rtc.disableAllInterrupts();
rtc.setCountdownTimerFrequency(COUNTDOWN_TIMER_FREQUENCY_64_HZ);
rtc.setCountdownTimerClockTicks(224);
rtc.enableHardwareInterrupt(TIMER_INTERRUPT);
rtc.setCountdownTimerEnable(ENABLE);
lastInterruptTime = millis(); //Change millis() to micros() if you end up using the 4096 Hz counter
The loop checks if the countdown interrupt flag (FLAG_TIMER) has been updated using the getInterruptFlag function. If it has, it clears that flag and
prints the time between interrupts (in milliseconds) over serial.
Note: If you select the 4096 Hz counter, make sure to switch all calls to the millis function to call the micros function instead.
Example 4C - Periodic Interrupt
The last interrupt example demonstrates how to generate a periodic pulse from the RV-8803. This is very similar to the previous example but instead of
setting a custom time between interrupts, we configure the RV-8803 to pulse the interrupt pin every second or every minute using the
setPeriodicTimeUpdateFrequency(); function. The code defaults to a 1 second period but you can change to 1 minute by editing this line:
rtc.setPeriodicTimeUpdateFrequency(TIME_UPDATE_1_SECOND); //Can also use TIME_UPDATE_1_MINUTE
The loop checks if the periodic interrupt flag (FLAG_UPDATE) has been updated using the getInterruptFlag function. If it has, it clears that flag and
prints the time between interrupts (in milliseconds) over serial.
Example 5 - Timestamp
This example demonstrates how to get a timestamp of an event generated on the EVI pin either by pressing the button on the RTC or toggling the EVI pin
from a microcontroller-generated event. First, just like the other examples, we need to initialize the RV-8803 on the I C bus. Next, we enable and
configure the timestamp function:
rtc.setEVIEventCapture(ENABLE); /
rtc.setEVIDebounceTime(EVI_DEBOUNCE_256HZ);
//rtc.setEVIEdgeDetection(RISING_EDGE); // Uncomment to set event detection to button release instead of press
The main loop waits for the FLAG_EVI register to update from an external event on the EVI pin using the getInterruptFlag(); function like the other
interrupt examples. If that flag is updated and cleared, we capture the date and time stamp of the interrupt and print that data over serial.
2