  
;ESTE ES EL PROGRAMS FINAL
	LIST 	P=16F84A
	#INCLUDE<P16F84A.INC>
PDel0   EQU	10
PDel1   EQU	11
PDel2	EQU	12
MENS	EQU	13
LCD_Dato	EQU	14


RS		EQU	0
E		EQU	1

                                          
	ORG	0
	GOTO INICIO
	ORG 05
	
ms 	;  1000 cycles:1ms
PDelayY  movlw     .248      ; 1 set number of repetitions
        movwf     PDel0     ; 1 |
PLoop0YY  clrwdt              ; 1 clear watchdog
        decfsz    PDel0, 1  ; 1 + (1) is the time over?
        goto      PLoop0YY    ; 2 no, loop
PDelL1W goto PDelL2III         ; 2 cycles delay
PDelL2III  clrwdt              ; 1 cycle delay
        return              ; 2+2 Done

RETARDO ;RETURN; Code generated by PDEL  ver 1.0  on 24/11/2007 at 06:46:05 p.m.
; Description: Waits 3000 cycles
;-------------------------------------------------------------
PDelayBBBBBB  movlw     .4        ; 1 set number of repetitions (B)
        movwf     PDel0     ; 1 |
PLoop1IIII  movlw     .186      ; 1 set number of repetitions (A)
        movwf     PDel1     ; 1 |
PLoop2LLLL  clrwdt              ; 1 clear watchdog
        decfsz    PDel1, 1  ; 1 + (1) is the time over? (A)
        goto      PLoop2LLLL    ; 2 no, loop
        decfsz    PDel0,  1 ; 1 + (1) is the time over? (B)
        goto      PLoop1IIII    ; 2 no, loop
PDelL1OOOO  goto PDelL2OOOO         ; 2 cycles delay
PDelL2OOOO  clrwdt              ; 1 cycle delay
        return              ; 2+2 Done

             
;RETARDO ;RETURN; 1000000 ciclos : 1seg
PDelayf  	movlw     .14       ; 1 set number of repetitions (C)
        		movwf       PDel0     ; 1 |
PLoop0  	movlw       .72       ; 1 set number of repetitions (B)
        		movwf       PDel1     ; 1 |
PLoop1 	movlw       .247      ; 1 set number of repetitions (A)
        		movwf       PDel2     ; 1 |
PLoop2 	clrwdt              ; 1 clear watchdog
	    decfsz      PDel2, 1  ; 1 + (1) is the time over? (A)
	    goto        PLoop2    ; 2 no, loop
	    decfsz      PDel1,  1 ; 1 + (1) is the time over? (B)
	    goto        PLoop1    ; 2 no, loop
	    decfsz      PDel0,  1 ; 1 + (1) is the time over? (C)
      	goto        PLoop0    ; 2 no, loop
PDelL178  goto   PDelL2         ; 2 cycles delay
PDelL2  clrwdt              ; 1 cycle delay
        return              ; 2+2 Done 
                    
INSTRUC	BCF	     PORTA,RS        ;COLOCA EN CERO RAO
		GOTO		DATOS2


DATOS	BSF	     PORTA,RS
DATOS2	BSF	     PORTA,E      ; Permite funcionamiento del LCD mediante un pequeño
   		movwf   LCD_Dato      ; que hay que enviar y lo guarda.
 		SWAPF	LCD_Dato,0
		MOVWF	PORTB
		CALL	RETARDO
		BCF	     PORTA,E 
		CALL	RETARDO
		BSF	     PORTA,E 
 		movf   LCD_Dato,0 
		ANDLW B'11110000'
  		MOVWF	PORTB
		call	RETARDO
		BCF	     PORTA,E 
   		return






TABLA  	ADDWF	PCL,1		;TABLA DE DATOS A MOSTRAR EN LCD.
		RETLW	"P"
		RETLW	"I"
		RETLW	"R"
		RETLW	"O"
		RETLW	"T"
		RETLW	"E"
		RETLW	"C"
		RETLW	" "
		RETLW	"B"
		RETLW	"U"
	    RETLW   "R"
		RETLW   "N"
		RETLW   "E"
		RETLW   "R"
		RETLW   "S"


INICIO
		BSF	     STATUS,5
		MOVLW	H'00'
		MOVWF	PORTB
		MOVLW	B'00000000'	
		MOVWF	PORTA
		BCF	     STATUS,5
		CLRF	     PORTB
LCDINI
		movlw B'00101000'      ;function set=2 lineas, 5*7 dots y 4 bits    
		CALL	     INSTRUC
		MOVLW	B'00000110'     ;DIRECCION A LA DERECHA
		CALL	     INSTRUC
		MOVLW	B'00001100'     ;PRENDE PANTALLA
		CALL	     INSTRUC
		MOVLW	B'00000001'     ;LIMPIA PANTALLA
		CALL	     INSTRUC	
		
RR		MOVLW     B'10000000'      ;EL PUNTERO SE UBICA EN LA SEGUNDA LINEA
       	CALL      INSTRUC	 	;PARA DECIR EMPRESA	

        CLRF      MENS
A      	MOVF      MENS,0
        CALL      TABLA
        CALL      DATOS
        INCF      MENS,1
        MOVF      MENS,0
        XORLW     .15
        BTFSS     STATUS,2
        GOTO     A
G		GOTO	RR
		
	END












