Exact timing of IN A,() and IN A,(C)

By RvS

Rookie (24)

RvS의 아바타

16-05-2020, 11:20

Dear MSX fans,
I am trying to read data via the joystick port at a high sample rate.
The IN instructions on the MSX take 12 (IN A,(n)) or 14 cycles (IN r,(C)).
I am trying to figure out at what cycle the actual data is read from the bus.
According to the manual IN A,(n) is 11 (4,3,4) T-states, I guess for MSX, this becomes 12 (5,3,4).
My best guess is that the actual read is in the last cycle (number 12).
Can anybody help?

Login or 등록 to post comments

By wouter_

Champion (437)

wouter_의 아바타

16-05-2020, 13:20

The first two M cycles are for fetching the instruction opcodes (both instructions are 2 bytes long). And obviously before the instruction is known, the actual IN operation cannot execute.

For when exactly within those last 4 cycles the operation executes you have to clarify your question. Do you mean the cycle when the device (the PSG in this case) sees the request or the cycle when the Z80 expects the result?

For details see "figure 7: Input or Output Cycles" in the Z80 user manual:
* During the 1st cycle the IO address is put on the address bus.
* During the 2nd cycle the /RD and /IORQ control signals are activated. When the device sees this it starts processing the request.
* The 3rd cycle is a wait cycle. This gives the device more time to respond.
* During the 4th cycle the Z80 reads the value from the data bus.

By RvS

Rookie (24)

RvS의 아바타

16-05-2020, 13:52

Thanks! This clarifies the situation.
I am not sure if the PSG samples the joystick port or if it just routes that line to the bus.
But this already limits the set to the last 3 cycles.

By RvS

Rookie (24)

RvS의 아바타

29-05-2020, 10:21

I attached a logic analyzer and it looks like it is feasible to get 115200 bits/s via the joystick port. A little more tweaking is required but checking the /IORQ line helps a lot: