SPI slave driver, last 4 Bytes missing (using DMA)

trancefreak
Posts: 5
Joined: Wed Sep 19, 2018 7:31 am

SPI slave driver, last 4 Bytes missing (using DMA)

Postby trancefreak » Thu Sep 20, 2018 7:25 am

Hi,

I'm using the spi slave driver and I have the problem that the last 4 Bytes are not written to the RX buffer. The trans_len field shows that all bytes are received. I tried all available SPI modes (0 - 3). This issue happens in all modes. I use DMA and the size of the transaction does not matter. It happens with 64 bytes or 8196 and all other transaction sizes (all dividable by 4).

As a workaround I send 4 dummy bytes to make sure my data is completely written to the buffers

Is this a bug and is there already a fix for it?

Just for info: The frequency does not matter, it happens with 10kHz and also with 10 MHz and frequencies in between. I checked the output of the master (Raspberry PI) with a logic analyzer and the output is ok, all bytes written and correect. The trans_len field proves that all bytes are received. But the last 4 bytes do not show up in the RX buffer.

Thanks,
Christian

trancefreak
Posts: 5
Joined: Wed Sep 19, 2018 7:31 am

Re: SPI slave driver, last 4 Bytes missing (using DMA)

Postby trancefreak » Tue Sep 25, 2018 10:53 am

Please, can someone from Espressif give an update on the issue why the last 4 Bytes are always missing?

vpopescu
Posts: 1
Joined: Wed Oct 17, 2018 2:27 pm

Re: SPI slave driver, last 4 Bytes missing (using DMA)

Postby vpopescu » Wed Oct 17, 2018 3:14 pm

Hello, I am having the same issue using the ESP32 WROVER as slave, maximum buffer size to have a valid transfer on SPI, using DMA, between master and slave, is 4092. There is one place where is specified that the DMA buffer size is limited at 4092 byte, "Because limited of DMA buffer is 4092 bytes" line 378, file Drivers\esp-idf\components\driver\i2s.c, so it is this a known bug, or a limitation ?

ESP_Sprite
Posts: 1941
Joined: Thu Nov 26, 2015 4:08 am

Re: SPI slave driver, last 4 Bytes missing (using DMA)

Postby ESP_Sprite » Fri Oct 19, 2018 3:15 am

Trancefreak: Are you sure your /CS doesn't go high before the last few bytes have been written? The ESP32 hardware doesn't really like the /CS-pin going high early and can abort the transfer, causing what you see.

vpopescu: No idea what you're trying to say here, but both SPI master as well as slave drivers support a max_transfer_sz option to indicate how many DMA buffers to allocate; you can set this as high as you want and in that way transfer more than the 4092 bytes that fit in one DMA buffer.

Who is online

Users browsing this forum: No registered users and 2 guests