1
\$\begingroup\$

I have an HD146818 (Motorola MC146818) integrated circuit, which is a real-time clock. I would like to build a simple clock on it, which will control an 8-segment display. I read the datasheet for this chip and it is not clear to me whether the chip can operate independently without a microprocessor. My assumption is that time information such as hours, minutes, and seconds, etc. are stored in the HD146818, and access to them, i.e. reading, is done through the address pins A0-A7 (pin 15 "high"), taking into account the appropriate configuration of other pins for data reading. I assume that I can decode the A0-A7 pins (from binary to BCD) and read the time. Is this possible?

https://datasheetspdf.com/pdf-file/555707/HitachiSemiconductor/HD146818/1

\$\endgroup\$
11
  • 1
    \$\begingroup\$ Hate to be a smart a** here, but... why?! Even basic MCU can do all those things, like initialize RTC, read its data, convert to 8-segment, setup alarms, read and debounce buttons for setting time/alarm, generate waveform for alarms and many more. All without additional chips or discrete components. Cannot be simpler than that. \$\endgroup\$
    – Maple
    Commented Jul 21, 2023 at 16:50
  • 1
    \$\begingroup\$ @Maple 1. Because I don't write a code (yet) 2. because I like to experiment with an old school digital logic chips :) \$\endgroup\$ Commented Jul 21, 2023 at 16:56
  • 1
    \$\begingroup\$ That is fair, and something I used to do too. May I point out, however, that with some devices (and this RTC is one of them) the amount of logic chips and interconnections between them requires schematic design that becomes indistinguishable from writing logic expressions for MCU. This is exactly the project where electronics and software merge. \$\endgroup\$
    – Maple
    Commented Jul 21, 2023 at 17:15
  • 1
    \$\begingroup\$ @JerzyPrzezdziecki but the point that maple made was that you still end up with something that requires you to write code - just that's it's not code for a well -understood programming language for a microcontroller, but a code that controls your own custom very complicated state machine. (It might not be textual code, but pages full of drawings and tables and timing diagrams.) That is the exact opposite of "simple as possible". There's a reason microcontroller exist, and it's that they make this exact kind of thing orders of magnitude easier than building things in logic hardware yourself :) \$\endgroup\$ Commented Jul 22, 2023 at 8:04
  • 1
    \$\begingroup\$ Turning it around, this is simply the wrong chip for the application you want to build. This chip was designed specifically to be easy to interface to an MPU. You're creating an uphill battle for yourself by trying to avoid that. More to the point, there are other chips with the same functionality that are designed to be connected directly to displays. If you want a "simple" project, you should start with one of those. \$\endgroup\$
    – Dave Tweed
    Commented Jul 22, 2023 at 11:38

2 Answers 2

1
\$\begingroup\$

Yes, this chip operates as a kind of "magic RAM" -- once you have it started.

Note in particular the process for setting the time involves writing to "Register B"; and having the correct divider selected in Register A. If you can make the right signals without a microcontroller, this chip will certainly work.

It's certainly possible to do it with a state machine, if that's what you want to do.


Edited to add

"However, in this diagram, both reading and writing occur simultaneously... this seems impossible?"

They have just presented both timings on a single diagram, which can be confusing to read. (The Intel timings are shown on two diagrams 2 and 3; similar but slightly different. You choose whether you want to do the Motorola-style or the Intel-style, both will work.)

READ When you read from the chip, you make R/W high. You put the address on AD and take AS low: the device latches the address. You disable your outputs, and then after you make DS high, after TDDR the device will put its data on the AD bus (shown in red) and you read it. enter image description here

WRITE When you write to the chip, you make R/W low at the appropriate time, and put the data you want to write on the AD bus. When you take DS low the device will read the data. enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ Thank you. what do you mean by "If you can make the right signals without a microcontroller, this chip will certainly work." I understand that I need to start it first. Is the setting of the registers done through the A0-A7 pins? Or other ones? \$\endgroup\$ Commented Jul 21, 2023 at 17:04
  • 1
    \$\begingroup\$ You set the starting values by writing to RAM (yes, through AD0-7), having set the registers. (see fig 15 and text above it.) By "Make the right signals" I mean eg fig 1 etc which is how you read/write to the device. Your logic must produce AS, DS, R/W etc. \$\endgroup\$
    – jonathanjo
    Commented Jul 22, 2023 at 9:08
  • \$\begingroup\$ As I understand it, I need to reproduce the timing diagram from figure 1. However, in this diagram, both reading and writing occur simultaneously... this seems impossible? How can I provide these sequences so that data is first written and then read? \$\endgroup\$ Commented Jul 22, 2023 at 11:57
1
\$\begingroup\$

Of course it is possible. The chip keeps time with a battery even when MCU is turned off.

However, There is a but.

You would need to connect to the bus and create that bus logic with logic chips, FPGA or CPLD which allows you to initialize the chip, set time and read the time for displayig it.

It is certainly not impossible, and a neat idea, but I don't see why would anyone even bother to try it in practice.

It will of course depend on if you are already an expert working with logic at that level, but most people would likely write a few lines of program code instead.

Now, if you really want to make a clock, you would likely buy an easy to program MCU board, where the MCU already contains a built-in RTC, so you don't even need to use that RTC.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks. "You would need to connect to the bus and create that bus logic with logic chips, FPGA or CPLD which allows you to initialize the chip, set time and read the time for displayig it." - do I need to initialise it once? \$\endgroup\$ Commented Jul 21, 2023 at 17:21
  • 1
    \$\begingroup\$ @JerzyPrzezdziecki Yes but you need to decide if you want battery backup or not, and if you do, then your "logic" needs to check if the chip just started from full power-off state without correct time or is it already previously initialized and ticking with correct time. That may not be the main point of the logic you want to design. \$\endgroup\$
    – Justme
    Commented Jul 21, 2023 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.