Real Time Clock

Project Demo: April 25th, 2019

Abigail Stroh and Louis Rosenblum

Project requirements

The point of this lab was to read the date and time from a real time clock and display the values on the LCD. The initial real time clock register values had to be user inputted and all communications were done using I2C.


LCD Slave:
In order to initialize the S08 the watchdog needed to be disabled, interrupts needed to be enabled, the stack pointer needed to be initialized, and the program code needed to be set at $E000. Then the I2C registers were initialized to act as a slave within the I2C module. Then certain pins were set as outputs to the LCD and registers were set up for the LCD to display properly.

Keypad Master:
Just like the slave, the watchdog was disabled, interrupts enabled, stack pointer initialized, and the program code set at $E000. The I2C registers were initialized for master mode, pins were set as inputs for the columns of the keypad and others were set as outputs for the keypad rows.

At program powerup the LCD would print the message “Date is “ on the top line of the LCD. The user would then enter 6 keystrokes to program the current month/day/year into the system. The LCD would print colons between each field after detecting two unique keystrokes. The LCD would then jump the cursor down to the second line and print “Time is “. The user would then be able to program the time with another six digits, representing hours/minutes/ seconds. The master HCS08 would then begin reading from the clock device. The program continually read from the seconds register, and whenever it noticed that the seconds register held a different value than the previous read it would infer that a second had passed. The master would then fire an I2C interrupt to the slave to inform it of the time change. Each time the slave received an interrupt it would increment the current time displayed by one second, by shifting the cursor and displaying the new value. Overflow situations were programmed to allow seconds to roll over into tens of seconds and tens of seconds to roll over into minutes.

For the master the code from lab 4 was used as a starting point. With the addition of the real time clock the I2C routines were used more and now the master had to receive data from the clock and not just send data. The first step was to write to the real time clock as well as the LCD with the original data and time. Then once that was complete, the clock was read from every second and the updated time was sent to the LCD.

Summary Comments:
The hardest part to implement was switching from writing to reading after the 12 digit inputs. Once this was done, the code was completely easily.

Other projects

Back to Top