Go Down

Topic: Memory size issues with a pointers vector (Read 491 times) previous topic - next topic


Mar 01, 2013, 08:29 am Last Edit: Mar 01, 2013, 08:38 am by matthdup Reason: 1

I have issues trying to program a data recorder on my Arduino Uno SMD. I just want to record short int in a pointers vector. That works fine if my vector size is less than approximatively 800. But if there's more elements than 800 (I'd like 1024), the program bug: I can compile and upload it but it seems to execute the setup() in a loop!?!
Did I made a stupid mistake (I'm a beginner)? Is it just that there's not enough memory available (but 1024 short int take just 2048 Bytes)?


Here's my code:
Code: [Select]

#include "Arduino.h"

int pinElectret=A1;

void setup ()
 Serial.println("Setup execution");
void loop()

 short* donnees[1024]  ;
 short val;
 int nbtot=1024;

 Serial.println("Start Recording");
 for(short int ip=0;ip<nbtot;ip=ip+1)

 Serial.println("End recording");
 for(short int ip=0;ip<nbtot;ip=ip+1)


int availableMemory()
 int size = 1024; // Use 2048 with ATmega328
 byte *buf;
 while ((buf = (byte *) malloc(--size)) == NULL);

 return size;


Is it just that there's not enough memory available (but 1024 short int take just 2048kB)?

sp. "2048 bytes".
Remember, that's all the RAM you have.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.


Per Arduino ad Astra


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131