c++ - Storing 200kb of data in an array? -
i'm pretty new programming embedded applications (besides arduino stuff) , i'm working cc3220sf microcontroller texas instruments.
currently have program polling device , storing result. store 100,000 of these samples (each 2 bytes) giving me 200kb of data store. i'm not sure how should go doing this, trying make array of size [100][1000] crashes device.
how should go storing data later use?
#define max_arr_length 1000 #define max_arr_depth 100 // later in collection function: uint16_t measurmentsarr[max_arr_depth][max_arr_length] = {0}; unsigned int arr_length = 0; unsigned int arr_depth = 0; // , later, after data point has // been verified useful: if (arr_length < max_arr_length){ measurmentsarr[arr_depth][arr_length++] = angle; } else { arr_length = 0; measurmentsarr[arr_depth++][arr_length] = angle; }
this ^^^ way works small arrays, said need store 200kb... know cc3220sf has 512kb use, how best write/read that?
respectfully, -james
chances sticking static
in front of huge array makes work.
most compilers embedded systems place function-local variables on cpu stack, static
variables have "static storage duration" , behave globals. linker knows how memory need, , try fit them in.
of course, static
make function non-reentrant, couldn't allocate 2 200 kb arrays on 256 kb device anyway.
Comments
Post a Comment