
;ESTE ES EL PROGRAMA 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    00
	         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
                    
MEDIAINSTRUC
   		 movwf     LCD_Dato       ; que hay que enviar y lo guarda.
		 GOTO	   DATOS3

DATOS	         BSF	   PORTA,RS
INSTRUC	         movwf     LCD_Dato       ; que hay que enviar y lo guarda.
		 movlw	   0x0F		  ;< evitar cambiar el estado del nibble bajo del portb
		 andwf	   PORTB,F 		;PORTB= 0000XXXX
		 movf	   LCD_Dato,W
		 andlw	   0xF0
		 iorwf	   PORTB,F	  ;PORTB=DDDDXXXX     >
		 BSF	   PORTA,E
		 CALL	   RETARDO
		 BCF	   PORTA,E
		 CALL	   RETARDO
DATOS3
		 movlw	   0x0F	          ;< evitar cambiar el estado del nibble bajo del portb
		 andwf	   PORTB,F	  ;PORTB= 0000XXXX
		 SWAPF	   LCD_Dato,W
		 ANDLW 	   0xF0
  		 iorwf	   PORTB,F	  ;PORTB=DDDDXXXX     >
		 BSF	   PORTA,E
		 call	   RETARDO
		 BCF	   PORTA,E
		 BCF	   PORTA,RS
		 CALL	   RETARDO
   		 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	   PORTA
		 CLRF	   PORTB

LCDINI
		 movlw	   b'00000010'	  ;inicializar a 4 bits
		 call	   MEDIAINSTRUC

		 movlw	   b'00100000'
		 call	   INSTRUC

		 movlw	   b'00001110'
		 call	   INSTRUC

		 movlw	   b'00000110'
		 call	   INSTRUC

RR		 MOVLW     0x80	          ;EL PUNTERO SE UBICA EN LA SEGUNDA LINEA
       	         CALL      INSTRUC	  ;PARA DECIR EMPRESA

                 CLRF      MENS
A      	         MOVF      MENS,W
                 CALL      TABLA
                 CALL      DATOS
                 INCF      MENS,F
                 MOVF      MENS,W
                 XORLW     .15
                 BTFSS     STATUS,Z
                 GOTO      A
G		 GOTO	   $
		
	         END












