Fast Way to start a SPI transmission with DMA?
Posted: Sun Nov 12, 2023 8:13 am
Hi,
I am new to the ESP32, but my first project already pushes this controller to its limits.
The goal is to capture a very uncommon video signal on the FSPI port, and re-transmit it as a VGA-signal.
The input signal have 3 wires: a combined SYNC signal and 2 Bit color (well, 4 shades of green...) signals. The idea is to get this signals into a 4-bit SPI port, receive them as a long DMA transmission, and finally process them into the VGA buffer.
The VGA part was easy. The SPI part was also not difficult to set up.
BUT: to capture the full line of the image, I have so start the SPI transmisson FAST. I have 5µs between the sync impulse and the first pixel. In my youth naivety i though: "a 240MHz processor should get that easily", bot no - before the transmission starts, half of the line is already gone.
I have taken some looks into the spi_device_queue_trans source code to find out why the SPI startup does take so long. It seems the function does a lot of housekeeping and places the transmission into a queue. A ISR takes the transmission from the queue and after a lot of housekeeping again it finally starts the transmission. This all takes time. No way to get this in 5µs.
Ok. Time to go deeper. I took the technical reference manual, and implemented the whole SPI thing by writing registers. But: to my surprise the SPI registers does not even change if i write something into them! Are they protected somehow? For an IOT device this would make sense, but in my case... no.
So: is there a fast way to start a SPI transmission? Any other ideas?
Greetings
Stefan
I am new to the ESP32, but my first project already pushes this controller to its limits.
The goal is to capture a very uncommon video signal on the FSPI port, and re-transmit it as a VGA-signal.
The input signal have 3 wires: a combined SYNC signal and 2 Bit color (well, 4 shades of green...) signals. The idea is to get this signals into a 4-bit SPI port, receive them as a long DMA transmission, and finally process them into the VGA buffer.
The VGA part was easy. The SPI part was also not difficult to set up.
BUT: to capture the full line of the image, I have so start the SPI transmisson FAST. I have 5µs between the sync impulse and the first pixel. In my youth naivety i though: "a 240MHz processor should get that easily", bot no - before the transmission starts, half of the line is already gone.
I have taken some looks into the spi_device_queue_trans source code to find out why the SPI startup does take so long. It seems the function does a lot of housekeeping and places the transmission into a queue. A ISR takes the transmission from the queue and after a lot of housekeeping again it finally starts the transmission. This all takes time. No way to get this in 5µs.
Ok. Time to go deeper. I took the technical reference manual, and implemented the whole SPI thing by writing registers. But: to my surprise the SPI registers does not even change if i write something into them! Are they protected somehow? For an IOT device this would make sense, but in my case... no.
So: is there a fast way to start a SPI transmission? Any other ideas?
Greetings
Stefan