EasyManua.ls Logo

sparkfun RV-8803 - Arduino Examples; Example 1: Set Time

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...
Extra Functions
uint8_t BCDtoDEC(uint8_t val); - Convert values in the RTC from Binary Coded Decimal to Decimal.
uint8_t DECtoBCD(uint8_t val); - Convert values in the RTC from Decimal to Binary Coded Decimal.
bool readBit(uint8_t regAddr, uint8_t bitAddr); - Read a single bit from the selected register.
uint8_t readTwoBits(uint8_t regAddr, uint8_t bitAddr); - Read two bits from the selected register.
bool writeBit(uint8_t regAddr, uint8_t bitAddr, bool bitToWrite); - Write a selected bit to a register.
bool writeBit(uint8_t regAddr, uint8_t bitAddr, uint8_t bitToWrite); - Write a selected bit to a register.
uint8_t readRegister(uint8_t addr); - Read a specific register.
bool writeRegister(uint8_t addr, uint8_t val); - Write a specific register.
bool readMultipleRegisters( uint8_t addr, uint8_t * dest, uint8_t len); - Read multiple consecutive registers.
bool writeMultipleRegisters(uint8_t addr, uint8_t * values, uint8_t len); - Write multiple consecutive registers.
Next up we'll go over the examples included with the RV-8803 Arduino Library.
Arduino Examples
Example 1 - Set Time
This example demonstrates how to set the time on the RV-8803 RTC to either the compiler time or a custom time. This is necessary to set the RTC's
internal clock to keep time so long as the RTC has power. First, the code initializes the RV-8803 on the I C bus and verifies the microcontroller can talk to
it. Next, it sets the internal clock. Take note of the following bits of code to set the RTC time to either the compiler or a custom time:
When setting a custom time, change these values at the beginning of the sketch:
//The below variables control what the date and time will be set to
int sec = 2;
int minute = 47;
int hour = 14; //Set things in 24 hour mode
int date = 2;
int month = 3;
int year = 2020;
int weekday = 2;
In the setup, this code selects either compiler time or custom time:
2

Related product manuals