The code below locks up when the RTC module is plugged in ...but boots with no issues and displays the Home Screen when the RTC is pulled out. But then then there is no valid time display. But if after booting i insert the RTC module the code runs fine and time is valid.. so what i am doing wrong ? This is on a Teensy3.5.
( Some functions not shown to keep the code small )
( Some functions not shown to keep the code small )
Code:
// The LCD is a 4L x 20Char type with a I2C backpack.
// Both the LCD and the RTC are connected to the SCL0 and SDA0 lines of Teensy3.5
// thorugh a 3.3V to 5V level shifter.
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#define DS3231_I2C_ADDRESS 0x68 // 0x68 is the RTC address
// DEFINE LCD PINS AND INSTANTIATE
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7); // 0x27 is the I2C bus address
void setup()
{
// START SERIAL FOR DEBUGGING
SerialPort.begin(9600);
// START THE I2C INTERFACE
Wire.begin();
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();
// START THE LCD INTERFACE
lcd.begin(20, 4);
lcd.setBacklightPin(3, POSITIVE);
lcd.setBacklight(HIGH);
lcd.clear();
lcd.print(F( " WELCOME TO MAKS. "));
lcd.print(F( " Version : MK2.0 "));
}
void loop ()
{
ReadTime();
if ( second != prevSecond )
{
prevSecond = second;
printLCD_RF( "MAK TPM MANAGEMENT.", 0);
sprintf(clockStringNow, " %02d-%02d %02d:%02d:%02d ", dayOfMonth, month, hour, minute, second);
printLCD_RF(" ", 1);
printLCD_RF(" ", 2);
printLCD_RF(clockStringNow, 3);
}
}