Hello,
I am trying to read sensor data, store it together with a timestamp on the additional PSRAM of my T4.1 and after the measurement is finished, I would like to print the arrays via USB. The measurement is startet and ended by sending b'1' or b'2' via pyserial.
For timing the measurements I am using the Arduino-Timer library (each 100 microseconds).
Unfortunately only around 2000 values can be written inside the arrays, even though I initialized them for 100000 values. My guess would be, that they are saved somewhere else and that memory is full at some point. How could I fix this?
Thank you in advance!
I am trying to read sensor data, store it together with a timestamp on the additional PSRAM of my T4.1 and after the measurement is finished, I would like to print the arrays via USB. The measurement is startet and ended by sending b'1' or b'2' via pyserial.
For timing the measurements I am using the Arduino-Timer library (each 100 microseconds).
Unfortunately only around 2000 values can be written inside the arrays, even though I initialized them for 100000 values. My guess would be, that they are saved somewhere else and that memory is full at some point. How could I fix this?
Thank you in advance!
Code:
#include <arduino-timer.h>
Timer<1, micros> timer;
const int Pin_ = 40;
EXTMEM int data_[100000];
EXTMEM int t[100000];
int val = 0;// variable to store the value read
int ts = 0;
int i = 0; // counter
int start_=0;
void store_val(){
ts = micros();
val = analogRead(Pin_);// read the input pin
t[i] = ts;
data_[i] = val;
i++;
}
void setup() {
timer.every(100, store_val);
}
void loop() {
start_ = Serial.read();
if (start_==49) {
while (1){
timer.tick();
start_ = Serial.read();
if (start_ == 50){
break;
}
}
for(int j = 0; j<i; j++){
Serial.print(data_[j]);
Serial.print(";");
Serial.println(t[j]);
}
memset(t, 0, sizeof(t));
memset(data_, 0, sizeof(data_));
i = 0;
}
}