Here is a response to an almost identical question (posted from an almost identical from address???) that was recently posted on the Freescale mc68hc11 email group. Clock projects must be popular that semester --- In , "aznxstryder1" <aznxstryder1@y...> wrote: > > Can anyone explain to me how to write this kind of program. I got > the display on the lcd down, just need to write to program in. Any > algorithm or suggestions on how I would go about on writing this > program. Any suggestions would be very helpful. thanks Below I've provided some C-like pseudocode that shows how to keep time once you've created a 1-second timing routine. The first thing you have to do is figure out a way to generate a periodic signal that is activated once per second. You could use the RTI (Real-Time-Interrupt) source, although this typically generates intervals that are not even multiples of 1 second. A better solution would be to use one of the Output Compare channels (configured such that it does not utilize the output pin associated with it) to generate a timing signal that is an even fraction of 1 second. This is not overly difficult to do, but it does require some understanding of the HC11 timer/output compare subsystem. Review these sections in the HC11 Reference Manual, and if you still can't figure out how to go about setting up the output compare to generate periodic interrupts/timing signals, I'll do what I can to help you. Once you have a 1 second timing source, call a routine based on the pseudocode below to update your clock. I have designed this routine to use individual RAM locations/variables for each digit to make conversion for display easy. This is less efficient than, say, maintaining the 'two digit' seconds counter in one byte location, but is much easier to convert for display. Here's the pseudocode for the timekeeping routine: Increment [unit seconds] if [unit seconds] > 9 then [unit seconds] = 0 Increment [tens seconds] If [tens seconds] > 5 then [tens seconds] = 0 Increment [unit minutes] If [unit minutes] > 9 then [unit minutes] = 0 Increment [tens minutes] If [tens minutes] > 5 then [tens minutes] = 0 Increment [unit hours] If [unit hours] > 9 then [unit hours] = 0 Increment [tens hours] endif If ([tens hours] = 2) and ([unit hours] = 4) then [unit hours] = 0 [tens hours] = 0 Call date update routine (if needed) endif endif endif endif endif --- Avoid computer viruses, Practice safe hex --- -- Specializing in small, cost effective embedded control systems -- http://www.smithmachineworks.com/embedprod.html Robert L. (Bob) Smith Smith Machine Works, Inc. 9900 Lumlay Road Richmond, VA 23236 804/745-2608 ----- Original Message ----- From: "asianxstryder1" <> To: <> Sent: Sunday, December 12, 2004 7:23 PM Subject: [m68HC11] Not sure about how to write this program on a clock > > Can anyone suggest somne kind of algorithm or a flowchart( which I > dont know how to make) on a program that keeps track of a 24 hour > time period that is displayed onto the LCD screen of the EVB board. > I dont really know the algorithm to use to be able to write this > program nor how to make a flowchart. Any kind of help would be great. > > > -- ------ > Yahoo! Groups Links > > a.. To |