Hello @pengyong_zhang,
Thank you for looking into this. This is the procedure:
1. After I get the callback from the HAL that the transfer is complete I monitor the TC flag from the STATREG register in a while loop with a volatile timeout counter.
2. When the TC flag goes high I set the chip select GPIO pin high manually. Note that I print an error message here if the timeout counter has timed out, so it is within the timeout.
3. I see with my logic analyzer that the CS line goes up before the last bit has gone out on the line.
I've tried using the ECSPI_GetStatusFlag and grabbing the value from the register directly.
I've detected that sometimes the timeout counter is non-zero, so the TC flag goes from 0 to 1, but this does not happen every time and is not consistent with when the last bit has gone out on the line.
Note that this happens when I transfer more than the FIFO buffer size: I use a burst length of 8 and have a transfer of 512 bytes. However, to get past the limitation of 32-bit data in the HAL, I need to copy to a temporary 32-bit buffer of length 512 where each element is only filled with a byte.
This code is running on the M7 core.