Bueno el programa lo estoy trabajando en ASM; aqui les va:
LIST P=16F877
INCLUDE P16F877.INC
CBLOCK H'F0'
SEGUNDO
MINUTO
HORA
DIASEMANA
DIA
MES
AÑO
I2C_BANDERAS
PDel0
PDel1
ENDC
ORG 0x00
GOTO INICIO
ORG 0x05
INICIO CLRF PORTB
CLRF PORTC
CLRF PORTA
CLRF PORTD
CALL BAN1
MOVLW b'00000110'
MOVWF ADCON1
CLRF TRISB
BSF TRISB,0
MOVLW 0xFF
MOVWF TRISC
CLRF TRISD
MOVLW 0xCF
MOVWF OPTION_REG
MOVLW 0x80
MOVWF SSPSTAT
MOVLW .9
MOVWF SSPADD
CALL BAN0
;CONFIGURACION DEL MODO MSSP EN MODO MAESTRO I2C
MOVLW 0x28
MOVWF SSPCON
CLRF I2C_BANDERAS
CALL CARGA_INICIAL
CALL ESCRIBIR
MOVLW 0x28
MOVWF SSPCON
CALL CONDICION_START
MOVLW b'11010000'
CALL ENVIAR_BYTE
MOVLW b'00000111'
CALL ENVIAR_BYTE
MOVLW b'00010000'
CALL ENVIAR_BYTE
CALL CONDICION_STOP
RTC_LEE MOVLW 0x28
MOVWF SSPCON
CALL CONDICION_START
MOVLW 0xD0
CALL ENVIAR_BYTE
MOVLW 0x00
CALL ENVIAR_BYTE
CALL CONDICION_STOP
CALL CONDICION_START
MOVLW 0xD1
CALL ENVIAR_BYTE
CALL LEER_BYTE
MOVWF SEGUNDO
CALL LEER_BYTE
MOVWF MINUTO
CALL LEER_BYTE
MOVWF HORA
CALL LEER_BYTE
MOVWF DIASEMANA
CALL LEER_BYTE
MOVWF DIA
CALL LEER_BYTE
MOVWF MES
BSF I2C_BANDERAS,0
CALL LEER_BYTE
MOVWF AÑO
CALL CONDICION_STOP
BCF I2C_BANDERAS,0
;VISUALIZACION
CALL RETARDO
CALL RETARDO
MOVLW H'01' ;Activa transistor
MOVWF PORTA
MOVF MINUTO,F
RLF MINUTO,W
MOVWF PORTD
CALL RETARDO
CALL RETARDO
MOVLW H'02' ;Activa transistor
MOVWF PORTA
SWAPF MINUTO,F
RLF MINUTO,W
MOVWF PORTD
CALL RETARDO
CALL RETARDO
MOVLW H'04' ;Activa transistor
MOVWF PORTA
MOVF SEGUNDO,F
RLF SEGUNDO,W
MOVWF PORTD
CALL RETARDO
CALL RETARDO
MOVLW H'08' ;Activa transistor
MOVWF PORTA
SWAPF SEGUNDO,F
RLF SEGUNDO,W
MOVWF PORTD
CALL RETARDO
CALL RETARDO
GOTO RTC_LEE
CONDICION_START BCF PIR1,SSPIF
CALL BAN1
BSF SSPCON2,SEN
CALL BAN0
TERMINO_START BTFSS PIR1,SSPIF
GOTO TERMINO_START
RETURN
CONDICION_STOP BCF PIR1,SSPIF
CALL BAN1
BSF SSPCON2,PEN
CALL BAN0
TERMINO_STOP BTFSS PIR1,SSPIF
GOTO TERMINO_STOP
RETURN
ENVIAR_BYTE BCF PIR1,SSPIF
MOVWF SSPBUF
ENVIAR_BYTE_ACK BTFSS PIR1,SSPIF
GOTO ENVIAR_BYTE_ACK
RETURN
LEER_BYTE BCF PIR1,SSPIF
CALL BAN1
BSF SSPCON2,RCEN
CALL BAN0
LEER_W BTFSS PIR1,SSPIF
GOTO LEER_W
BTFSC I2C_BANDERAS,0
GOTO NO_ACK
ACK BCF PIR1,SSPIF
CALL BAN1
BCF SSPCON2,ACKDT
BSF SSPCON2,ACKEN
CALL BAN0
ACK_W BTFSS PIR1,SSPIF
GOTO ACK_W
RETURN
NO_ACK BCF PIR1,SSPIF
CALL BAN1
BSF SSPCON2,ACKDT
BSF SSPCON2,ACKEN
CALL BAN0
NO_ACK_W BTFSS PIR1,SSPIF
GOTO NO_ACK_W
MOVF SSPBUF,W
RETURN
CARGA_INICIAL MOVLW 0x00
MOVWF SEGUNDO
MOVLW 0x00
MOVWF MINUTO
CLRF HORA
MOVLW 0x06
MOVWF DIASEMANA
MOVLW 0x02
MOVWF DIA
MOVLW 0x03
MOVWF MES
MOVLW 0x07
MOVWF AÑO
RETURN
ESCRIBIR CALL CONDICION_START
MOVLW 0xD0
CALL ENVIAR_BYTE
MOVLW 0x00
CALL ENVIAR_BYTE
MOVF SEGUNDO,W
CALL ENVIAR_BYTE
MOVF MINUTO,W
CALL ENVIAR_BYTE
MOVF HORA,W
CALL ENVIAR_BYTE
MOVF DIASEMANA,W
CALL ENVIAR_BYTE
MOVF DIA,W
CALL ENVIAR_BYTE
MOVF MES,W
CALL ENVIAR_BYTE
MOVF AÑO,W
CALL ENVIAR_BYTE
CALL CONDICION_STOP
RETURN
BAN0 BCF STATUS,RP0
BCF STATUS,RP1
RETURN
BAN1 BSF STATUS,RP0
BCF STATUS,RP1
RETURN
BAN2 BCF STATUS,RP0
BSF STATUS,RP1
RETURN
BAN3 BSF STATUS,RP0
BSF STATUS,RP1
RETURN
RETARDO movlw .7 ; 1 set numero de repeticion (
movwf PDel0 ; 1 |
PLoop1 movlw .213 ; 1 set numero de repeticion (A)
movwf PDel1 ; 1 |
PLoop2 clrwdt ; 1 clear watchdog
decfsz PDel1, 1 ; 1 + (1) es el tiempo 0 ? (A)
goto PLoop2 ; 2 no, loop
decfsz PDel0, 1 ; 1 + (1) es el tiempo 0 ? (
goto PLoop1 ; 2 no, loop
PDelL1 goto PDelL2 ; 2 ciclos delay
PDelL2 clrwdt ; 1 ciclo delay
return
END