Autor Tema: Ayuda con Rutina para Controlar LCD  (Leído 2206 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado Lionel

  • PIC10
  • *
  • Mensajes: 8
Ayuda con Rutina para Controlar LCD
« en: 22 de Octubre de 2012, 03:11:48 »
Hola Gente..

Empezando con el tema de los Pics empeze a jugar con los LEDs, leer y escribir la EEPROM, ...

Ahora me surgio un pequeño problemilla, espero puedan ayudarme.. Estoy armando las rutinas para controlar un LCD 16x2 y me encuentro con varias cosas..
- Al simularlo en el Proteus el programa funciona, solo si cargo el archivo .cof, con el .hex no..
- En la realidad no funciona ni para atras..
- Cuando modifico el programa y vuelvo a cargar (el .cof) sigue simulando el programa anterior..

Aqui el programa entero:
Código: ASM
  1. ; --- Datos PIC ---
  2. list    P=16F628A
  3. #include        <P16F628A.INC>
  4.        
  5. ; --- Fusibles de Configuracion ---
  6. __CONFIG _BOREN_ON & _CP_OFF & _DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_ON & _INTOSC_OSC_NOCLKOUT
  7.  
  8. ; --- Declaraciones ---
  9. COUNTER equ     0x20
  10.  
  11. ; --- Programa ---
  12. Reset
  13.         org     0x00
  14.         goto    Inicio
  15.         org     0x04
  16.         nop
  17.         org     0x05
  18.  
  19. Inicio
  20.         bsf     STATUS,RP0
  21.         bsf     PCON,OSCF       ; Oscilador Interno funcione a 4MHz.
  22.         movlw   0x20
  23.         movwf   TRISA
  24.         movlw   0x00
  25.         movwf   TRISB
  26.         bcf     STATUS,RP0
  27.         movlw   0x07    ; Comparadores Apagados.
  28.         movwf   CMCON
  29.  
  30. Programa
  31.         call    Retardo
  32.        
  33.         movlw   b'00000001'     ; Clear Display
  34.         bcf     PORTA,0 ; RS = 0
  35.         call    SENDTOLCD
  36.         movlw   b'00000011'     ; Home
  37.         bcf     PORTA,0 ; RS = 0
  38.         call    SENDTOLCD
  39.         movlw   b'00000110'     ; Entry Mode
  40.         bcf     PORTA,0 ; RS = 0
  41.         call    SENDTOLCD
  42.         movlw   b'00001110'     ; Display Control
  43.         bcf     PORTA,0 ; RS = 0
  44.         call    SENDTOLCD
  45.         movlw   b'00010100'     ; Cursor Display Shift
  46.         bcf     PORTA,0 ; RS = 0
  47.         call    SENDTOLCD
  48.         movlw   b'00111000'     ; Function Set
  49.         bcf     PORTA,0 ; RS = 0
  50.         call    SENDTOLCD
  51.        
  52.         movlw   'L'
  53.         bsf     PORTA,0 ; RS = 1
  54.         call    SENDTOLCD
  55.         movlw   'i'
  56.         bsf     PORTA,0 ; RS = 1
  57.         call    SENDTOLCD
  58.         movlw   'o'
  59.         bsf     PORTA,0 ; RS = 1
  60.         call    SENDTOLCD
  61.         movlw   'n'
  62.         bsf     PORTA,0 ; RS = 1
  63.         call    SENDTOLCD
  64.         movlw   'e'
  65.         bsf     PORTA,0 ; RS = 1
  66.         call    SENDTOLCD
  67.         movlw   'l'
  68.         bsf     PORTA,0 ; RS = 1
  69.         call    SENDTOLCD
  70.        
  71.         nop
  72.         goto    $-1
  73.  
  74. Retardo
  75.         movlw   0xFF
  76.         movwf   COUNTER
  77.         decf    COUNTER,1
  78.         btfss   STATUS,Z
  79.         goto    $-2
  80.         retfie
  81.  
  82. SENDTOLCD
  83.         bsf     PORTA,1 ; EN = 1
  84.         movwf   PORTB   ; Muevo el Dato al Puerto.
  85.         nop
  86.         bcf     PORTA,1 ; EN = 0 (supuestamente con la bajada del EN el LCD toma los datos)
  87.         nop
  88.         bcf     PORTA,0 ; RS = 0
  89.         clrf    PORTB
  90.         call    Retardo
  91.         retfie
  92.  
  93.         end

Seguro es una estupidez pero no me estoy dando cuenta..

Gracias por su tiempo..

Saludos..