range since the chip only uses CE3*
*/
-xdata at 0x310000 static volatile unsigned char rtc;
+__xdata __at (0x310000) static volatile unsigned char rtc;
// this is the 64bit pattern that has to be recognized by the ds1315
-code unsigned char rtcMagic[8]={0xc5,0x3a,0xa3,0x5c,0xc5,0x3a,0xa3,0x5c};
+__code unsigned char rtcMagic[8]={0xc5,0x3a,0xa3,0x5c,0xc5,0x3a,0xa3,0x5c};
#define BCDtoINT(x) (((x)&0x0f)+((x)>>4)*10)
#define INTtoBCD(x) (((x)%10)+(((x)/10)<<4))
}
}
}
- rtcDate->tm_year=BCDtoINT(rtcBytes[7]+100); // year since 1900
+ rtcDate->tm_year=BCDtoINT(rtcBytes[7])+100; // year since 1900
rtcDate->tm_mon=BCDtoINT(rtcBytes[6])-1; // jan=0
rtcDate->tm_mday=BCDtoINT(rtcBytes[5]);
rtcDate->tm_wday=(rtcBytes[4]&0x07)-1; // monday=0?
unsigned char rtcBytes[8];
unsigned char byte,bitMask;
- rtcBytes[7]=INTtoBCD(rtcDate->tm_year-100);
+ rtcBytes[7]=INTtoBCD(rtcDate->tm_year%100);
rtcBytes[6]=INTtoBCD(rtcDate->tm_mon)+1;
rtcBytes[5]=INTtoBCD(rtcDate->tm_mday);
rtcBytes[4]=(INTtoBCD(rtcDate->tm_wday)+1)&0x07; //set 24h mode