Hi guys
I spoke too soon and have spent days trying to get it right but I'm missing something.
I attach the schematic, the Z80 source code, the Arduino main loop and relevant subroutine code and some logic traces.
IORQ is ORed with RD to provide IORD and IORQ is ORed with WR to provide IOWR.
D and CLK are connected to ground to prevent spurious actions.
When an I/O WRITE is performed, the flip-flop should be cleared by IOWR, forcing the Z80 to WAIT until the Arduino code takes SET low, allowing the Z80 to continue.
If the flip-flop is not connected to WAIT, I get a very nice clean trace of the two INs and the five OUTs.
IORDs are not associated with the flip-flop but I should still be able to detect the five OUTs which I cannot. Of course, if I cannot detect them, I cannot reset the flip-flop to get the Z80 going again after a wait.
If the flip-flop is connected to WAIT as it is meant to be, I get the odd results shown in the second trace. While the WAIT process seems to have worked on the first Z80 OUT command, after it has been cleared, subsequent ones seem wrong, not following through with the IOWRs.
Please can anyone explain what is going wrong here ?
Thanks
Z80 source code
.org 0
in a,(0)
in a,(0)
out (0),a
out (0),a
out (0),a
out (0),a
out (0),a
halt
Arduino code
void loop()
{
while (digitalRead(Z80_IOWR) == HIGH) {};
// Deal with the I/O requests here
z80_reset_wait();
}
// Clear the wait condition
void z80_reset_wait()
{
digitalWrite(Z80_WAIT_RESET_PIN, LOW);
digitalWrite(Z80_WAIT_RESET_PIN, HIGH);
}