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
ESP32C3 9bit-SPI Transmit Error (IDFGH-6865) #8487
Comments
I have been trying to use 9-bit SPI transfers on ESP32-S3 (not C3 like londonlove) which appears to have a similar issue. Using a buffer containing [0xff, 0xff] I tested sending various size transfers from 1 to 16 bits. Two cases fail: sending 1 bit results in a 0 bit being transmitted, and sending 9 bits results in the last bit being erroneously sent as a 0. On the original ESP32, this does not happen.
I have tried using other data as well, and it seems that for 9-bit transfers the last bit is always sent as 0 no matter what. I am also using IDF v4.4 |
With some further testing of the issue on ESP32-S3, the last bit is always sent as zero for any transaction with 8n+1 bits. There's something special happening when the last buffer byte only has one bit used. Workaround is to detect the 8n+1 bits case and split it into two transactions (8n-1 and 2 bits respectively). Here is an example of the workaround: https://gist.github.com/DavidJRobertson/3d077b55dce744c4c87ae6c49d0fc2cb The workaround can't fix the case of 1 bit transactions, but these are not of much practical use anyway. |
Hi @londonlove , @DavidJRobertson , |
Thanks,I haved change the IDF branch to v4.3,and the problem is also exist,Waiting for your response |
Small question: is SPI host with DMA enabled or disabled? |
Hi @liaozhelin , We confirmed this is a limitation in the HW. The architecture of HW is based on bytes, not for bit-based transactions, regardless of whether DMA is used or not. Though it happens to support all other cases except 8n + 1 bits on ESP32-C3.. You may workaround this issue with the command/addr phases. We may improve this in future chips, but maybe not possible on ESP32-C3. |
Could the software workaround be included in the IDF? This would at least give API compatibility between ESP32 and ESP32-C3/S3 |
Hi @DavidJRobertson , The workaround would take some execution time, space, and cannot fix the issue perfectly (can fix tx only, cannot use with the DMA mode). Finally the user still need to know this limitation, and is suggested to avoid this use cases by making a descriptor that meets HW limitation. Due to the space usage (the driver doesn't keep any internal buffer to avoid data copying, temporary buffer should be given by the user), if there should be a layer for compatibility, it should be a helper function above the driver, instead of integrated into the driver core. Please see and try the code below:
|
Issue closed, feel free to re-open it if you find more problems. |
Environment
Problem Description
I have a 3-wire TFT screen, his communication protocol is 9bit, the highest bit is cmd/dat control bit, and the remaining 8 bits are communication data.
Through the vscode-idf plug-in tool, the project was created through the template spi-master. According to the sending method of 9bit spi in the manual, the content after the spi initialization was deleted, and the following code was written
(After the "ESP_ERROR_CHECK(ret);" 441lines):
It's works great. I use the Logic Analyzer to view the gpio statues:
the date seems Ok,but when I change the DATE in SPI_SWAP_DATA_TX,to 0X045:
The logic analyzer detected the following information:
It can be seen that the highest bit (9bit) and the lowest bit (1bit) of the SPI output seem to be bound together, which is controlled by the ninth bit of DATE in SPI_SWAP_DATA_TX. I have tried many times with different data, and the result is the same , also checked the Mode and other settings, what could be the problem, thank you very much!
Debug Logs
Other items if possible
none
The text was updated successfully, but these errors were encountered: