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.

Parents Reply Children
  • 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.