Summary of Interfacing of PIC16F877 with DS1307 (RTC) code and Proteus simulation
This article details interfacing a DS1307 Real-Time Clock with a PIC16F877 microcontroller using C code in MPLAB. The DS1307 connects via I2C, with RC4 as SDA and RC3 as SCK, utilizing 10K pull-up resistors. An LCD displays the RTC data for demonstration, while Proteus simulation validates the circuit.Parts used in the DS1307 RTC Interfacing Project:
- DS1307 RTC
- PIC16F877 microcontroller
- LCD (connected in 4-bit mode)
- 10K resistors (for I2C pull-ups)
- MPLAB v8.85 software
- HI-TECH C v9.83 compiler
- Proteus v7.10 simulation tool
- I2C Debugger Tool
It is assumed that you know how to interface LCD with PIC16F877 microcontroller in 4bit mode. If you don't then please read this page first, before proceeding with this article. It is also assumed that you know how to use i2c module in PIC16F877, if you don't then please read this page first.
The result of simulating the code in Proteus is shown below.
In the above circuit[1], RC4 pin is being used as SDA pin and RC3 pin is the SCK pin. Both of these pins are pulled up using 10K resistors as required for i2c protocol. DS1307 RTC is the slave device, while PIC16F877 is configured to be the master. LCD is also attached with PIC16F877, just to show the values received from the RTC, otherwise it is not required in this circuit. Proteus provides an 'I2C Debugger Tool' which is attached on the SDA and SCK pins in the above circuit, this debugger shows all the activity on i2c bus[2]. It is attached in the circuit just for debugging purposes.
Code
The code for the main function is shown below.
Downloads
DS1307 RTC interfacing with PIC16F877 code was compiled in MPLAB v8.85 with HI-TECH C v9.83 compiler and simulation was made in Proteus v7.10. To download code and Proteus simulation click here.
For more detail: Interfacing of PIC16F877 with DS1307 (RTC) code and Proteus simulation
Quick Solutions to Questions related to DS1307 RTC Interfacing Project:
- How is the DS1307 RTC connected to the PIC16F877?
The DS1307 uses an I2C interface where RC4 acts as the SDA pin and RC3 acts as the SCK pin. - What type of resistors are required for the I2C connection?
Both SDA and SCK pins must be pulled up using 10K resistors as required by the I2C protocol. - Which software was used to compile the code?
The code was compiled using MPLAB v8.85 with the HI-TECH C v9.83 compiler. - Can this project be simulated in Proteus?
Yes, the code was simulated in Proteus v7.10, and results are shown in the article. - Is the LCD necessary for the core functionality of the RTC?
No, the LCD is attached only to display values received from the RTC and is not required in the basic circuit. - Does the PIC16F877 act as a master or slave device?
The PIC16F877 is configured to be the master device while the DS1307 RTC acts as the slave. - What tool can be used to debug I2C activity in Proteus?
Proteus provides an 'I2C Debugger Tool' which can be attached to the SDA and SCK pins to show bus activity. - What language was used to write the code?
The code for interfacing the devices was written in the C language.
Related projects
PIC16F877 Driving LCD in 4-Bit Mode using PIC16F877 with Proteus Simulation
Introduction This microcontroller project shows how a PIC16F877 can drive an LCD display using 4-bit mode inside a Proteus simulation.The project demonstrates...
Programmers & ICSP · PIC16F877AEPE PIC/LCD Demo using PIC16F877 with Proteus Simulation
IntroductionThe EPE PIC/LCD Demo is a classic microcontroller project that demonstrates how a PIC16F877 can fully control a PG12864F graphical LCD.Designed as...
Motors & Robotics · PIC16F877AEfficient Sun-Following Robot: A Solar Tracker with Microcontroller Control
Abstract The impending global challenge of dwindling non-renewable fuel resources underscores the urgency of transitioning towards renewable energy alternatives like solar power....
Communication & Interfacing · PIC18F4520CAN FD Node based on a PIC18 Microcontroller
The introduction sets the stage for an embedded systems project that involves developing a Embedded C CAN FD project using the MCP2517FD...
Communication & InterfacingLAN9662 Gigabit Switch: Optimized for Industrial Ethernet
Introduction It should come as little surprise therefore that one element of what is now more commonly referred to in some circles...
Communication & InterfacingPIC Microcontroller: Fundamentals & Applications for Students
Introduction Microcontrollers are the key components in the embedded systems market. A variety of embedded systems was formed and developed after the...

