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
HW SPI so slow,How to solve? (IDFGH-7973) #368
Comments
Do you use spi_master from esp-idf directly, or do you use the Arduino code? Also, in what sense is it slow? High latency, low clock speed, ...? |
Just esp-idf This is code
|
Fyi, code blocks need three backticks to work. I've been so bold to edit your comment. Also, again the question: in what aspect do you think the code is slow? What do you expect, what do you see? |
Soft api faster than HW SPI on ESP32. This is a driver for st7735r LCD chips,I had test this driver on STM32F103 ,HW SPI very fast. I can see slower than STM32 use my eyes…… |
Also possible related to #336 |
You're still not clear what exactly is slow. I'm going out on a limb here and assume you mean the latency between transactions, not the clock speed or cpu use or anything else. If so, you want to pipeline your transmissions. Basically, you can do this by queueing a bunch of transmissions using negativekelvin: I'm pretty sure it's not. #336 only comes into play when receiving data as well, as far as I can see. |
I'm sure not, I only run a task,just refresh the LCD,I also tried the queue, but it did not work. |
Okay, but then I will ask again: what is slow according to you, what speed do you expect and what speed do you get? Incidentally, there are no mutexes in the esp-idf SPI driver code (which is entirely separate from the Arduino code). Also, what do you try to transfer? You only posted some utility routines, but I have no idea what you feed into those. |
I expect the speed to be 25 frames on a 160 * 128 pixel screen,If I set it wrong, give me an example please. |
What do you try to transfer? You only posted some utility routines, but I have no idea what you feed into those: entire frames, lines, single pixels, ... |
I understand what you mean, I need to transfer the whole frame. |
If there is no way, I try to use the soft SPI…… |
That would indeed help, yes. The SPI routine fires an interrupt when a transfer is finished. This will take some time to process. When you have more transactions queued, the interrupt can immediately start the next transfer, this is reasonably fast. When you have coded your transfers as above (with no queue), this is the worst case: the interrupt fires, sees there's nothing to be done, your program resumes, the transfer triggers another interrupt to queue the new data, the transaction finished causing another interrupt etc. You can probably do sw SPI as well, but be aware that probably hangs up the entire core in transmitting, which can kill the CPU-time available to other tasks. |
I'll try it first |
The SPI driver in ESP-IDF is quite flexible and thread-safe, but I also found it to be too slow for my purpose (also, banging out > 100 kB @ 30 MHz byte-by-byte, interrupted by some GPIO toggeling). My workaround was to take the esp32-hal-spi.c/h module combo from the arduino project, modifying a little, removing all MUTEX calls from spiWriteByte() which are supposed to make this call thread-safe and use it directly from my application in ESP-IDF. It works without queues, events, interrupts or mutexes and is really fast. |
TO holzachr: yes!Yes, I used RTOS, how to solve this problem? I guess it should be for this reason |
I found a way to solve this problem, that is, use the more underlying functions, as used in the emunes project. |
Hey @holzachr would you mind sharing your module? |
I'm sorry, it looks like the module got last in the sands of time. |
I have a driver works on ESP32 in software SPI and also hardware SPI mode, but is very slow.
I think HAL mutex make this situation.
The text was updated successfully, but these errors were encountered: