DUE SRAM access and maximum limit of size.

Hi, guys.

hope that you all doing good.

I am working on DUE board, there it has given SRAM 96 Kb in 2 split bank.

i would like to know that How do i access these SRAM banks, is there any special Instructions or Code or library.

I am not able to write buffer size above 23000. for ex. i have wrote unsigned int arr [23000]. these are the limitation of hardware??? why i am not able to write buffer size more than 23000.??

does anyone have answer..?

suppose if this is the limitation then how do i write buffer arr[50000] and so on.. any external memory required.?

looking forward to answer.

Thanks

The SRAMs are aliased within their blocks; SRAM0 is aliased and will repeat every 64K, i.e. bits 16-18 of the address are ignored. So the byte that is accessed at address 0x20000000 can also be found at 0x20010000, 0x20020000, 0x20030000, etc., up to 0x20070000.

SRAM1 is similarly aliased and will repeat every 32K, i.e. bits 15-18 of the address are ignored. So the byte that is accessed at address 0x20080000 can also be found at 0x20088000, 0x20090000, 0x20098000, etc, up to 0x200F8000.

To make the SRAM appear as one contiguous block it is accessed via the upper alias of SRAM0 (0x20070000) and the lower alias of SRAM1 (0x20080000).

AFAIK the stack is stored at the top of Sram1, and maybe your libraries are using some more RAM.

Note that the NAND Flash Controller (NFC) embeds 4224 bytes of internal SRAM. If the NFC is not used, these 4224 bytes can be used as general-purpose SRAM. You will have to power on SMC_SDRAMC (NFC) before using these 4224 bytes of memory.

Anyway, Inside the minimal sketch below, you can access 94520 bytes of SRAM thru 2 arrays:

#define Array2_size  (630)

uint32_t Array1[23000];
uint32_t Array2[Array2_size];
void setup() {
  Serial.begin(250000);
  // put your setup code for core 0 here, to run once:
  for (int i = 0; i < 23000; i++) {
    Array1[i] = i;
  }
  for (int i = 0; i < Array2_size; i++) {
    Array2[i] = i + 23000;
  }
  Serial.println(Array1[0]);
  Serial.println(Array1[22999]);
  Serial.println(Array2[0]);
  Serial.println(Array2[Array2_size - 1]);

}

void loop() {
  
}

Thank you ard_newbie.

can i store 50000 points of 32 bits data into these array.

actually as a newbie, i can not understand ur code. it shows 23000+630 points isn't it...?

plz try to elobrate if possible.

thanks.

i am getting error during compilation of above code , error is related to ram and .bss.

what could be the problem .?

I got the same thing, so I looked for the max size empirically,

#define Array2_size 630
#define Array1_size 22731 // 23000
uint32_t Array1[Array1_size];
uint32_t Array2[Array2_size];

//#define Array2_size 1260
//#define Array1_size 45462
//uint16_t Array1[Array1_size];
//uint16_t Array2[Array2_size];

//#define Array2_size 2520
//#define Array1_size 90924
//uint8_t Array1[Array1_size];
//uint8_t Array2[Array2_size];


void setup() 
{
  Serial.begin(115200);
  // put your setup code for core 0 here, to run once:
  for (int i=0; i<Array1_size; i++) 
  {
    Array1[i] = i;
  }
  for (int i=0; i<Array2_size; i++) 
  {
    Array2[i] = i + Array1_size;
  }
  Serial.println(Array1[0]);
  Serial.println(Array1[Array1_size - 1]);
  Serial.println(Array2[0]);
  Serial.println(Array2[Array2_size - 1]);

}

void loop() 
{

If you max-out these values, the is no RAM left to .print anything or do anything else???

If I use,

#define Array2_size 630
#define Array1_size 22731
uint8_t Array1[Array1_size];
uint8_t Array2[Array2_size];

, it compiles, but the output is 0, 202, 203 & 64, Where does the 64 come from? Is should be greater than 203!

If I use,

#define Array2_size 600
#define Array1_size 22000
uint32_t Array1[Array1_size];
uint32_t Array2[Array2_size];

, I get 0, 21999, 22000 & 22599. Great!

If I use,

#define Array2_size 630
#define Array1_size 22731
uint16_t Array1[Array1_size];
uint16_t Array2[Array2_size];

, I get 0, 22730, 22731 & 23360. Hooray! But, why doesn't uin8_t give the correct result???

I'll hazard a guess that it has something to do with Aligned Memory Access

I got the same thing, so I looked for the max size empirically,

The system needs more than just the RAM allocated at compile time. If you fill it up to "99% used" as reported by the IDE, your sketch probably won't work, because there isn't enough RAM left for the run-time environment.
Exactly how much RAM needs to be free for your sketch to actually work is very hard to predict, which is why the IDE will start issuing warnings long before that point...