Interfacing DS1307 Real time clock with PIC16f877
In any advance project we need real time clock synchronize with our work and for this purpose the best option is DS1307 (RTC Ic). Interfacing DS1307 Real time clock with PIC16f877 is done by I2C communication. To know I2C protocol you may refer my previous post “Interfacing external EEPROM with PIC Microcontroller”. To know about Interfacing DS1307 Real time clock with PIC16f877, we should know something about DS1307 IC.
Real time clock ( DS1307):
The DS1307 serial real-time clock (RTC) is a low-power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I2C, bidirectional bus. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The date at the end of the month is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The DS1307 operates as a slave device on the I2C bus. Access is obtained by implementing a START condition and providing a device identification code followed by a register address. Subsequent registers can be accessed sequentially until a STOP condition is executed.
In this project we will see how we interfaced DS1307 with pic16f877 via I2C protocol. After interfacing DS1307 we recive the data from DS1307 and display it on LCD. Weall ready know before that DS1307 is send data in full BCD format. So we have to convert this data in digit and send to display on LCD.
Now question is how we convert BCD number to 4 bit number?
For getting higher nibble we use command
return ((bcd >> 4) + ‘0’) : it means the number will be Binary Right Shift 4 times with loading zero on left side.
For getting Lower nibble we use command
return ((bcd & 0x0F) + ‘0’) : it means we did and operation 0F with BCD number.
For more detail: Interfacing DS1307 Real time clock with PIC16f877
From Schematic to PCB Production, Just Need One Tool
Free Circuit Design Software: learn to use Editor quickly and easily
Cheapest PCB: 10pcs 2-layers 10cm×10cm only $8.21, 3-day build time, 100% E-test
Current Project / Post can also be found using:
- real time clock using pic16f877a
- pic real time clock y calendar
- real time clock (ds1307) using pic16f877a
- real time clock circuit