1
TinyDuino Processors & TinyShields / Memory Question
« on: December 05, 2014, 03:32:18 PM »
I'm trying to find out more about how memory is allocated on the Tinyduino.
I need an array of longs to store some data in. I'd like to be able to store up to 1000 points of accelerometer x,y,z data.
I setup this as a test:
long Points[300];
for (i=0;i<300;i+=3) {
accel.read();
Points[i+0]=accel.X;
Points[i+1]=accel.Y;
Points[i+2]=accel.Z;
}
and it works just fine, allowing me to store one hundred x,y,z values.
But if I increase the number to even 500, the sketch stops working.
I assume (know) that the 2k of ram memory is too small to hold all 1000 points that I'd like to have, but it seems odd to me that the sketch fails at even 500.
A long should be 16 bits, right? 500 longs should be 1000 bytes, using only half of the RAM available.
I'd like to be a bit more logical about this.. I should be able to calculate how much RAM a set of longs is going to require, rather than trial-and-erroring just waiting for the sketch to fail.
=======
The second half of my question is.. I could move all of this data out to an SD card, but what's the write cycle speed on an SD? Isn't writing to an SD going to significantly slow me down compared to using RAM? Any chance of a RAM shield some day? I'm not greedy, even 32k should be exceedingly helpful here. <hint> <grin>
I need an array of longs to store some data in. I'd like to be able to store up to 1000 points of accelerometer x,y,z data.
I setup this as a test:
long Points[300];
for (i=0;i<300;i+=3) {
accel.read();
Points[i+0]=accel.X;
Points[i+1]=accel.Y;
Points[i+2]=accel.Z;
}
and it works just fine, allowing me to store one hundred x,y,z values.
But if I increase the number to even 500, the sketch stops working.
I assume (know) that the 2k of ram memory is too small to hold all 1000 points that I'd like to have, but it seems odd to me that the sketch fails at even 500.
A long should be 16 bits, right? 500 longs should be 1000 bytes, using only half of the RAM available.
I'd like to be a bit more logical about this.. I should be able to calculate how much RAM a set of longs is going to require, rather than trial-and-erroring just waiting for the sketch to fail.
=======
The second half of my question is.. I could move all of this data out to an SD card, but what's the write cycle speed on an SD? Isn't writing to an SD going to significantly slow me down compared to using RAM? Any chance of a RAM shield some day? I'm not greedy, even 32k should be exceedingly helpful here. <hint> <grin>