/* *------------------------------------------------------------------------------ * void InitializeRtc(void) * * Summary : Initialize the I2C module and RTC * * Input : None * * Output : None * *------------------------------------------------------------------------------ */ void InitializeRtc(void) { UINT8 tempVar; #ifdef RTC_DS3232 // Read Oscillator control register tempVar = ReadByteI2C(DEV_ADDR_RTC,RTC_REG_CTR); // check if the RTC oscillator run flag is enabled if(tempVar & 0x80) { //Enable oscillator (bit 7=0) WriteByteI2C(DEV_ADDR_RTC,RTC_REG_CTR,0x00); } #else // Read seconds register contents tempVar = ReadByteI2C(DEV_ADDR_RTC,RTC_REG_SEC); // check if the RTC oscillator run flag is enabled if(tempVar & 0x80) { // Enable oscillator (bit 7=0) tempVar = tempVar & 0x7F; WriteByteI2C(DEV_ADDR_RTC,RTC_REG_SEC,tempVar); } #endif /* ReadRtcTimeAndDate((UINT8*)&stRtcRegs); stRtcRegs.mSeconds = 0x00; // second = 00 stRtcRegs.mMinute = 0x29; // minute = 29 stRtcRegs.mHour = 0x21; // hour = 21 ,24-hour mode(bit 6=0) stRtcRegs.mDay = 0x01; // Day = 1 or sunday stRtcRegs.mDate = 0x12; // Date = 12 stRtcRegs.mMonth = 0x10; // month = October stRtcRegs.mYear = 0x08; // year = 08 or 2008 WriteRtcTimeAndDate((UINT8*)&stRtcRegs); // Set RTC */ #ifdef TIME_DEBUG stRtcRegs.mSeconds = 0; // second = 00 stRtcRegs.mMinute = 50; // minute = 29 stRtcRegs.mHour = 6; #endif // Setup task to run #ifdef TIME_DEBUG SCH_AddTask(UpdateRealTimeClockTask ,0,TASK_10MSEC_PERIOD); #else // SCH_AddTask(UpdateRealTimeClockTask ,0,TASK_100MSEC_PERIOD); #endif }
/* *------------------------------------------------------------------------------ * void InitializeRtc(void) * * Summary : Initialize the I2C module and RTC * * Input : None * * Output : None * *------------------------------------------------------------------------------ */ void RTC_Init(void) { UINT8 tempVar; // Read seconds register contents tempVar = ReadByteI2C(DEV_ADDR_RTC,RTC_REG_SEC); // Enable oscillator (bit 7=0) tempVar = tempVar & 0x7F; WriteByteI2C(DEV_ADDR_RTC,RTC_REG_SEC,tempVar); // set RTC control register to o/p 1Hz sqr wave o/p WriteByteI2C(DEV_ADDR_RTC,RTC_REG_CTR,0x90); /* ReadRtcTimeAndDate((UINT8*)&stRtcRegs); stRtcRegs.mSeconds = 0x00; // second = 00 stRtcRegs.mMinute = 0x29; // minute = 29 stRtcRegs.mHour = 0x21; // hour = 21 ,24-hour mode(bit 6=0) stRtcRegs.mDay = 0x01; // Day = 1 or sunday stRtcRegs.mDate = 0x12; // Date = 12 stRtcRegs.mMonth = 0x10; // month = October stRtcRegs.mYear = 0x08; // year = 08 or 2008 WriteRtcTimeAndDate((UINT8*)&stRtcRegs); // Set RTC */ #ifdef TIME_DEBUG stRtcRegs.mSeconds = 0; // second stRtcRegs.mMinute = 5; // minute stRtcRegs.mHour = 12; // hour #endif // Setup task to run //#ifdef TIME_DEBUG // SCH_AddTask(UpdateRealTimeClockTask ,0,TASK_10MSEC_PERIOD); //#else // SCH_AddTask(UpdateRealTimeClockTask ,0,TASK_100MSEC_PERIOD); //#endif }