ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

faptastic
Posts: 15
Joined: Mon Nov 14, 2022 10:38 pm

ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

Postby faptastic » Sun May 19, 2024 1:16 am

Hello.

The TRM seems to imply that one can create a buffer in PSRAM memory, and use EDMA to send out via the I2S peripheral (for parallel output LCD mode).

However, any attempts I try produce garbage output when any of the buffer is allocated to the ESP32-S2's PSRAM.

What is this the case? The TRM seems to imply this is possible. However, I have not been able to find any examples.

liaifat85
Posts: 200
Joined: Wed Dec 06, 2023 2:46 pm

Re: ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

Postby liaifat85 » Sun May 19, 2024 2:00 pm

You can allocate critical buffers that require high-speed access in internal SRAM instead of PSRAM. You can use PSRAM for less critical data that doesn’t need high-speed access.

faptastic
Posts: 15
Joined: Mon Nov 14, 2022 10:38 pm

Re: ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

Postby faptastic » Mon May 20, 2024 10:24 am

I don't want to use the SRAM. I want to use the PSRAM.

The TRM says you can use it for I2S and LCD output, but I there's no guidance anywhere on how to achieve this in code.

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

Postby ESP_Sprite » Tue May 21, 2024 1:36 am

It should just work like internal RAM, with the exception that your memory needs to be aligned to the cache line size of the psram cache. Also, you need to make sure data is not stuck in that cache, as the CPU reads/writes from cache while DMA interacts directly with the underlying PSRAM; this means that you'll need to flush the cache for the data memory before starting the DMA transfer. Also note that DMA descriptors can only be in internal RAM.

faptastic
Posts: 15
Joined: Mon Nov 14, 2022 10:38 pm

Re: ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

Postby faptastic » Tue May 21, 2024 5:27 am

Thanks ESP_Sprite.

If I used say the esp-camera example (https://github.com/espressif/esp32-camera) and re-write it to be an LCD output instead, do you think that could potentially do the trick? I see a bunch of PSRAM data alignment stuff in this code.

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

Postby ESP_Sprite » Tue May 21, 2024 8:54 am

Erm, possibly? It certainly has a lot of the components you'd need.

faptastic
Posts: 15
Joined: Mon Nov 14, 2022 10:38 pm

Re: ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

Postby faptastic » Sun Jul 07, 2024 8:36 am

For those that might be interested I figured it out and it was indeed per what Sprite_TM stated.

Use of the function

Code: Select all

Cache_WriteBack_Addr
in the code solves for the issue.

I can now clock out 24bits (3 bytes) in parallel at about 6Mhz from SPIRAM via. the I2S 'LCD Mode'.

https://github.com/mrcodetastic/esp32s2 ... /tree/main

Who is online

Users browsing this forum: No registered users and 321 guests