SPI sends old bytes on MISO when no data available
I'm creating some SPI slave code using an STM32 on a G474RE board. The protocol is that the master sends two command bytes, and then the slave sends back a single byte response. My SPI is a little rusty, but as I recall the way you do this is to have the master send a third byte (just 0x00) and the slave response will show up in MISO.
That's working just fine, what I'm curious about is the data that shows up on MISO while the master is sending his two command bytes on MOSI. It seems like the STM32 just picks a random byte it sent sometime in the past and sends it again. It's not a big deal, I really only care about the third byte, but it makes me a little nervous to have random data wandering around on SPI.
Am I doing something wrong? Is this just the way the STM32's SPI works? Is there a way to tell the STM32 "if you have nothing to send, send a zero"?
Thanks,
Chris
