Categories: Hookup Guide-PIC

OpenLab RTC Hookup Guide

RTC

A real-time clock is a battery powered IC that is usually included in a computer motherboard. A small memory unit in these ICs stores the system description or set up values, including the current time values stored by the real-time clock. The time values are for the year, month, date, hours, minutes and seconds. The registers inside the RTC can be configured by the user. RTCs are widely used in embedded systems. The user can write the desired time value into the memory locations in the IC. RTC will start to run from the defined time just like a watch. It can count leap years and knows how many days are in a month. The RTC can run both in 12 hr and 24 hr mode. The day register is incremented at midnight.

The communication between the processor and the RTC is carried out through serial communication protocols. DS1307 is a serial RTC module manufactured by Maxim. RTC is low power, full binary coded decimal clock/calendar IC with 56 bytes of RAM. The DS1307 has a built-in power sense circuit that detects power failures and automatically switches to the backup supply. Timekeeping operation continues while the part operates from the backup supply. DS1307 communicates with the microcontrollers through an I2C serial interface.

DS 1307

X1 and X2 are pins for 32.768kHz crystal. SCL and SDA are clock and data lines for the I2C communication protocol respectively. VCC is the primary supply source for the RTC. Timekeeping registers are updated when VCC is connected. VBAT is the backup supply input for any standard 3V Lithium cell or other Energy sources. SQW is square wave output enabled SQW outputs one of the four square wave output frequencies(1KHz,4KHz,8KHz,32KHz).

I2C Protocol

I2C is a two-wire synchronous serial communication protocol developed by Philips. In I2C the devices which support I2C protocol are connected to the controller using two lines, SDA for data transfer and SCL for Clock information.The device generating the clock is called the master in an I2C bus and the device accepting the clock and works according to it is called slave. The communication is initiated by the master device in I2C.

The above block diagram is a typical example for an I2C network. SDA and SCL lines of the I2C needs to be pulled to VCC using the pull-up resistors due to its open drain load. Each slave in the I2C has a unique 7-bit address which is used to access the device. A total of 128 slave devices can be connected to the I2C. I2C stands different from other communication protocols like SPI in its unique feature of multiple master communication, in which a slave can be accessed by more than one master.

Communication process is as follows

  1. Master device generates a START condition in the I2C bus. Upon receiving the start condition all slaves will wait for the 7-bit device address.
  2. Following the START condition, a master will send the 7-bit device address.
  3. The device which matches the 7-bit address will send an acknowledgment, thus communication between master and slave is established.
  4. Upon receiving the acknowledgment data transfer is carried out either to write into the slave or to read from the slave.
  5. The communication is stopped by initiating the stop condition by the master device.

OpenLab RTC Module

OpenLab supports RTC with I2C interface (DS1307)

Connection step is as follows

  • Place the RTC in the IC base
  • Connect the battery to the battery connector
  • Use a jumper cap to short J19 and J17 to complete the hardware set up for interfacing the RTC.
Share