mrcodetastic / esp32s3_spi_dma_tx_seg_loop

Example of SPI Master DMA driven segmented transfers on the ESP32S3
2 stars 0 forks source link

Could we use this approach to read 8bits in parallel instead of write? #1

Closed odelot closed 2 months ago

odelot commented 2 months ago

Hi mrcodetastic,

This is a question, not an issue ;-)

I am trying to use the ESP32 to read the NES (Nintendo Entertainment System) internal RAM, which has a 24-bit bus plus controller flags.

For the 16-bit address (I need just 12 bits for internal RAM) and some controller flags, I used the Camera Module to oversample the bus at 24 MHz.

I need a way to read the 8-bit data bus, and some suggested using octal-SPI to do this.

I know you studied the TRM in detail to use octal-SPI for output to your LED panel. Is it possible to read 8 bits in parallel using octal-SPI at 24 MHz?

If you think it's possible, I'll probably stick to this strategy and study SPI. I am also strongly considering moving from the ESP32 to the Raspberry Pico W, since there are examples of people running the Gameboy bus (very similar to NES) with PIO. There are also examples using STM32F to create an Everdrive for Gameboy that handles a 16-bit address and 8-bit data bus similar to NES.

Thanks in advance. Please delete this issue if you think it is inappropriate.

mrcodetastic commented 2 months ago

Hey odelot,

You can use the SPI peripheral on the ESP32S3 in Octal mode to read. When using Octal I think it's half duplex only, so read or write 8 bits only at one time.

The problem I think you'd face using the S3's SPI in octal mode is you would have trouble using it as a generic logic level analyser - similar to what you are doing with the camera module to oversample. SPI transactions (segments) are limited to 32Kb as well, which isn't a great deal of data. One can get around this issue by reading data into multiple chains of segments, but there's a time-gap between jumping across to a new segment, so data could be lost - unless of course you can control when the NES clocks out its data.

Personally, I'd move to the PI. I haven't used PIO myself, but from what I understand, it gives a level of control that you won't be able to get with a mix of LCD/CAM module + SPI.

odelot commented 2 months ago

thank you very much! I will do that (move to PI).

odelot commented 2 months ago

It can be quite tiresome to use something for a purpose it wasn't intended for. I think you understand, since you are using the LCD/Camera module to output 16 bits in parallel at high speed.

I spent some time figuring out that the approach used with the stock ESP32, which abuses the I2S, wouldn't work on the ESP32S3. There were significant changes from the ESP32 to the S3 model when it comes to using the LCD/Camera peripheral. I believe you also mentioned on the forum that the stock ESP32 can read/write 24 bits using I2S, whereas the S3 model cannot (that's is sad).

Thank you for the information about octal-SPI. This helped me avoid investing time again in trying to use something that isn't meant to be used as I need. I found the answer above wasn't too clear about that.