Autor Tema: LCD 162JHD y PIC 16F690 no se ve la segunda linea  (Leído 1258 veces)

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

Desconectado rienfega

  • PIC10
  • *
  • Mensajes: 1
LCD 162JHD y PIC 16F690 no se ve la segunda linea
« en: 09 de Abril de 2013, 03:05:20 »

 list      p=16F690           ; list directive to define processor
   #include <p16F690.inc>        ; processor specific variable definitions

   errorlevel  -302              ; suppress message 302 from list file


   __CONFIG   _CP_OFF & _CPD_OFF & _BOR_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _FCMEN_OFF & _IESO_OFF


; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See data sheet for additional information on configuration word settings.



;***** VARIABLE DEFINITIONS (examples)

; example of using Shared Uninitialized Data Section
INT_VAR      UDATA   0x30   
rOC         RES     1      ; variable used for context saving
rOD         RES     1      ; variable used for context saving
r13         RES      1      ; lugar de almacenaje del retardo
e         equ      1h      ;el pin RA1
rs         equ      2h      ;el pin RA2
r         equ      1h      ;almacena en el mismo registro
w         equ      0h      ;almacena en el acumulador

;**********************************************************************
RESET_VECTOR   CODE   0x000      ; processor reset vector
      goto    main              ; go to beginning of program

      CODE 0x05


;*****************Bloque de control y retado*****************************
;*************En este bloque esta la subrutina que crea un retardo***********
;************** al enviar comandos o datos al LCD****************************
;***************SUBRUTINA DE RETARDO*************************************
retardo
      movlw      0xFF
      movwf      r13            ;contador de retadrdo
decre   decfsz      r13,r         ;genera un retardo de aproximadamente
      goto      decre         ;3*256 microsegundos.
      retlw      0
;******ENVIO DE CONTROLES O DATOS*************************************
;****Para el envio de un comando*******************************************
;**rs=0**********************************************************
;**R/W=0****************************************************
;**e=1**********************************************
;****Para el envio de un dato***********************************************
;**rs=1*********************************************
control
      bcf         PORTA,rs      ;se prepara para enviar se?ales de control
      goto      dato2         ;va a enviar el comando
dato   bsf         PORTA,rs      ;se prepara para enviar un dato
dato2   bsf         PORTA,e         ;va a enviar lo que se haya desidido
                           ;habilita
      movwf      PORTC
      call      retardo
      call      retardo
      call      retardo
      bcf         PORTA,e         ;deshabilita
      call      retardo
      retlw      0
;*****************************************************************************   

main
;Inicializaci?n de los puertos, recuerde que los bits PA1 y PA2 se utilizaran para******
;las se?ales de control ?e? y ?rs?respectivamentes por lo que deben ser *****************
;programados como salidas****************************************************************
;***********Inicializaci?n puerto A, puesta en Cero del puerto*********
      BCF      STATUS,RP0
      BCF      STATUS,RP1
      CLRF   PORTA
      BSF      STATUS,RP1
      CLRF   ANSEL
      BCF      STATUS,RP1
      BSF      STATUS,RP0
      CLRF   TRISA
      BCF      STATUS,RP0
      clrf   PORTA
;********************************************************************
;************************INICIALIZA PUERTO C*****************************
      BCF      STATUS,RP0      ;Cambia al banco 0
      BCF      STATUS,RP1
      CLRF   PORTC         ;Inicializa el puerto C
;***************************************************************************************   
      BSF      STATUS,RP1      ;Cambia el banco 2 para poner los purtos como digitales
      CLRF   ANSEL         ;Digital I/O
      CLRF   ANSELH
;***************************************************************************************
      BCF      STATUS,RP1      ;Ahora se cambia al banco 1 para programar a TRISC
      BSF      STATUS,RP0
      MOVLW   0x00
      MOVWF   TRISC         ;Todas en salida
;************************************************************************************
   
      BCF      STATUS,RP0      ;Se regresa al banco 0 para programar al puerto C
      BCF      STATUS,RP1
      CLRF   PORTC         ;esta instrucci?n se pudiera quitar, se dejo por seguridad
;******************************************************************************


   
;***********************PROGRAMA PRINCIPAL**********************************************
;inicializaci?n del LCD
      movlw      0x0F         ;DISPLAY ON/OFF CONTROL
      call      control   
      call      retardo      
      movlw      0x01         ;CLEAR DISPLAY
      call      control
      call      retardo
      movlw      0x06         ;ENTRY MODE SET
      call      control
      call      retardo
      movlw      0x34         ;FUNCTION SET
      call       control
      call      retardo

   
;************************MENSAJE*************************************
      movlw      " "
      call      dato
      call      retardo
      movlw      "R"            ;Mensaje
      call       dato
      call      retardo      
      movlw      "I"            ;Mensaje
      call       dato
      call      retardo
      movlw      "C"            ;Mensaje
      call       dato
      call      retardo      
      movlw      "A"            ;Mensaje
      call       dato
      call      retardo      
      movlw      "R"            ;Mensaje
      call       dato
      call      retardo      
      movlw      "D"            ;Mensaje
      call       dato
      call      retardo      
      movlw      "O"            ;Mensaje
      call       dato
      call      retardo      
      movlw      " "            ;Mensaje
      call       dato
      call      retardo      
      movlw      "F"            ;Mensaje
      call       dato
      call      retardo      
      movlw      "E"            ;Mensaje
      call       dato
      call      retardo
      movlw      "R"            ;Mensaje
      call       dato
      call      retardo
      movlw      "R"            ;Mensaje
      call       dato
      call      retardo
      movlw      "E"            ;Mensaje
      call       dato
      call      retardo
      movlw      "R"            ;Mensaje
      call       dato
      call      retardo
      movlw      " "            ;Mensaje
      call       dato
      call      retardo
   
      


      END                       ; directive 'end of program'


Este es el programa que he utilizado pero no puedo poner que se vea la segunda linea del LCD, e intentado cambiar el lugar donde se guardan los datos o configurar otra rutina de control pero no he podido, si me pudieran ayudar, gracias.

Desconectado solapower

  • Colaborador
  • PIC16
  • *****
  • Mensajes: 209
Re: LCD 162JHD y PIC 16F690 no se ve la segunda linea
« Respuesta #1 en: 09 de Abril de 2013, 05:46:22 »
El mensaje que mandas al LCD tiene 16 caracteres , ese display es de 8 caracteres por dos líneas o de 16 x 2 ?
En cualquiera de los dos casos el ordinal de la direccion de memoria de inicio de cada linea no es consecutiva al final de la anterior.
Por ejemplo en un LCD 8x2 seria 00 y la ultima de 1ª fila 07 ,la 1ª de la fila 2 seria 40 (en hexadecimal todos).
Luego deberías partir el mensaje en dos mensajes y antes de mandar el segundo mandar el caracter de control de desplazamiento a la 2ª linea.

Mira de encontrar el datasheet de ese LCD
Saludos