1st version

Many years back, one of my student approach me and telling me that he wish to make an alarm clock on his own, using a real-time clock, a microcontroller, a display and a buzzer. At first, I quite surprise he would propose this to me because nowadays alarm clock are rather cheap and available everywhere. On second thought, although alarm clock are being used daily but I never had a chance to make a alarm clock myself and I would admit that I got little knowledge on how to make an alarm clock. So I give him and myself a try.

I provide him Renesas H8/3694 breakout board I brought from Japan in 2007. I make a small development kit with necessary I/O devices to let my students familiar with this microcontroller and interfacing. He intent to use real-time clock IC from Texas Instruments, and TI are so generous to give him as sample. Nowadays, real-time clock IC comes in either parallel or serial data transfer. Parallel data transfer would have easier in code program but more pin connections and the IC itself is rather bulky, whereas serial data transfer would need more effort in code programming but lesser pin connections. He choose parallel data transfer to cut down his development time in code programming.

Schematic diagram - pdf

Due to limited resource and funding in project, he is only able to get a normal 16x2 lines LCD as a display. So the objective of the project becomes easier because he only required to have numerical clock displayed on the LCD, besides that, it is also possible to display date, month and year on the second line of the LCD.

Flow chart here!!

The code programming is rather simple, flow chart shown how does the program run on the microcontroller. It is not an essential to update the data from the real-time clock IC every second tick. It would need one reading from the real-time clock IC upon power-up and start counting using microcontroller's timer. Calculating the hour, minute and second are shown below:

clockNumericalDisplay{

.....

hourDisplay = realTime_cnt / 60 / 60; // calculate hour

minuteDisplay = realTime_cnt / 60; // calculate minute

secondDisplay = realTime_cnt % 60; // calculate second

displayLine1(hourDisplay, minuteDisplay, SecondDisplay);

.....

}