> BUT the FIFO at MBAR+0x8A7C (DRFDR_0) shows (lower 16 bits): 0xF020.
> I can't figure out where that 0xF0 comes from.
Neither can I. From that trace you should be getting 0xff20. It is likely the pin is floating at this time and your logic analyser and the MOSI pin have different ideas on what voltage "1" and "0" are, or they weren't the same capture.
Back to basics. At the bottom and on the wire, with SPI you shift one bit OUT and shift one bit IN at the same time. At a higher level you may be dealing in bytes, in 12 or 16-bit commands.or with a whole complicated protocol. You may be writing and reading a byte at a time, using FIFOs, rings or DMA, but the wire doesn't know and doesn't care. Frankly, all the complicated stuff gets in the way of getting it working.
So when you're sending a "read command" out, you can't stop the hardware from shifting a byte into the FIFO at the same time, and you can't read the results back in without shifting something out.
With some RAM or EEPROM chips, as long as you keep clocking, it will keep providing the next byte of data in the memory. So there's no fixed limit to how long an SPI sequence can be.
So it is "drop chip-select, shift out N bits while shifting in N bits, lift chip select". "N" can be between 1 or 4 or more usually 8 and a few million if you're reading an SPI boot ROM. You then get to make sense of the returned bits - in your case you throw the first one away and read the second one.
But the code in rtc-r9701.c is smart enough to know how to do that already. A call to it to "read the time" will have it perform SPI driver calls to generate the right bit streams on the wire and interpret the results properly.
But only if you get the configuration set up the way it expects it to be, which is probably byte-wise. Why? Because that works on any hardware. Not all SPI drivers can handle bit lengths other than multiples of 8.
In the DSPI, each entry written to the transmit FIFO can send between 4 and 16 bits. As a consequence, the receive FIFO will fill at the rate of one receive FIFO entry per transmit entry, with between 4 and 16 valid bits in it. The receive FIFO is 32 bits wide, but only 16 bits are valid, and only four bits may contain data if that's how many you sent. This isn't clear in the documentation.
Tom