Define LCD_DREG   PORTB  '*bit de datos del LCD empezando
Define lCD_DBIT   0      '*por B.0 ,B.1, B.2 y B.3
Define LCD_RSREG   PORTB  '*bit de registro del LCD conectar
Define LCD_RSBIT   5      '*en el puerto B.5
Define LCD_EREG   PORTB  '*bit de Enable conectar en el
Define LCD_EBIT   4      '*puerto B.4     0,0048828125
ADCON1 =7
SCL_PIN var portb.7
SDA_PIN	var PORTb.6
segu var byte   
minu var byte                    
hora var byte                                       
minu1 var byte 
minu2 var byte 
diaS var byte                     
diaF var byte                    
mes  var byte                    
anio var byte

I2CWRITE Sda_PIN, scl_pin,%11010000,0,[$00] '* segundos
    pause 50                    
    I2CWRITE Sda_PIN, scl_pin,%11010000,1,[$12]  '* mitutos 
    pause 50  
    I2CWRITE Sda_PIN, scl_pin,%11010000,2,[$17] '* horas   
    pause 50  
    I2CWRITE Sda_PIN, scl_pin,%11010000,3,[$5]  '* dia de la semana  
    pause 50                              
    I2CWRITE Sda_PIN, scl_pin,%11010000,4,[$28] '* dia del mes   
    pause 50  
    I2CWRITE Sda_PIN, scl_pin,%11010000,5,[$12] '* mes   
    pause 50  
    I2CWRITE Sda_PIN, scl_pin,%11010000,6,[$06] '* ao  
    pause 50 
    I2CWRITE Sda_PIN, scl_pin,%11010000,7,[$10] '* frec 1hz 
    pause 50

inicio:

 
leer_RTC:           

    I2CREAD Sda_PIN,scl_pin,%11010000,0,[segu]
    I2CREAD Sda_PIN,scl_pin,%11010000,1,[minu]   
    I2CREAD Sda_PIN,scl_pin,%11010000,2,[hora]   
    I2CREAD Sda_PIN,scl_pin,%11010000,3,[diaS] 
    I2CREAD Sda_PIN,scl_pin,%11010000,4,[diaF]             
    I2CREAD Sda_PIN,scl_pin,%11010000,5,[mes] 
    I2CREAD Sda_PIN,scl_pin,%11010000,6,[anio] 

    lcdout $FE,1, hex2 hora,":",hex2 minu,":",hex2 segu," "   

    if diaS=$1 then lcdout $FE,$c0, "Dom."    
    if diaS=$2 then lcdout $FE,$c0, "Lun."
    if diaS=$3 then lcdout  $FE,$c0, "Mar."
    if diaS=$4 then lcdout  $FE,$c0, "Mie."
    if diaS=$5 then lcdout $FE,$c0, "Jue."
    if diaS=$6 then lcdout $FE,$c0, "Vie."
    if diaS=$7 then lcdout $FE,$c0, "Sab."
    
    lcdout $FE,$c5,hex2 diaF,"/" 
    lcdout $FE,$c17,"  /20",hex2 anio

    if mes=$1 then lcdout $FE,$C8, "Ene"      
    if mes=$2 then lcdout $FE,$c8, "Feb"
    if mes=$3 then lcdout $FE,$c8, "Mar"
    if mes=$4 then lcdout $FE,$c8, "Abr"
    if mes=$5 then lcdout $FE,$c8, "May"
    if mes=$6 then lcdout $FE,$c8, "Jun"
    if mes=$7 then lcdout $FE,$C8, "Jul"
    if mes=$8 then lcdout $FE,$c8, "Ago"
    if mes=$9 then lcdout $FE,$c8, "Sep"
    if mes=$10 then lcdout $FE,$c8, "Oct"
    if mes=$11 then lcdout $FE,$c8, "Nov"
    if mes=$12 then lcdout $FE,$c8, "Dic"
   goto inicio 