Aren't i2c devices among those tend to power up slower than the Teensy? And warm start versus power on shows that up - maybe why the battery power version acts better.
Perhaps make setup() start like this with added delay()?
Code:void setup() { // START SERIAL FOR DEBUGGING Serial.begin(9600); [B] delay(1000); // Less delay may work - if this is the issue it should be time in excess ...[/B] // ...
Tried the following :
- Reduce the speed all the way down to 24MHz
-Bring in delay in start up immediately after Serial.begin(9600);
-Shift the LCD init ahead of RTC init.
-Bring in delay between the LCD and RTC init.
And yet the issue remains... after each of above change you try powering up and it looks like you have killed the issue and just then it locks up. Anyway the RESET button is of no use when such a lock up happens ... which is very surprising. Only power cycling helps start code.
the final Setup() looks like this :
Code:
void setup()
{
// START SERIAL FOR DEBUGGING
Serial.begin(9600);
delay(1000);
Wire.begin();
// START THE LCD INTERFACE
lcd.begin(16, 2);
lcd.setBacklightPin(3, POSITIVE);
lcd.setBacklight(HIGH);
lcd.clear();
lcd.print(F( " IIC CHECK OUT. "));
delay(1000);
Wire.beginTransmission(DS3231_I2C_ADDRESS);
Wire.write(0xE); // Address the Control Register
Wire.write(0x00); // Write 0x0 to control Register
Wire.endTransmission();
Wire.beginTransmission(DS3231_I2C_ADDRESS);
Wire.write(0xF); // Address the Status register
Wire.write(0x00); // Write 0x0 to Status Register
Wire.endTransmission();
//setDS3231time(00,30,12,7,9,12,17); // Uncomment, enter right date &time , download once.
}