Incomplete SPI Buffer

NevynSelby
Posts: 34
Joined: Thu Dec 24, 2015 12:04 pm

Incomplete SPI Buffer

Postby NevynSelby » Fri Apr 12, 2019 2:11 pm

I have the ESP32 set up as a slave device using SPI. I have followed the advice in the online documentation that states that the buffers should be minimum 8 bytes and a multiple of 4 bytes long.

So I am trying to send 23 bytes (in a 24 byte buffer) to the ESP32.

In every case it looks like the last four bytes are being set to 0x00.

I have checked the transaction length and it is set to 192 bits (i.e. 24 bytes).

Has anyone else come across this and have a solution?

Regards,
Mark

NevynSelby
Posts: 34
Joined: Thu Dec 24, 2015 12:04 pm

Re: Incomplete SPI Buffer

Postby NevynSelby » Sat Apr 13, 2019 7:43 am

After some experimentation it appears that the last four bytes are not being populated in the rx_buffer.

I have tried a number of buffer sizes, 24, 32, 40, all of which are multiples of 4. The logic analyser shows that the data is going onto the SPI bus correctly and the transaction length is saying that the number of bytes received matches the number of bytes transmitted.

For reference, I am using spi_slave_queue_trans to start the transmission and calling spi_slave_get_trans_result in the post transmission callback.

My work around is to make the buffer four bytes larger than necessary and then resizing if the buffer is not a multiple of 4.

Regards,
Mark

Who is online

Users browsing this forum: No registered users and 121 guests