How to get validation that SPI transmit has TX data on peripheral and is ready for master get it?
I am using the STM32L4S9AII6 clocked at 120MHz. This device is being used as a slave to a master that is clocked at a much higher frequency. They communicate over the SPI1 bus. I am trying to optimize the rate of communication between these two devices.
How do I validate that the SPI transmit API call has TX data sent to the SPI peripheral and is ready for master get it? I need to set a flag (GPO pin) to the master when the slave has finished processing a command and is ready for another command. When I try to set this "finished processing" flag immediately after the HAL_SPI_TransmitReceive_IT() API call the master sends the next command and attempts to retrieve requested data from the last command simultaneously. However, most often the slave misses the deadline and the data that was intended to be sent to the master doesn't show up until the next command cycle.
Obviously the MCU is not able to get the data to the SPI peripheral fast enough before the master comes asking for this data. So I need a way to check/validate that the data is on the SPI peripheral TX register before setting this flag to tell the master "Your data is here, come and get it".
Any suggestions on how to do this?
Thanks!
