So, I bought the DS1302 Real Time Clock Module, and after building it and spending several hours trying to use it with my RC2014 Pro, I now realise that it only works with the RC2014 Zed, and requires RomWBW.
Is this module no use to me, or can I use it with the RC2014 Pro?
I am of course assuming that RC2014 Pro doesn't have an RTC since `clock()` and `time(t)` don't seem to work (`clock()` returns 0, and `time(t)` returns random values).
That said, now I think about it, I could have sworn that `clock()` was returning something other than 0 at one point, unless it was all a dream... And if it was returning something, maybe I have broken something since?
Nick wrote:So, I bought the DS1302 Real Time Clock Module, and after building it and spending several hours trying to use it with my RC2014 Pro, I now realise that it only works with the RC2014 Zed, and requires RomWBW.
Wayne wote:
Well, this is a software issue, not a hardware issue. CP/M 2.2 does not know what a clock is, so there is no way to integrate it with CP/M 2.2 per se. However, you could certainly write CP/M 2.2 programs that interact with it (set or display time). Such programs would run fine under RC2014 Pro.Is this module no use to me, or can I use it with the RC2014 Pro?Definitely useful if you write some software to leverage it.I am of course assuming that RC2014 Pro doesn't have an RTC since `clock()` and `time(t)` don't seem to work (`clock()` returns 0, and `time(t)` returns random values).I assume clock() and time(t) are referring to Z88DK. I'm not sure why Z88DK (when building for RC2014 Pro) would not support the DS1302.That said, now I think about it, I could have sworn that `clock()` was returning something other than 0 at one point, unless it was all a dream... And if it was returning something, maybe I have broken something since?
z88dk understands both clock() and time() because I did write a library for that.
Nick wrote:So, I bought the DS1302 Real Time Clock Module, and after building it and spending several hours trying to use it with my RC2014 Pro, I now realise that it only works with the RC2014 Zed, and requires RomWBW.
In the essence of "teach a man to fish, and he shall never hunger", check out some of the libraries I've prepared previously for various modules for the RC2014 here at z88dk-libraries.A you can get a good overview looking at the simple examples to support the TH02 Temperature and Humidity sensor.
One complexity (or specific thing to get right) is going to be linking the DS1302 interrupt into the RC2014 if you want to use a 32kHz timer. I haven't looked at the module to see how this would be done. Perhaps that wouldn't even be necessary for you to do, if you just want to calculate day time and day date by querying the DS1302 Module?
I'm actually not looking for accurate date/time, though that might be handy. What I really want is to count elapsed milliseconds, so I can run a function every n millis. I tried doing this with counting `while` loop iterations, but since some functions take several cycles, so results vary wildly. Arduino has a handy function called millis() which I use often.
> Spencer's Dual Clock ModuleAh, I actually have this module. I thought it was purely a clock for the CPU. Perhaps I misunderstood the use of this module?
> set to a slow speed, and connected to the NMI interrupt, orAre there docs on how to do this with C?
> But just as you can connect one output to a serial module block, you could connect it to the NMI bus pin to trigger timing increment code. I haven’t seen this done before though.Thanks Phillip, very helpful. It's quite interesting that nobody has attempted (or published work) to count millis in C with the RC2014; I believe millis() is a fairly well used function among Arduino developers. I was expecting clock() to do this, but it just returns 0.I wonder if using CP/M holding me back here of if it's unrelated.
Nick wrote:
> Got it. So it sounds like although the clock() function is included in z88dk, that's just for compliance. It sounds like z88dk's clock() supports the Z180 CPU (1997) via RomWBW HBOS, but before that, the Z80 was never designed to have inherent timing capability.
> So, it might be possible to create a Z80 clock() function, a la "connect it to the NMI bus pin [on Spencer's Dual Clock Module] to trigger timing increment code".
> Did I understand correctly?
You also can't use NMI in CP/M properly because CP/M was designed for
the 8080 and the NMI vector is actually part of the CP/M FCB space. As
you can't mask an NMI this is a somewhat fatal flaw in that proposal.
There are three ways to address it for timing events in my experience
unless you want to wire up a CTC and the extra bus wires plus small
BIOS change.
1. Use delay loops instead. In fact for short delays it's better
because you can find the Z80 interrupt takes longer to process