Hi,
I note that the latest GHI assembly documentation states that the [italic]RealTimeClock::IsTimeValid[/italic] Property is now obsolete. Other threads on this forum suggest that a similar function can be achived by examining the value returned by [italic]RealTimeClock::GetTime()[/italic] and checking it for validity (e.g check that the year is >= 2011). I’m not certain that the following provides any additional merit, but I’ve coded up a replacement - comments please…
static public bool isRTCTimeValid()
{
Register regSec = new Register(0xE0024020);
Register regMin = new Register(0xE0024024);
Register regHour = new Register(0xE0024028);
Register regDay = new Register(0xE002402C);
Register regMon = new Register(0xE0024038);
Register regYear = new Register(0xE002403C);
uint Sec = regSec.Read();
uint Min = regMin.Read();
uint Hour = regHour.Read();
uint Day = regDay.Read();
uint Mon = regMon.Read();
uint Year = regYear.Read();
return (Sec >= 0 && Sec <= 59 &&
Min >= 0 && Min <= 59 &&
Hour >= 0 && Hour <= 23 &&
Mon >= 1 && Mon <= 12 &&
Year >= 2011 && Year <= 2100 &&
Day >= 0 && Day <= (uint)DateTime.DaysInMonth((int)Year, (int)Mon));
}