Marco Lo Bartolo
Member
Hi y'all
I have been having a couple of issues with a sketch on my Teensy 4.1. I am running the latest Teensyduino version, but I was having the same issue with the previous version (1.58), i'm using PlatformIO ad VsCode under Windows 10.
The problem regards the sequence of function calls in setup(). I have a particular function, mts.initializeVariables(), that retrieves values from EEPROM.
I usually called it at the beginning of the setup(), and it has been working fine on some of my Teensys 4.1. I recently bought a couple more 4.1s, and the very same binaries that were previously fine are now causing the MCU to hang indefinitely at startup. I couldn't trace it to any particular fault in the code. I ended up "fixing" it by moving the mts.initializeVariables() to the very end of setup(). This has since been working fine on all boards.
Here's the setup(), in a way that's working:
If instead I put it first, it doesn't work at all:
And here's the function itself:
My questions now are: should the sequence of execution in setup() be this influential on the flow?
Does it have anything to do with a initialization of the EEPROM library/physical memory? Is it influenced by the addresses I'm trying to access (addresses and sizes are fine and fixed)? Any way to fix this, maybe using a different library?
Thanks All,
-Marco.
I have been having a couple of issues with a sketch on my Teensy 4.1. I am running the latest Teensyduino version, but I was having the same issue with the previous version (1.58), i'm using PlatformIO ad VsCode under Windows 10.
The problem regards the sequence of function calls in setup(). I have a particular function, mts.initializeVariables(), that retrieves values from EEPROM.
I usually called it at the beginning of the setup(), and it has been working fine on some of my Teensys 4.1. I recently bought a couple more 4.1s, and the very same binaries that were previously fine are now causing the MCU to hang indefinitely at startup. I couldn't trace it to any particular fault in the code. I ended up "fixing" it by moving the mts.initializeVariables() to the very end of setup(). This has since been working fine on all boards.
Here's the setup(), in a way that's working:
void setup()
{
pinMode(TEST_PIN, OUTPUT);
digitalWrite(TEST_PIN, LOW);
coreTermometer.begin();
Serial.begin(115200); // Baud Rate set to 115200
Serial.setTimeout(10000); // Timeout set to 1 second
// Serial Messages
rcv_msg.reserve(512);
// Init status
currentStatus = STATUS_DISCONNECTED;
class.initializeVariables(); <----- This one
}
If instead I put it first, it doesn't work at all:
void setup()
{
class.initializeVariables(); <---- This one
pinMode(TEST_PIN, OUTPUT);
digitalWrite(TEST_PIN, LOW);
coreTermometer.begin();
Serial.begin(115200); // Baud Rate set to 115200
Serial.setTimeout(10000); // Timeout set to 1 second
// Serial Messages
rcv_msg.reserve(512);
// Init status
currentStatus = STATUS_DISCONNECTED;
}
And here's the function itself:
int Class::initializeVariables()
{
// Read the currentIndex from EEPROM
int currentIndex;
EEPROM.get(INDEX_ADDRESS, currentIndex);
EEPROM.get(DEVICE_ID_ADDRESS, m_deviceId);
return 0;
}
};
My questions now are: should the sequence of execution in setup() be this influential on the flow?
Does it have anything to do with a initialization of the EEPROM library/physical memory? Is it influenced by the addresses I'm trying to access (addresses and sizes are fine and fixed)? Any way to fix this, maybe using a different library?
Thanks All,
-Marco.