Memory curruption issues with enough free memory on Mega 2560

Hello everyone,
I am working on a project with the goal of measuring the gravitational pulling force of an object hung on a swinging guitar chord. However whilst working on the project I encountered weird memory corruption. Values would be randomly changed, short for loops would not stop etc. Adding in debug statements can cause these problems to go away or get worse.
I checked if the Arduino ran out of memory using the MemoryFree library, but it reported a good 80% of free memory. I also tested the code on an Arduino Leonardo to rule out the possibility of broken hardware.
I've attached the source code below, because I thought it would be too long for a code block.
The issues appear when entering the [tt]mmCreator()[/tt] function and reflect mostly by the values in the measurementPoints array changing.
Thanks in advance,
The personified devil/Leonhard Saam

main.ino (8.52 KB)

I don't see a reason, why I would not own the memory, this is written into, considering the fact that the statement writing into the memory is in a function owned by the same class that owns the array.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.