Ah, one of my friends pointed out the issue. It's a scope snag:
chunks is allocated on the stack in get32BitInt By returning a pointer to chunks, you are pointing to memory that is deallocated. Think of it as pointing to a member variable of a class that has already been destroyed
when you try to dereference deallocated memory, bad things can happen. ...
My DaquinOscope https://www.daqarta.com/dw_rroo.htm uses the open-source DaqPort sketch https://www.daqarta.com/dw_rraa.htm to sample in batches, then transfer the data to the host in one high-speed blast. It takes 1024 total samples, which in your case of 2 channels would be 512 per channel. It stores only the raw data, unscaled... the host is the place ...
Storing the data into arrays is not an end in itself. The question is:
what do you want to do with these arrays? The way to proceed depends on
If you want the data acquisition (analogRead()) and the processing
(computation and printing) to proceed in parallel, then you will need
the arrays for buffering the data between those two processes. As
You can create two arrays, e.g.:
#define MAX_LENGTH 20
volatile float _gauge0[MAX_LENGTH];
volatile float _gauge1[MAX_LENGTH];
volatile int _filled = 0;
The _filled value shows that _gauge0 is filled from 0 upto (excluding) _filled.
So when adding two values you use:
_gauge0[_filled] = some value;
_gauge1[_filled] = some_other_value;