我的代码运行良好并在串行监视器上提供输出,直到我添加此函数调用它停止发送到串行!
该函数用输入数组的绝对值填充结果数组。
#define INPUT_SIZE 800
void vabs(double *vec,int vsize,double *result){
int i;
for(i=0 ; i<vsize ; ++i)
result[i] = fabs(vec[i]);
}
double x1[INPUT_SIZE];
int x1size;
double absX1[INPUT_SIZE];
int absX1size;
double Process(int *inputArray,double *qrs){
int i;
// Initialization
for(i=0 ; i<INPUT_SIZE ; ++i)
x1[i] = (double)inputArray[i];
x1size = INPUT_SIZE;
// Cancellation DC drift and normalization
double meanValue = mean(x1,x1size);
minus(x1,x1size,meanValue);
Serial.println(x1[0]);
// vabs(x1,x1size,absX1); // Uncomment this line will cause the problem!
absX1size = x1size;
*qrs = 5;
return 10;
}
设置和循环:
void setup(){
Serial.begin(9600);
delay(1000);
}
void loop(){
// This array contains 800 values
int bArr[]= {59,259,259,250,250,250,83,83,...};
double qrs = 0;
double heartRate = Process(bArr,&qrs);
delay(5000);
}
我正在使用具有 128 KB 闪存和 8 KB SRAM 的 Arduino Mega (Atmega1280)。