Problem: subraction giving very strange results

marco_c:
Yes. Have you looked at the code in the link?

Generally using functions like malloc() on embedded processors is a bad idea. Use static arrays and manage you memory usage really closely.

Ok, I run this function Serial.println(freeMemory()); and I got always the same value: 957. I ran it just before and after the crytical part giving me error. Is it ok to have always the same result?
I have some variables that are constant and won't be changed should I move them to the flash memory using PROGMEM?