DS1307 RTC With 7 Segment Display
Some time ago I built a DS1307 RTC board. This uses the I2C bus configuration.
For a display a standard EB-005 LCD board was used.
http://www.matrixmultimedia.com/mmforum ... rtc#p27889
This project will now use a 4 x 7 segment LED Module which also has I2C connections.
The unit is a Byvac BV4513
The unit can also be programmed using the serial protocol
Display Programming
It is not possible to send the hour & minute values to the display directly as in the case with the LCD.
Therefore, the raw data read from the DS1307 RTC chip is split into individual digits.
Hour Data
bit0 = ( Reg_Hour >> 4 ) AND 0x03
bit1 = Reg_Hour AND 0x0F
Minute Data
bit2 = ( Reg_Minute >> 4 ) AND 0x07
bit3 = Reg_Minute AND 0x0F
Each digit is then sent sequentially to the display
I2C Commands
The display address is 0x62
Command 1 = Set Brightness
Format <Start – Address – 1-(0 to 250)-Stop>
Command 2 = Clear Display
Format <Start – Address – 2-Stop>
Command 3 = Send Byte
This command is not used in this program.
It is to send non standard characters by lighting certain segments
Command 4 = Send Number
Format <Start – Address – 4 –LED Digit – Number – Stop>
Command 51 = Decimal Point
Format <Start – Address –5-Led Digit – ( 0 or 1) –Stop>
0 turns off DP
1 turns on DP
Program Macros
Init
This sets up the I2C bus and configures the address.
Brightness
Sets the display brightness.
DP
Turns on the decimal point
Read Time
Reads the time from the DS1307 Chip as BCD
Hours = Reg_Hour
Minute = Reg_Minute
Display Time
This takes the data from the Read Time macro
And converts it to the decimal values as show above.
Each digit is then sent to the display module in the following order.
Hours (Tens)
Hours (Units)
Minutes (Tens)
Minutes (Units)
The display only has 4 digits so it is not possible to show seconds in this application.
Note
A second display could be used, though this would mean changing the address of one of the displays, as all devices on the I2C bus must have unique addresses.
DS1307 RTC Module
The DS1307 RTC module is programmed before being connected up to this project.
This is done by entering the data from a keypad.
The RTC is battery backed, so the data can be retained for several years with power off.
The data must be sent to the RTC in BCD format.
Before reading from a device on an I2C bus the device must first be set to write mode
Start
Transmit write address to device
Transmit the register to be read
Restart
Transmit read address
Read Minutes (Last Byte = 0)
Read Hours (Last Byte = 1)
Stop
Setting Last(Byte) = 1 is the "Not Acknowledge" to end the read cycle.
Notes
1 ) Only one set of pull up resistors is needed on the bus. In this case they are on board with the
DS1307 RTC.
2) The switch on the RTC is to turn the battery back up on or off.
DS1307 RTC With 7 Segment Display
Moderator: Benj
- JohnCrow
- Valued Contributor

- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
DS1307 RTC With 7 Segment Display
Last edited by JohnCrow on Sun Nov 20, 2011 10:59 am, edited 1 time in total.
1 in 10 people understand binary, the other one doesn't !
- JohnCrow
- Valued Contributor

- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
Re: DS1307 RTC With 7 Segment Display
16 Bit Version
The board was also tested using my EB064 16bit programmer
For this I used a 30F3014 device
8Bit Version With Date
This version now also can show the date in the format DD.MM
Date is accessed by pressing the RHS of the 3 push buttons on the Clock Board.
This is connected to Port RC0
The board was also tested using my EB064 16bit programmer
For this I used a 30F3014 device
8Bit Version With Date
This version now also can show the date in the format DD.MM
Date is accessed by pressing the RHS of the 3 push buttons on the Clock Board.
This is connected to Port RC0
1 in 10 people understand binary, the other one doesn't !