Dear all, this is a code snip from the setup() fcn of a fairly big project running on a Mega2560. The observed behaviour is in the comments:
initGlobalVars(); // rigStatus.rigCal.cal1.FFBounds.mx = 1.2; inside here
DEBUGSERIAL.println(rigStatus.rigCal.cal1.FFBounds.mx); // prints 1.20
DEBUGSERIAL.println(rigStatus.rigCal.cal1.FFBounds.mx); // prints 0.00 (!!)
To be clear, that is the same print statement twice, giving different results. There are no ISRs running at all - not least one that could change this value while not looking, and nor is it declared volatile anywhere anyway.
Worth noting that the struct "cal1" is defined in an #included header file and declared as part of the principal sketch header file. It compiles and runs without warnings.
I'm just looking for any intuition or experience that may suggest where to look into this one as it has me stumped...
As a bit of extra fun:
initGlobalVars(); // rigStatus.rigCal.cal1.FFBounds.mx = 1.2; inside here
DEBUGSERIAL.println(rigStatus.rigCal.cal1.FFBounds.mx); // prints 1.20
DEBUGSERIAL.println(rigStatus.rigCal.cal1.FFBounds.mx); // prints 0.00 (!!)
rigStatus.rigCal.cal1.FFBounds.mx = 1.2;
DEBUGSERIAL.println(rigStatus.rigCal.cal1.FFBounds.mx); // prints 1.20
DEBUGSERIAL.println(rigStatus.rigCal.cal1.FFBounds.mx); // prints 1.20 (!!!)
and
initGlobalVars(); // rigStatus.rigCal.cal1.FFBounds.mx = 1.2; inside here
rigStatus.rigCal.cal1.FFBounds.mx = 1.2;
DEBUGSERIAL.println(rigStatus.rigCal.cal1.FFBounds.mx); // prints 1.20
DEBUGSERIAL.println(rigStatus.rigCal.cal1.FFBounds.mx); // prints 0.00 (!!)
Any assistance appreciated, thanks!!