On 8/10/2022 at 6:55 PM, BruceMcF said:
(1) You don't necessarily have to slow down the clock. If a write to a particular address triggers an interrupt in the MCU (REQUEST), and the MCU can set a GPIO that shows up at an address as low when the MCU is not ready and high when it is ready (or visa versa) (ACK), then the protocol can check that the MCU is ready for the next step in the protocol. After all, you are programming for an MCU routine that you have also programmed, so you don't have to hit arbitrary times specified in a pre-existing protocol.
Note that ACK could actually only be a single GPIO output connected through to D7 (when reading the correct address in that I/O slot), so that "BIT MCURDY" can put the state into the sign flag for BPL / BMI to use. With that design, you don't actually have to put a BIT mask into the accumulator, because you don't care what the state of the Z flag is after the BIT operation.
(2) If you want to slow down the clock, you can use the RDY line. It should still have some support circuitry doing that, so that the RDY line setting by the MCU only connects through to the CPU when the MCU I/O address space is accessed. Unlike the NMOS 6502, the RDY line on the 65C02 holds the CPU for both reads and writes.
Stretching the clock is indeed a general option (and with a counter based clock circuit, you can even get an "unstretched" clock output for the VIAs so that the VIA clock input remains steady), but since the 65C02 clock circuit is presently using a binary counter and jumpers to allow setting the clock to 1MHz / 2MHz / 4MHz / 8MHz, it seems like a clock stretching circuit for the CX16 would be more complex than if the inputs to the binary counter are not already put to use in the circuit for something else.
Seems reasonable you could use the RDY pin for this purpose, if it can halt all operations as you describe.
The first option---doing this without clock stretching---I do not fully understand. If the SMC is to drive the data bus without clock stretching, even to put just a one bit ready signal there, mustn't that be done within the strict timing limits that
@Wavicle discussed above? And if the SMC was to drive the data bus outside those timing limits, wouldn't that corrupt the data bus?
EDIT: Another thing. In (2) I suppose the SMC must drive the RDY line within the 65C02 timing limits, that is 4--5 clock cycles for a microcontroller doing 100 MHz, according to
@Wavicle above. Could that be a problem, as the SMC has several interrupt driven tasks it's running in parallel---being a host=slave for two PS/2 devices? The SMC could easily spend more than 5 clock cycles handling an incoming PS/2 bit at the same time the 65C02 wants to read a value.