I have a technical problem where I want to control the amount of data that is written to an SPI port depending on the data.
I have 8 L6470’s in series. The chip will send you back your data on the MISO pins if you clock in more than 8 bits per device. This means that to get back the data you are sending out you must send more than 64 bits (8 bytes) of data. So I send 9 bytes of data. The first byte is a control to ensure that the communications to the chips is not corrupted. If the first byte comes back and is not equal to what I sent, then I know something has gone wrong. I can’t have random data being sent to the chip, because it’s attached to machinery, invalid data can cause equipment damage or personal injury.
The chip processes the data when the CS pin is inactive.
I also have control over all the SW pins from the central µC. This allows me to execute an emergency stop on all L6470’s in the system via either a switch or a µC pin.
Here is my problem: I need to keep the CS pin active while I check the control byte to know if the data was sent correctly.
My current solution is to control the CS pin independently of the SPI bus. I set CS active > send the data > check the control byte > set CS inactive | resend data | perform some sort of emergency action.
Question: Is there a builtin way to keep the CS active after WriteRead?