Esp32 allocate big two dimensional array in External memory
Posted: Fri Jan 16, 2026 5:50 pm
I am doing a program for an Esp32, I am new in this. I did an array of two dimensions for storage the background of an small Display. I will use it to stream buffer all. Take some frames small where data change and using a font bit map replace uint16_t 565 pixel by bit points in the small frame. The rest after task send the array I will delete it.
I used a program to make the 565 one line hexa uint16_t
https://sourceforge.net/projects/lcd-im ... ter/files/
And I did a program to arrange it
https://drive.google.com/file/d/1vzO4_r ... sp=sharing
I try plenty ways to allocate memory for the two dimensional arrays and any works. I am asking information about it.
and At the end or at start I am trying to reference one to the other and I can't.
If anyone can help me is very welcome.
I used a program to make the 565 one line hexa uint16_t
https://sourceforge.net/projects/lcd-im ... ter/files/
And I did a program to arrange it
https://drive.google.com/file/d/1vzO4_r ... sp=sharing
I try plenty ways to allocate memory for the two dimensional arrays and any works. I am asking information about it.
Code: Select all
#include <stdint.h>
#include "esp_heap_caps.h"
# define ARRAYBACKGROUNDSIZE (128*160)
uint16_t* pointerbackground[160][128]= (uint16_t*) heap_caps_malloc((ARRAYBACKGROUNDSIZE+100)*sizeof(uint16_t),MALLOC_CAP_SPIRAM);
static volatile uint16_t background [160][128]=
{{0xe75d, 0xf7ff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xf7ff,
0xf7ff, 0xef9e, 0xdf3d, 0xe77d, 0xcefb, 0x9514, 0x3a4a, 0x31a8, 0x31a7, 0x39c8, 0x31a7, 0x2967, 0x2167, 0x2167, 0x2146, 0x2146,
0x2987, 0x2987, 0x2967, 0x2166, 0x1946, 0x2146, 0x2146, 0x2966, 0x39a6, 0x41c7, 0x41c7, 0x41e7, 0x49e7, 0x4a07, 0x4a07, 0x41e7,
0x41c7, 0x39a6, 0x3986, 0x3986, 0x3986, 0x3986, 0x3165, 0x3145, 0x3165, 0x41a6, 0x8308, 0xcc8b, 0xd4cb, 0xc44a, 0xdd0c, 0xed8d,
0xed8e, 0xed8d, 0xd4ec, 0xd4ec, 0xe54d, 0xdd0c, 0xd4ec, 0xdd4d, 0xedce, 0xedae, 0xed8e, 0xe56e, 0xe5b1, 0xe613, 0xeeb8, 0xef7d,
0xf7ff, 0xf7ff, 0xf7ff, 0xf7ff, 0xf7ff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xf7ff, 0xf7ff,
0xf7ff, 0xffff, 0xffff, 0xf7ff, 0xf7ff, 0xf7ff, 0xf7ff, 0xf7ff, 0xf7ff, 0xf7ff, 0xf7ff, 0xf7ff, 0xf7ff, 0xf7ff, 0xf7ff, 0xdf5d},
Code: Select all
{ 0x82c7, 0x82e8, 0x7287, 0x7287, 0x51a5, 0x4984, 0x6a46, 0x8b08, 0x938b, 0x834b, 0x72c9, 0x6a05, 0x6a46, 0x7246, 0x7265, 0x6225,
0x6226, 0x72c9, 0xa42f, 0x836c, 0x834c, 0x7b2b, 0x7b6c, 0x7b6d, 0x736d, 0x736d, 0x7b8e, 0x5acb, 0x3187, 0x10e5, 0x0884, 0x0084,
0x00a4, 0x0906, 0x0907, 0x1148, 0x21a9, 0x41c8, 0x4985, 0x49a5, 0x6268, 0x6247, 0x72a9, 0x93cc, 0x6247, 0x5a05, 0x6226, 0x8309,
0x82c8, 0x7287, 0x82a7, 0x9348, 0xb42c, 0xbc6c, 0x9b68, 0x7a66, 0x6a05, 0x6a05, 0x7246, 0x59e5, 0x7aa7, 0x9329, 0xbc4c, 0xbc6d,
0x82c7, 0x49a4, 0x49e6, 0x6288, 0x9b8b, 0x8b8c, 0x7aea, 0x7288, 0x7288, 0x72a8, 0x7267, 0x7288, 0x6a47, 0x6226, 0x7288, 0x9329,
0x8b29, 0x8b29, 0x934a, 0x7267, 0x8ae9, 0x7246, 0x6a46, 0x7a86, 0x8a86, 0x92e8, 0x9329, 0x7aa7, 0x7266, 0x8ac7, 0x8b29, 0x8b08,
0x7246, 0x7226, 0x82a7, 0x8b07, 0x82c8, 0x7aa7, 0x7287, 0x59c5, 0x51a4, 0x6a45, 0x82e7, 0x82e8, 0x8ae8, 0x82c7, 0x6a45, 0x59e4,
0x51a4, 0x51a4, 0x72a7, 0x6a67, 0x4983, 0x5183, 0x61e4, 0x9348, 0xb40b, 0x9b69, 0x82a6, 0x9307, 0x7a65, 0x61c3, 0x5183, 0x7266}};
*pointerBackground =&background;