The RV-8523 is a real-time clock (RTC) with 20 registers each eight bits wide. The registers, numbered from 00H to 13H inclusive, are listed on the right in Figure 4. The RTC has an internal supply voltage monitor and can switch itself automatically over to battery power. As the lead photograph shows, the device is available in module form complete with battery holder.

After the register number (from 0x00 to 0x13) has been sent, the register can be accessed. In contrast to the LM75 this device automatically increments the register pointer, wrapping round from 0x13 to 0x00. It is therefore possible to read from or write to all twenty registers in a single operation.

Suppose for example that we wish to read just the date and time. We set the register pointer to 3 and read seven bytes. Using the Arduino Wire library the code might look like the following.

Wire.write(byte(0x03)); // set register number to
Wire.requestFrom(0x68, 7); // read time and date
seconds = Wire.read();
tenseconds = (seconds >> 4) & 0x07; seconds &= 0x0f;
minutes = Wire.read();
tenminutes = (minutes >> 4) & 0x07; minutes &= 0x0f;

The resulting values are BCD-encoded, and so conversion to binary may be required.

Besides the clock itself, the RV-8523 also has an alarm function that can produce an interrupt at a specified point in time. The only wrinkle is that although the INT_1 output goes low at the appointed hour, it does not automatically go high again: it is necessary to reset the alarm interrupt explicitly with a write to AF in control register 2.

Some operating systems, including Raspbian, already have a driver for this device built in (rtc_pcf8523). In such cases there is no need for any programming if you are only interested in the current date and time, as the hwclock command will talk to the RTC and read or set the clock. An rc script run at boot time can be used to run this command to set the system clock automatically, and at power down the updated system time (which may have been adjusted either manually or over the network) can be written back to the RTC. This arrangement allows a Raspberry Pi, even without a network connection, to maintain its clock across a power failure with minimal additional hardware. However, if you wish to use the alarm feature of the RTC, then you will need to get involved in some programming. Once the RTC has been set using a Raspberry Pi, it can then be connected to an ATmega or Arduino. The back-up battery on the module ensures that the clock continues to keep time. Then it is just a matter of a few lines of code to read the time into the ATmega or Arduino.

fig 1 11 RV 8523

13. February 2019 by sam
Categories: Components | Comments Off on RV-8523