I want to initialize the internal RTC of a PIC18F67K22 with some fix time and date. Time is set properly, but date is not set properly. The problem occurs in setting the year. year is not set to whatever we give to RTC.
Find attach below RTC code, which I write to initialize internal RTC.
RtccInitClock(); //Intialize the internal RTC RtccWrOn(); //Write enable for RTC //enable RTCC output on RTCC output pin PIE3bits.RTCCIE=1; //Enables the alarm interrupt from RTC RtccTimeDate.f.hour = 2; //Set Hour RtccTimeDate.f.min = 3; //Set minute RtccTimeDate.f.sec = 4; //Set second RtccTimeDate.f.mday = 05; //Set day RtccTimeDate.f.mon = 06; //Se month RtccTimeDate.f.year = 14; //set year RtccWriteTimeDate(&RtccTimeDate,1); //Writes the date and time read from the external RTC delay_ms(10); RtccSetAlarmRpt(RTCC_RPT_SEC,1); //Set the alarm repeat to every minute ALRMCFGbits.CHIME = 1; //Alarm repeat infinite times RtccWriteAlrmTimeDate(&RtccTimeDate); //Writes Alarm date and Time mRtccOn(); //Enables the RTC mRtccAlrmEnable();
Is there any setting I may have missed?