Download Print this page

sparkfun RV-8803 Hook-Up Manual page 18

Real time clock module (qwiic)

Advertisement

uint8_t minuteAlarmValue = 55; //0-60
uint8_t hourAlarmValue = 0; //0-24
uint8_t weekdayAlarmValue = 0; //0-6
uint8_t dateAlarmValue = 0; //1-31
#define MINUTE_ALARM_ENABLE true
#define HOUR_ALARM_ENABLE false
#define WEEKDAY_ALARM_ENABLE false
#define DATE_ALARM_ENABLE false
Setting the the various Alarm Enable variables (e.g.
an alarm and, as expected, setting it to
an alarm every hour when the minutes value reaches 55.
With the variables defined and enabled/disabled, the code initializes the RV-8803, configures it to trigger an alarm and the calls the values for each time
variable (minutes, hours, etc.). The main loop checks if the alarm interrupt flag (FLAG_ALARM) has been triggered using the 'getInterruptFlag` function
and, if the alarm is triggered, drives the INT pin LOW and prints over serial the alarm has been triggered.
Lastly, it clears the alarm flag to reset the RTC for the next alarm trigger. If you want to clear the entire flag register on an alarm trigger, uncomment this
line:
//rtc.clearAllInterruptFlags();
Example 4B - Countdown Interrupt
This example demonstrates how to configure a periodic signal interrupt based on a countdown timer and explains how to calculate the proper values for
the countdown timer. The countdown timer values require some math to calculate how many clock ticks (0-4095) we want to count along with the length
of those ticks (4096 Hz, 64 Hz, 1 Hz, 1/60 Hz) in order to designate the period of the countdown timer. Click the button below to take a look at the table
for more information on how the countdown timer interval is calculated:
After initializing the RV-8803, the example configures a ~3.5 second interrupt. To do this, we first choose 60 Hz as our timer frequency since we want our
timer longer than 1 second but still want a small enough time range (or resolution) to easily set the interrupt to fire at 3.5 secs and not 3 or 4 seconds.
Next, we'll convert 3.5 seconds to 3500 mS since our resolution @60 Hz is 15.625mS/LSB. Finally, to figure out how many ticks are needed for a 3.5 sec
interval, we divide the time we want by the resolution of the clock frequency:
configuring the Countdown Timer Interrupt looks like this:
MINUTE_ALARM_ENABLE
prevents the RV-8803 from matching the variable for the alarm interrupt. The example defaults to trigger
false
CLICK HERE TO OPEN THE COUNTDOWN TIMER SETTINGS TABLE
) to
will configure the RV-8803 to check to match that variable to trigger
true
3500 / 15.625 = 224 Clock Ticks
. With everything calculated, our code

Advertisement

loading
Need help?

Need help?

Do you have a question about the RV-8803 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Bob-16281