DEFINE OSC 4
DEFINE LCD_DREG PORTB 'DEFINE EL PUERTO A USAR EL PIC
DEFINE LCD_DBIT 0 'DEFINE EL PRIMER BIT A USAR EL PUERTO
DEFINE LCD_RSREG PORTB 'DEFINE EL PUERTO A USAR PARA RS
DEFINE LCD_RSBIT 5 'DEFINE EL BIT DE RS EN EL PUERTO
DEFINE LCD_EREG PORTB 'DEFINE EL PUERTO A USAR PARA E
DEFINE LCD_EBIT 4 'DEFINE EL BIT DE E EN EL PUERTO
DEFINE LCD_BITS 4 'DEFINE EL NUMERO DE BITS CONECTADOS AL LCD
DEFINE LCD_LINES 2 'DEFINE EL NUMERO DE LINEAS
DEFINE LCD_COMMANDAUS 1000 'RETARDO ENTRE ENVIO DE COMANDOS AL LCD
DEFINE LCD_DATAUS 50 'RETARDO ENTRE EL ENVIO DE DATOS ENVIADOS
PORTB=%00000000
TRISD=%00000100
SYMBOL SDA = PORTD.0
SYMBOL SCL = PORTD.1
START VAR PORTD.2
LED VAR PORTD.3
CONTROL VAR BYTE
CONTROL= $A0
DIREC VAR WORD
DATO VAR BYTE
A1 VAR BYTE
X VAR BYTE
A1=0
LCDOUT $FE,1 'LIMPIA LCD
LCDOUT $FE,2
INICIO:D
LCDOUT $FE,1, " GRABADORA DE"
LCDOUT $FE,$C0," MEMORIAS I2C"
IF START ==1 THEN
GOTO RUTINA
ENDIF
PAUSE 2000
LCDOUT $FE,1 'LIMPIA LCD
LCDOUT $FE,2
IF START ==1 THEN
GOTO RUTINA
ENDIF
PAUSE 200
LCDOUT $FE,1, " PRESIONE"
LCDOUT $FE,$C0," START.."
IF START ==1 THEN
GOTO RUTINA
ENDIF
PAUSE 2000
IF START ==1 THEN
GOTO RUTINA
ENDIF
GOTO INICIO
RUTINA:
GRABAR:
LCDOUT $FE,1 'LIMPIA LCD
LCDOUT $FE,2
FOR DIREC =0 TO 207
GOSUB DATOS
LCDOUT $FE,1, "DATO. DIREC."
LCDOUT $FE,$C0, DEC DATO ," ",DEC DIREC
LED=1
PAUSE 700
I2Cwrite SDA, SCL, CONTROL, DIREC, [DATO], {ERRORD}
LED=0
PAUSE 10
LCDOUT $FE,1 'LIMPIA LCD
LCDOUT $FE,2
PAUSE 20
LCDOUT $FE,1,"DATO GUARDADO"
PAUSE 700
LCDOut $fe, 1 ' Limpia la LCD
LCDOUT $FE,2
PAUSE 20
NEXT DIREC
FINAL:
LCDOUT $FE,1, " GRABADO."
LCDOUT $FE,$C0," TERMINADO."
PAUSE 2000
LCDOUT $FE,1 'LIMPIA LCD
LCDOUT $FE,2
FOR DIREC =0 TO 207
LED=1
I2CRead SDA,SCL,CONTROL,DIREC,[A1], {ERRORD}
PAUSE 10
LCDOUT $FE,1, "DATO. DIREC."
LCDOUT $FE,$C0, DEC A1 ," ",DEC DIREC
PAUSE 250
LED=0
PAUSE 500
NEXT DIREC
GOTO INICIO
ERRORD:
LCDOUT $FE,1, " ERROR DE"
LCDOUT $FE,$C0," CONEXION"
PAUSE 2000
GOTO INICIO
DATOS:
lookup DIREC,[0,0,0,0,0,0,0,31,27,27,31,27,27,27,0,31,27,27,30,27,27,31,0,31,31,27,24,27,31,31,0,30,31,27,27,27,31,30,0,31,31,28,31,28,31,31,0 _
,31,31,24,30,24,24,24,0,31,31,24,27,25,31,31,0,27,27,27,30,27,27,27,0,31,31,14,14,14,31,31,0,31,31,6,6,22,31,31,0,27,27,30,28,30,27,27,0,24,24,24,24,27,31,31,0,27,31,21,17,17,17,17,0 _
,25,25,29,21,29,19,19,0,31,27,27,27,27,27,31,0,31,25,25,31,24,24,24,0,31,17,17,17,21,19,31,0,3,25,27,28,30,27,27,0,31,31,16,31,1,31,31,0,31,31,14,14,14,14,14,0,27,27,27,27,27,31,31,0 _
,27,27,27,27,27,31,14,0,17,17,17,21,21,31,27,0,17,17,10,4,10,17,17,0,27,27,27,17,4,4,4,0,31,31,1,14,16,31,31],DATO
RETURN