Hi, Does anyone have C example code on how to use the RTC module? Thanks
Oops, In the previous example, RtcSetTime is incorrect as it needs to write to RTC_RTCH and RTC_RTCL instead of writing to RTC_RELL and RTC_RELH; But even with this improvement it does not work :-(
void RtcSetTime(tTimeOfDay time) { RTC_T14 = time.msecOfDay & 0x0FFFFFFFL; RTC_RTCL = 0; RTC_RTCH = time.days << 6; }
Now I understand better. Unfortunately I use the C167CS which is different than the XC167. As we are using different processors, I don't think I can help you. Are you sure that you are writing to the RTC_CON register? Try writing to the RTC_CON register last, after the write to RTC_IC_IE. In your init routine, call the RtcSetTime routine to set a time. Set a non-zero time. When you call RtcGetTime you should at the very least see the non-zero time. Sorry that I couldn't help. If you figure it out, perhaps you could post the solution here.