EasyManua.ls Logo

sparkfun RV-8803 - Example 4: Interrupts

sparkfun RV-8803
24 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
We have split this example into two "sub-examples" to demonstrate the ways to reset the hundredths register. The hundredths register is read only so
we cannot write to it like the other time variables (seconds, minutes, etc.). Instead, we "set" this register by writing to the RESET bit on the RV-8803. This
function is covered in more detail in section 4.13 of the RV-8803 Application Note.
Example 3A - Set Hundredths (Software)
This example initializes the RV-8803 and then configures the RTC to reset the hundredths register on a serial prompt to the microcontroller. After
uploading the code, open up the serial monitor (with the baud set to 115200 like the previous examples) and send an "r". Your microcontroller will write to
the RESET bit on the RV-8803 to "set" the hundredths register to 00 . If you want to reset the hundredths register again, simply send another "r" through
your serial monitor.
Example 3B - Set Hundredths (Hardware)
This example is near identical to the Software example above but also enables resetting the hundredths register using the RV-8803's EVI pin along with
resetting it via serial commands. The EVI pin can be toggled either through the on board button or by controlling the EVI pin with a GPIO pin on your
microcontroller (or other external control mechanism). Resetting the hundredths register using the EVI pin is enabled by this line of code:
rtc.setEVICalibration(ENABLE);
Enabling this bit tells the RV-8803 to reset the hundredths register when it sees a LOW event on the EVI pin. This event can either be triggered by
pressing the button or pulling the EVI pin LOW. The code will print the RV-8803 is ready for a button press or other event on the EVI pin. When that pin is
triggered it prints out the the hundredths value pulled from the RV-8803's time register over serial. If you want to verify the register is set, open the serial
monitor and toggle the EVI pin and the code should print out: Hundredths set to: 00 .
The code also toggles the RESET bit back to 0 so it is ready for another event if you want to set the hundredths register back to 00 again.
Example 4 - Interrupts
Since the RV-8803 has several types of interrupts, we have split the interrupt examples into sub-examples as well. Each one will enable and configure a
different interrupt and demonstrate how to use it. To integrate any of these examples to your project, just tie the INT pin to a GPIO on your microcontroller
that is usable for external interrupts to trigger whatever behavior you would like when one of these alarms or timers are triggered. If you have never
worked with processor interrupts before, we have a tutorial covering how to work with them in Arduino here.
Example 4A - Alarm Interrupt
This example configures the Alarm Interrupt function. The code first defines the variables the RV-8803 will look to match to trigger the Alarm Interrupt and
selects which of these variables the RTC will look to match to trigger the alarm. To set it to a different time simply edit these values:

Related product manuals