We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hi: /* these codes are about DS1244. I can make sure the circuit is correct because I can access data from DS1244 correct . but I can't use Phantom Real-Time Clocks. when I try to get the data of Time register, I get all zero ,Thank you for you reply*/
#include "reg51.h" #include "absacc.h" static char xdata * data wdata; unsigned char code DSdata[8] = {0xC5,0x3A,0xA3,0x5C,0xC5,0x3A,0xA3,0x5C}; unsigned char code settime[8] = {0x00,0x00,0x00,0xB2,0x14,0x27,0x08,0x03}; sbit P10 = P1^0; sbit P11 = P1^1; void gettime(unsigned char x[]); void setuptime(void); void initime(void) ; main() { /////////////////////////// unsigned char CurrentTime[8]; P1 = 0xFF; if ( P10 ==0) { initime(); setuptime(); } if ( P11 == 0) { initime(); gettime(CurrentTime); // ALL THE DATA OF CurrentTime are zero.; } } void gettime(unsigned char x[]) { unsigned char i,loop,temp,dat; bit D0; wdata = 0xF0FF; for ( i = 0 ; i < 8 ; i++) { dat = 0; for ( loop = 0 ; loop < 8 ; loop++) { temp = * wdata; D0 = temp & 0x01; if(D0) dat = dat | 0x80; dat = dat>>1; } x[i] = dat; } } /*888888888888888888888888888888888888888888888888888*/ void setuptime(void) { unsigned char i,loop,temp,dat; bit D0; wdata = 0xF0FF; for ( i = 0 ; i < 8 ; i++) { temp = settime[i]; for ( loop = 0 ; loop < 8 ; loop++) { D0 = temp & 0x01; dat = (char)D0; *wdata = dat; temp = temp>>1; } } } /*8888888888888888888888888888888888888888888888888888888888*/ void initime(void) { unsigned char i,loop,temp,dat; //bit D0; wdata = 0xF0FF; for ( i = 0 ; i < 64 ; i++) temp = *wdata; for ( i = 0 ; i < 8 ; i++) { temp = DSdata[i]; for ( loop = 0 ; loop < 8 ; loop++) { dat = temp >>loop; *wdata = dat; } } }