GARTHWILSON wrote:
Or maybe it takes 1.2µs (a thousand times as fast as 1.2ms)?
Yes, 1.2µs. Sorry it's given in ns in the datasheet and I got my SI-prefixes mixed up on converting.
GARTHWILSON wrote:
(at 5MHz) handles the LCD (plus five other things) through the first VIA
I only have one VIA and there isn't enough pins left on it to drive the LCD screen. I would very much rather not add a second VIA to the system if I can avoid it as VIAs are not cheap components, and they take up a lot of space (relatively speaking compared to a couple of logic gates). Also this is as much a learning experience for me as it is an attempt to make an efficient system. I've never done wait states before (more on that below), so its an opportunity to learn.
GARTHWILSON wrote:
the next thing is to check its busy bit before writing to it again.
I know about the busy bit, but it won't help for this issue. With the LCD directly on the CPU bus at 4MHz, the read/write timing specification is violated so I won't even be able to read the busy bit, let alone read or write anything else.
---
Link to LCD Screen DatasheetLink to LCD Controller DatasheetIf you look at the timing diagram on page 30 of the controller datasheet and the AC Characteristics table on page 32, one can see that the two critical timings for this purpose are Tc and Tpw. Tc is the total time between rising edges of E, minimum 1200ns; Tpw is the minimum width between the rising edge and the falling edge, minimum 480ns.
Overall I don't think that Tc is an issue because (with the possible exception of RMW instructions) I don't think its possible for the 65C02 to access the same memory I/O device quicker than once every four cycles... e.g. STA $C002 takes four cycles to execute, only the last one of which is an actual write to the I/O device. So, for the purposes of Tc, one could argue that the access rate has dropped from a potential 4MHz to a potential 1MHz. Yes, technically 1MHz is still too fast for Tc, but it certainly a lot better.
Tpw is a bigger problem though. E would be high for only 125ns on a 4MHz system (ignoring prop delays) and there really is no way around that. Not to mention Tdsw requiring a data setup time of 80ns before E's falling edge, so with prop times it'd be cutting it close. So, I think that for accesses to the screen I would need to stretch the access over three cycles. 125ns + 2*250ns = 625ns > 480ns. This has the additional bonus of increasing the total length of the cycle for the purposes of Tc and should therefore keep that in spec too, taking into account the stuff I've already stated.
Two options for stretching the screen accesses: 1. stop / disconnect PHI0 for a specified period. 2. Use RDY. I prefer the latter option, gating the clock seems like a bad idea. That brings me to
André Fachat's RDY Generator Mini Project, which looks like it will do what I want, but I'll be honest, despite staring at it for hours I have no idea how it works, and I am uncomfortable using glue logic that I don't understand. Also there might be a simpler way to implement wait states that you lot have hidden up your sleeves; this one appears to require a minimum of three extra chips.
I'm going to do some thinking and experimenting in the mean time, but I shall await your collective wisdom with anticipation.
_________________
Want to design a PCB for your project? I strongly recommend
KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of
Retro Computing and
Arduino components you might find useful.