Framebuffers and PSRAM

craigyb

Active member
I need a little help, I'm trying to connect upto 8 ST7789 IPS displays to a Teensy 4.1. so far I have 4 connected and they all initialize ok, but the first 3 run smoothly when updating, but the 4th is jumping when updating. I think I've run out of framebuffer space after 3 320*240 displays.

Now I have a T4.1 with an 8MB PSRAM installed to test with, but how would I go about moving the framebuffers to the PSRAM and would it be super slow.
 
A couple of different ways:

Somewhere global something like:
Code:
EXTMEM uint16_t buf[MYPSRAM * 1024 * 1024]   __attribute__((aligned(32)));

and in your code before you use frame buffer to a call like:
Code:
tft.setFrameBuffer(buf);

Makes sense that 3 would fit into DMAMEM which would be where the allocation would be from (malloc) if you have not explictily set the frame
buffer.

320x240x2 = 153600 and 512k would fit 3.3333 of these.

You can also do the allocation using: extmem_malloc(). But I tend to allocate an extra 31 or 32 bytes and align the pointer to 32 byte boundary.
Why? When/if you use DMA updateScreenAsync the code needs to make sure the current contents of the any cache within that region is flushed
to the actual memory as DMA does not use the cache... And the flush type operations work on 32 byte chunks...

Potentially depending on what else is going on with your program, you can sometimes allocate a buffer in ITCM memory...
Like above definition minus the EXTEMEM...
 
OK, I set MYPSRAM to 4 to allocate 4MB and I tested the jerky display and now its smooth, I will carry on testing with all displays using the PSRAM
 
Last edited:
Back
Top