New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EZ#10853] spi transfer bug #363
Comments
Do you happen to have some more information than 'can't recv right data'? What data do you expect and what data actually ends up in the receive buffer? |
above are data buf if t.length >31 the recv_buf data are messy code,like this:
|
I get through read the spi driver code,i look the dma threshhold
now,i want to know the threshhold can freedom configure? |
Possibly related #336 |
Also worth noting is that the constant https://github.com/espressif/esp-idf/blob/master/components/driver/spi_master.c#L449 should be used here https://github.com/espressif/esp-idf/blob/master/components/driver/spi_master.c#L628 too to possibly avoid inline values leaking in the future. |
methodmissing: Check. I've included it in the code change for #336. |
new issue
but spi master clock change to 20Mhz the recv data is wrong:
|
I just fixed some SPI code, commit c057f06 . Can you check if this fixes the issue you originally had? |
I had fixed the code, but the issue still exist. At the moment I found that DMA can not be sent and transmitted at the same time. Can you test this issue ? |
'sent and transmitted'? Do you mean 'sent and received'? If so, you need to enable full-duplex mode :) In general, as far as I can see, SPI works perfectly well with 10MHz. I'm using the testcase in components/driver/test/test_spi_master.c and modified the clock to 10 (and later even 20) MHz, and I receive the transmitted data without issue. |
whether you test the data size >32 bytes? E.g 50 bytes? |
Ah derp, sorry, forgot the length is in bits. Lemme try... Edit: Nope, 160 bytes, 10MHz and I still get back what I sent. |
Seems like this is a hardware thing. I'm discussing it with the HW guys. I can work around the symptoms in the driver, but I'd rather understand what's going on first. |
I hope to find the issue as soon as possible, and then give the solution, my project is very urgent to use SPI DMA.thanks! |
Hmm. Can you check once more if transmitting <31 bytes of data at 20MHz does not give you any problems? |
If you adjust clkcnt_h then it works up to 20mhz but breaks again at 26mhz aka clkcnt_n < 3. Happens with 16 bytes too. |
Here is a scan of all the clk freq in 10khz increments. Where trouble happens clkdiv_pre >> 0 && clkcnt_n = 0 or clkdiv_pre = 0 && clkcnt_n < 3 We can fix all the errors below 26MHz by restricting clkcnt_n > 0. Then we are left with just errors when freq > fapb/4 |
All freq work using the native mux pins including clk_equ_sysclk. |
26mhz working now using matrix pins. 40mhz needs dummy cycle? Can't get it to work. Enable dummy cycle stalls it. |
negativekelvin: I get the same result here: everything up to 40MHz works, but 40MHz hangs when enabling dummy bits. Will ask the digital guys, but it looks like the SPI host controller is not happy with the combination of dummy bits and full-duplex mode. |
What is the current progress of this issue? |
@long585 negativekelvin@1385bf0 seems to fix everything but 40mhz |
I'm actually working on a similar fix, but using the registers meant for it instead of messing with the clock rate calculations... 40MHz AND full-duplex AND using the GPIO matrix is still an issue, though: seems the engineer didn't have that usage scenario in mind. We're seeing if we can work around that limitation somehow, but that may take a while. |
Well, do not pay attention to this issue first. Another problem when I send the data size is 50 bytes, the received data is wrong。
|
50 bytes working for me, post your code |
next week post code |
my test hw environment is self send self recv
|
@negativekelvin @Spritetm Have you ever seen this code? |
Please do not use the callbacks for something like that. They're called as soon as the physical transfer is complete, in interrupt context. They're not meant for anything more than twiddle a GPIO or something. |
I know, but I would like to know why this code receives 50 bytes will be wrong |
@long585 I think when DMA is active your send_buf needs to be placed in ram with DRAM_ATTR |
Your idea is right,I modify the send_buf to be place in ram with DRAM_ATTR,but the last one byte date still wrong. like this:
|
This is my test case, send size and recv size from 45 bytes to 55 bytes.The test results are as follows:
|
Not sure, it appears to work when setting RX DMA size to be 32 bit aligned. @Spritetm |
What is the progress of this issue? |
@Spritetm any comment about DMA and RX fifo copy issue? |
Gonna look into it, but at the moment I'm slightly distracted by some other (internal) issues. |
What is the progress of this issue? |
Fix timing adjustment needed for higher speeds of SPI master bus. Ref #363 . It was found out the master SPI driver didn't exactly calculate the delay compensation needed, breaking 20 and 26MHz full-duplex mode. This fixes these use cases. We also found out 40MHz full-duplex routed over the GPIO matrix does not work because of a hardware quirk; this MR adds a check/error for that case until we find a workaround. See merge request !547
Fixed in a4acf7b |
Actually, it's been fixed in 46fa2cf or one of its subcommits. |
if TEST_SIZE >31 the rx_buffer can`t recv right data.
The text was updated successfully, but these errors were encountered: