Quantcast
Channel: Clock - Timer Projects - PIC Microcontroller
Viewing all articles
Browse latest Browse all 218

Real Time Clock (RTC) Interfacing PIC18F

$
0
0

Introduction to RTC:

Real time clock also referred as RTC is an important device or integrated circuit which will keep the track of current time. RTC is mainly used in computers, mainframes servers and embedded applications (mobile phone, tablets, organizers, PDA etc).

The main function of the RTC is to keep the track of time of the device even though it is in off or turned off state. The best example is your computer, even though if you shut down your computer for really long time you can see the exact time on your desktop.

Battery is used as external power source and connected to the RTC, to keep the track of the system time even if your computer or embedded system is turned off.  If we use lithium battery as external power source RTC will work minimum 3 years even if your system is turned off.Real Time Clock (RTC) Interfacing PIC18F

Pin Configuration of PCF8563:

PCF8563 is a RTC and Calendar developed by NXP Semiconductor.PCF8563 uses bidirectional I2C (inter integrated circuit) for interfacing with other peripheral. The bus speed is 400 kbps and incremented automatically after each written or read data byte.

There are 8 pins which are on the IC as seen in the below figure

  • OSC1 and OSC0: These two pins connected by the 32.768 kHz crystal oscillator and which provide the source clock for the circuit.
  • INT: This pin mainly used to provide an external interrupt to the RTC. For example: in alarm application after the alarm occur it should set back to original state, to set back it to original state the user must give an interrupt to the RTC.
  • Vss: Ground
  • Vdd: Vdd is the pin where we have to give the supply voltage to the RTC. Battery is connected to the Vdd for uninterrupted power supply, even if the main supply voltage is turned off. The operating voltages are 1V- 5V.
  • CLKOUT: for all the application we cannot use 32.768 kHz clock for other application we may need small clock like 32 Hz, 1 Hz for microcontroller clock , input to the charge pump etc.
  • SCL and SDA: SCL is serial clock; SDA serial data pins which are mainly used to interface with the other peripherals through I2c (inter integrated circuit). Through these pins only data is exchanged between the other peripherals and RTC. Clock is given to the SCL and Data is given to the SDA.

Functional Features of PCF8563:

  • Provides year, month, day, weekday, hours, minutes, and seconds based on a 32.768 kHz quartz crystal.
  • Battery backup input pin and switch-over circuit.
  • Freely programmable timer and alarm with interrupt capability.
  •  Selectable integrated oscillator load capacitors for CL = 7 pF or CL = 12.5 pF.
  •  Internal Power-On Reset (POR).
  •  Open-drain interrupt or clock output pins.
  •  Programmable offset register for frequency adjustment.

PIC Microcontroller:

Peripheral Interface controller is developed by general instruments in the year 1975. Hardware architecture and reduced instruction set are used in it. Peripherals like ADC, PWM, OP-AMPS, TIMERS, CAPTURE/COMPARE and DAC etc are inbuilt in PIC microcontroller. Communication protocols like I2C, SPI (serial peripheral Interface) USART (Universal Synchronous Asynchronous Receiver Transmitter), CAN (Control Area Network), ETHERNET are used to communicate with the other external peripheral which are connecter to the PIC micro controller.

PIC is available in different architectural like 8 bit, 16 bit, 32 bit. According to the application we can use the architecture.

PIC 18F45K80 is a PIC 16 bit microcontroller developed by microchip and it belong to PIC 18F66K80 family. PIC 18F45k80 has 40 pin in PDIP (Plastic Dual Inline Package) and 44 pin in TQFP (Thin Quad Flat Package).

PIC 18F45K80 Features:

  • Program memory of 32 Kbytes and data memory of 3648 bytes
  • 40-44 pins and 35 I/O pins
  • Operating Voltage Range: 1.8V to 5.5V
  • On-Chip 3.3V Regulator
  • Operating Speed up to 64 MHz
  •  Up to 64 Kbytes On-Chip Flash Program Memory
  • Five CCP/ECCP modules
  • Five 8/16-Bit Timer/Counter modules  and Two Analog Comparators
  • Configurable Reference Clock Output
  • Charge Time Measurement Unit (CTMU) and  One Master Synchronous Serial Port (I2c and SPI)
  • Two Enhanced Addressable USART modules 12-Bit A/D Converter with up to 11 Channels Data Signal Modulator module.

PIN Diagram of PIC Microcontroller:

Related Post: PIC Microcontroller Architecture

Interfacing PIC with RTC:

Connect the RTC SDL and SCL pins to the PIC controller pins through the pull up resistor (Pull up resistor is nothing but giving the voltage to the resistors (5k – 10k) to the SDL and SCL wires, here we should give VCC voltage which is 5v).  Using the serial interface we can see the output in the terminal.Real Time Clock (RTC) Interfacing PIC18F schematiche

Circuit Diagram:

So by seeing the circuit we can easily understand how the connections are given. But care should be taken with the resistance value. The total project can be divided into three steps

  • Interfacing PIC18F to RTC.
  • Interfacing UART to PIC18F for serial communication purpose to see the RTC output in HyperTerminal of PC.
  • Interfacing RTC output to the Serial communication.

NOTE: same circuit and code can be used for PIC 16F and PIC18F series. In the code you have to change the pin configurations only in the initialization functions.

 

 

For more detail: Real Time Clock (RTC) Interfacing PIC18F

The post Real Time Clock (RTC) Interfacing PIC18F appeared first on PIC Microcontroller.


Viewing all articles
Browse latest Browse all 218

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>