My ongoing clock project needed a good time source. The clock is a simple project built from scratch using an ATMEL AT89C2051 microcontroller. It is a modernized variant of the Intel 8051 controller (MCS-51) using flash. The best part is the low pin count and compatibility with open source tools. The bad part is I was trying to use internal timer registers to track time and in a 24 hour period it was very difficult to get the time to stay accurate.

I have been writing the firmware in C and compiling it with SDCC. Then using a chip programmer to write the firmware to the AT89C2051.

The clock is a simple circuit with 4 seven segment displays on a circuit board I created in EagleCAD. I used Sunstone’s PCBExpress service to make a few prototype circuit boards using the output files from EagleCAD.

To work out the timing for bit-banging I2C to set and read the DS1307 I needed some better idea of what the communications looked like than what the data sheet for the DS1307 had. So I connected one to a BusPirate and used a logic probe to capture the signals. The logic probe I used is the Open Bench Logic Sniffer with the OLS Java Client.

After getting some good captures of a working I2C configuration I was able to write the C firmware for the AT89C2051 to create similar communications. The next work is to make a new circuit board in EagleCAD and get a few prototypes made.

Screenshots of I2C Transactions

OLS Java Client Screenshots from samples captured while using BusPirate to communicate with the DS1307 I2C RTC.

Bus Pirate

Open Bench Logic Sniffer

References

AT89C2051 Information

Open Bench Logic Sniffer