DS1302 Arduino - Quick Question

Hello, can anyone help me? I have been recently testing the DS1302 with the arduino, and I have successfully set the clock/calendar IC. Although the readings are 98% accurate, about 2% of the time I get random incorrect readings. Can you help me get rid of these arbitrary readings? I have added a decoupling capacitor to the supply voltage , and I am powering the device with a DC source. Thanks for your help.

BTW: Below, I have also included pseudo code, for shift-in function used to retrieve information from the IC.

Shiftin – Pseudo code 1. Make SCLK pin LOW 2. Wait 200 microseconds (uS) 3. Read I/O pin state 4. Make SCLK pin HIGH 5. Wait 200 microseconds (uS) 6. Repeat Steps 1-5, six more times 7. Output BCD value

To better assist you we’ll need to see the full code. Remember after pasting your code in to highlight it then click the # button so it sows up in the thread correctly.

Here is my code listing for my shiftin function

int shiftIn(int io, int sclk){
//shiftin Function used for receiving synchronous serial
//communication
int output;
int temp;
pinMode(sclk, OUTPUT);
pinMode(io, INPUT);
for (int i=0; i < 8; i++){
digitalWrite(sclk, LOW);
delayMicroseconds(2);
temp = digitalRead(io);
bitWrite(output,i,temp);
digitalWrite(sclk, HIGH);
delayMicroseconds(2);
}//end for loop
return output;
}//end shiftIn Function

SouLJaH:

Just a (not so) wild guess ... your tens of hours are messed up? Don't forget to mask out the bits that correspond to the 12/24 and AM/PM information.

Also: Reread the second sentence of Reply #1.

Don