I have encountered the strange error "unable to find a register to spill in class 'POINTER_REGS'" in the following program:
unsigned long h[8]={0,0,0,0,0,0,0,0};
unsigned long duration[8]={0,0,0,0,0,0,0,0};
float t = 3000;
float tau = 250000;
void setup() {
}
void loop() {
for (int i=0;i<8;i++) {
h[i]+=(t-duration[i]);
h[i]*=(1-t/tau);
}
}
It is a part of a larger program, I have removed the non-erratic code to find the error. Strangely, if h and duration are not arrays, the program works:
unsigned long h=0;
unsigned long duration=0;
float t = 3000;
float tau = 250000;
void setup() {
}
void loop() {
h+=(t-duration);
h*=(1-t/tau);
}
Thank you for your answer. It works, but I have no idea why! Also, if I change the definition of h slightly like this: ```
*unsigned long h[8]={0,0,0,0,0,0,0,0};
unsigned long duration[8]={0,0,0,0,0,0,0,0};
float t = 3000;
float tau = 250000;
void setup() {
}
void loop() {
for (int i=0;i<8;i++) {
h[i]+=(t-duration[i])-(h[i]t/tau);
}
} ``` then it works, but why??? Cheers, Frank
Shouldn't the compiler automatically decide correctly which variables are stored in memory or in a register and if necessary transfer them (spilling and filling)? Why does the error occur? The program is very small, so the resources are not short.