I'm just not getting this. Either my time is not being written, my clock = is not running, or the time is not being read. (and there is no way to = tell which it is) Here is the PIC16 code that is supposed to work. Can anyone translate it = to PIC18 ASM code? I've tried several times - even to the point of = forgetting the loop and just making X read cycles, and everything is 0. The ADD(ress) variables both start at H'B0' and the time variables run = to H'B6'. I know the RRFs get changed to RRCFs. Or, as an alternative, does anyone have working ASM code for the DS1302 = clock? Joe M. --------------------- start of code snippet -------------- ;**********************read time program************************* ; GET_TIME ; usage: recept 7 bytes time data, sudden mode read ; INPUT:NONE ; OUTPUT:save the 7 bytes into TIME_RX_ADD's 7 registers ;********************************************************* ;input parameter: none ;output parameter:20H--26H's 7 RAMs GET_TIME MOVLW B'10111111' ;multi bytes read mode MOVWF TIME_TX BSF RST CALL TIME_WRITE_1 MOVLW TIME_RX_ADD ;save bytes MOVWF FSR MOVLW D'7' ;read 7 bytes continuously MOVWF COUNT2 TR2 CALL TIME_READ_1 MOVF TIME_RX,W MOVWF INDF INCF FSR,F DECFSZ COUNT2,F GOTO TR2 BCF RST RETURN ;**********************write a byte program***************** ; TIME_WRITE_1 ; usage: send one byte only. ; used for control word etc. ;************************************************ ;input parameter=A3=BATIME_TX ;output parameter=A3=BAnone TIME_WRITE_1 MOVLW D'8' ;8 bits MOVWF COUNT1 TLOP BCF I_O ;the initial is low BCF SCLK BTFSC TIME_TX,0 BSF I_O RRF TIME_TX,F BSF SCLK ;rise-edge to send data DECFSZ COUNT1,F GOTO TLOP BCF SCLK ;recover RETURN ;******************read one byte program********************* ; TIME_READ_1 ; usage: read 1302 only one byte. ; schedule: receiving data when the falling edge comes, low byte first. ; according the I/o's high and low to select the shift right with or = without carry. ;*********************************************** ; INPUT:NONE ; OUTPUT:TIME_RX TIME_READ_1 BANK1 BSF TRISB,4 ; I_O set to input BANK0 MOVLW D'8' MOVWF COUNT1 ;read 8 bits. TR1 BCF SCLK ;read when falling edge BCF STATUS,C BTFSC I_O BSF STATUS,C RRF TIME_RX,F BSF SCLK ;recover high DECFSZ COUNT1,F GOTO TR1 BANK1 BCF TRISB,4 ;I_O recover to output BANK0 BCF SCLK RETURN NOP --------------------- end of code snippet -------------- ivp wrote: >> Maybe I just need to change it to "INCF FSR0L,1"??? > = >>From memory that won't increment FSR0H when FSR0L =3D 255 + 1 > = > wbr -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist