This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

looking for example program for display a clock HH:MM:ss with 89C668

I am a beginner and am looking for example code to make a clock or a timer with 89C668.
using 7 segment or small LCD.

  • "I am a beginner"

    In that case, start by reading the uVision Getting Started guide, and working through the example projects in it.

    Then you will need the following documents, which describe the 8051 and its architecture:

    http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_ARCH_1.pdf
    http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_PROG_GUIDE_1.pdf
    http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_HARDWARE_1.pdf

    Then think about the "components" you will need for a clock:

    * A timebase - the "tick" of the clock;

    * A routine to count in hexagesimal (base 60 - for the minutes & seconds) and base 24

    * A routine to convert numbers to 7-segment format

    etc

    Put in the groundwork; give it some thought - call back if you get stuck.

    Have fun!

  • If you want source program for clocks with small LCD display, send me your email address at eduard.jadron@post.sk, I have my source code for clock created with RTX Tiny and 89C51RD2.

  • "I have my source code for clock created with RTX Tiny"

    Talk about a sledgehammer to crack a nut!

    An RTOS just to make a clock to display HH:MM:ss!!?

    Tom said he's a beginner; I hardly think that confusing the issue with multitasking is helpful!

  • The RTX program might not contain any multitasking per se. This is, after all, just RTX-51 Tiny. It's not like we're talking about a giant, bloated, Linux kernel.

    Since the kernel measures time, it might well be more understandable for a beginner to use os_wait() for 1 second than to jump right into directly programming a timer interrupt for themselves. Note that the os_wait() call also handles the problem of signalling your task at a fixed interval and not just a fixed timeout</a> after you call it.

    Still, in the long run I imagine it's worth while to open an 8051 architecture manual and learn how to program the timer yourself.
    (Especially if it's a homework problem! I doubt the prof would be looking an answer involving an RTOS... the convenience of covering up the details is exactly what you don't want when that's what you're supposed to learn.)

    At any rate, it's a pretty straightforward problem. Program a timer to interrupt at 1 second intervals. Count the seconds, mod 60. When you reach 60, increment the minutes (mod 60); when that reaches 60, increment the hour (mod 24).

    Display of the time value depends on your hardware (and could well be more difficult than all the rest of the problem). The data sheet for your display hardware will tell you what pins you have to twiddle to make numbers appear.