Re: Todd's ELF-ish gets some more I/O #ELF #Homebrew

taf123
 

With the UART finished, I decided to add a CDP1879 Real-Time Clock.

This fits into the memory-mapped I/O space very nicely, so I put it at C400.

The data sheet has very useful ideas which I've incorporated.  First, it supports standby time-keeping down to 2.5V with the use of an external oscillator running at  32.768kHz, and is nice enough to supply the details for one based upon the 74HC04 hex inverter.

Again, I decided to use the DS1321 to handle battery cut-over.

Also, the data sheet shows an interesting application where you can stop the CPU clock to put the system into a low power mode, and then use the RTC's alarm capability to restart at a set time.  I decided to incorporate this as well.



The control of the CPU clock uses two 40107 open drain NAND gates.  The first is shown above in the RTC circuit.  The second one is installed over on the main board next to the CPU clock, where it can stop it by holding the !XTAL line LO.



The design in the data sheet uses the Q line to stop the clock.  But since I'm still using my Q line for the UT4 serial interface (until I update the code to use the freshly installed CDP1854 UART), I decided to use one of the lines from the two-level I/O latch to do this instead.



The CDP1879 is there in the upper middle, surrounded by it's support chips and the oscillator.





And the test run



Since the RTC sits in memory-mapped I/O space, I can access it directly from UT4 with memory reads and writes.



The first write stops the clock.  The second sets the time; ss mm hh dd MM.

The hour encoding includes the 12-hour am/pm flag, and can be in 24 hour format.  So it was 19:35:00 on Oct 28th when I did this test.

The next write starts the clock.  The following reads show the clock running.

I then shut off the power for about an hour, turned it all back on, and checked the clock.



looks like it's keeping time.  Yay.

These cell batteries I'm using work great for the CMOS SRAM in standby.  But since the 32kHz oscillator has to keep running, this circuit eats these cells.  I'll re-wire for larger batteries eventually.

When I did a longer test run, I found the time had slipped quite a bit.  So, it was time to search eBay for a used frequency counter so I could check and adjust that oscillator.

Sure enough, it was running fast, at 41.6kHz



At the maximum range on the trimmer cap, the closest I could get was 34.1kHz



So I put a 39pF cap in parallel to the trimmer



This brought my oscillator much closer to where it should be at 32.771kHz.



If you're going to play with oscillators, a frequency counter is a must, and there are some very good deals out there.

I still haven't gotten around to testing the CPU stop feature yet, so that will be a future installment.

The RTC has additional features as well.  It can interrupt on an alarm, or at regular set intervals.  It can also output a square wave based upon the internal counters.


Join cosmacelf@groups.io to automatically receive all group messages.