I may be on a road to nowhere with this but I've been trying to coax an SIO channel in my Z80 KIO into becoming an SPI master device (mode 0) with a little help from an ATTINY85.
For testing I'm talking to an SPI EEPROM (25LC256).
I've managed to get the SIO to clock out the correct stream of bits so that the 25LC526 responds, but I'm having trouble getting the SIO RX side to behave.
Below is an LA trace showing the various signals. TxD = MOSI and RxD = MISO.
The TINY85 is generating the KIO TX & RX clocks (KIO_CLK) and the SPI CLK to the 25LC256 as well as the SYNC signal to the SIO. The KIO is generating nCS on the DTR pin. The KIO sets RTS low to cause the TINY85 to generate sets of 8 clocks. nRTS goes high before the last byte of the packet as I'm using the TX Buffer Empty bit in RR0 to detect when the last byte has been transmitted. I've had to add in a short delay before setting nCS high.
The message going out is: 03 00 00 00 00 00 00 00 00 00 00 - which is a READ command (03) starting at address 0x0000.
What I get back is: 3F FC FC 00 00 00 DA 30 F1 30 F5 30. I've tried flushing the receiver by reading the RX register until the RX char available bit in RR0 isn't set, but I can't figure out where the initial 3F FC FC is coming from. Also I can't get the SIO to give me the last 2 bytes either.
It's as though there is some RX FIFO mechanism that's got stuck.
Looking through the Z80 SIO technical manual, I can't see anything that may trigger a complete reset of just the RX queue.