Page 1 of 1

SPI Slave transmit function

Posted: Mon Feb 27, 2023 5:23 pm
by Uint64_t
I am in the function with the maximum delay waiting for the master to send me data in order to send him the data stored in sendbufer in response. But while I was waiting, I decided to change the data in sendbufer. The question is what data will go to the master new or previous.
Task1
t.length=128*8;
t.tx_buffer=sendbuf;
t.rx_buffer=recvbuf;
ret=spi_slave_transmit(RCV_HOST, &t, portMAX_DELAY);

Task2
sendbuf[0] = 0xA5;
...

Re: SPI Slave transmit function

Posted: Tue Feb 28, 2023 12:41 am
by ESP_Sprite
It's undefined, as in, we don't guarantee anything about the state the data is in. In practice, it may be that the first few words still are 'old' data as they're already hoovered up by the DMA subsystem and waiting in a FIFO somewhere, but whatever behaviour you see, better not depend on it as there's no guarantee it won't change in future HW/SW versions.

Re: SPI Slave transmit function

Posted: Tue Feb 28, 2023 5:44 am
by Uint64_t
Do you have any ideas how you can implement such an algorithm over the SPI bus.since the master needs to have up-to-date latest data at the time of their receipt.