Fixed it now
Found the problem and sorted it.
I got the PIC to output the test variables then use them to set the RTC before reading back and outputting the read values.
01-Sep-2006 Fri
01-Sep-2006 Fri
02-Sep-2006 Sat
02-Sep-2006 Sat
03-Sep-2006 Sun
03-Sep-2006 Sun
04-Sep-2006 Mon
04-Sep-2006 Mon
05-Sep-2006 Tue
05-Sep-2006 Tue
06-Sep-2006 Wed
06-Sep-2006 Wed
07-Sep-2006 Thu
07-Sep-2006 Thu
08-Sep-2006 Fri
08-Sep-2006 Fri
09-Sep-2006 Sat
09-Sep-2006 Sat
10-Sep-2006 Sun
10-Sep-2006 Sat
11-Sep-2006 Mon
11-Sep-2006 Sun
12-Sep-2006 Tue
12-Sep-2006 Mon
13-Sep-2006 Wed
13-Sep-2006 Tue
14-Sep-2006 Thu
14-Sep-2006 Wed
15-Sep-2006 Fri
15-Sep-2006 Thu
16-Sep-2006 Sat
16-Sep-2006 Fri
17-Sep-2006 Sun
17-Sep-2006 Sat
18-Sep-2006 Mon
18-Sep-2006 Sun
19-Sep-2006 Tue
19-Sep-2006 Mon
20-Sep-2006 Wed
20-Sep-2006 Mon
21-Sep-2006 Thu
21-Sep-2006 Tue
22-Sep-2006 Fri
22-Sep-2006 Wed
23-Sep-2006 Sat
23-Sep-2006 Thu
24-Sep-2006 Sun
24-Sep-2006 Fri
25-Sep-2006 Mon
25-Sep-2006 Sat
26-Sep-2006 Tue
26-Sep-2006 Sun
27-Sep-2006 Wed
27-Sep-2006 Mon
28-Sep-2006 Thu
28-Sep-2006 Tue
29-Sep-2006 Fri
29-Sep-2006 Wed
30-Sep-2006 Sat
30-Sep-2006 Wed
01-Oct-2006 Sun
01-Oct-2006 Tue
02-Oct-2006 Mon
02-Oct-2006 Wed
03-Oct-2006 Tue
03-Oct-2006 Thu
04-Oct-2006 Wed
04-Oct-2006 Fri
05-Oct-2006 Thu
05-Oct-2006 Sat
06-Oct-2006 Fri
06-Oct-2006 Sun
07-Oct-2006 Sat
07-Oct-2006 Mon
08-Oct-2006 Sun
08-Oct-2006 Tue
09-Oct-2006 Mon
09-Oct-2006 Wed
10-Oct-2006 Tue
10-Oct-2006 Wed
11-Oct-2006 Wed
11-Oct-2006 Thu
12-Oct-2006 Thu
12-Oct-2006 Fri
13-Oct-2006 Fri
13-Oct-2006 Sat
14-Oct-2006 Sat
14-Oct-2006 Sun
15-Oct-2006 Sun
15-Oct-2006 Mon
16-Oct-2006 Mon
16-Oct-2006 Tue
17-Oct-2006 Tue
17-Oct-2006 Wed
18-Oct-2006 Wed
18-Oct-2006 Thu
19-Oct-2006 Thu
19-Oct-2006 Fri
20-Oct-2006 Fri
20-Oct-2006 Fri
21-Oct-2006 Sat
21-Oct-2006 Sat
22-Oct-2006 Sun
22-Oct-2006 Sun
23-Oct-2006 Mon
23-Oct-2006 Mon
24-Oct-2006 Tue
24-Oct-2006 Tue
25-Oct-2006 Wed
25-Oct-2006 Wed
26-Oct-2006 Thu
26-Oct-2006 Thu
27-Oct-2006 Fri
27-Oct-2006 Fri
28-Oct-2006 Sat
28-Oct-2006 Sat
29-Oct-2006 Sun
29-Oct-2006 Sun
30-Oct-2006 Mon
30-Oct-2006 Sun
31-Oct-2006 Tue
31-Oct-2006 Mon
After studying my "SetRTC" subroutine I spotted the problem.
In Melanie's original code she had two sets of variables "SETvarname" and "RTCvarname". In my project the clock is set using commands via the serial port and data is fed in in the forms DDMMYY to set the date and HHMMSS to set the time.
Once a command is received I overwrite the existing RTC variables and call the SetRTC routine which converts them to BCD and sets the clock. There was the problem. Because I only have the one set of variables by the time I got the the DayofWeek calculation the values were now BCD rather than Decimal.
Moving the Day of Week calculation to before the Decimal to BCD conversions fixed the problem 
The worst thing about the "bug" was that it only went wrong on certain dates so could have gone undetected for a long time.
Once again, apologies for doubting the integrity of Melanie's code.
Keith
www.diyha.co.uk
www.kat5.tv
Bookmarks