Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

jhd161 lcd problem

Status
Not open for further replies.

lipschutz

Member
hi

i am trying to experiment with jhd161 lcd module using pic16f84a. i guess my code is correct as per mplab simulation. but can not display the desired characters on the screen. the right most eight square are displayed invariably. i also tried to test the lcd module by manual inputs. yet the same result is seen.

could you please suggest anything else to test the lcd. i attached my code here.
 

Attachments

  • LCD_84.ASM
    7.6 KB · Views: 128
the program is written to run on a pic16f84a which has no adc therefore no ansel. so all the ports RA pins are set as outputs. but do you think this is the thing that is causing problem?
 
Sorry.. I missed the bit where the pic16f84a is initialized...

Ok.. Init was slighty wrong... And you can't use the cursor function like that..

I rem'ed out the cursor function and corrected the init stage

Code:
;                  processor 16F88
;                 include <p16f88.inc>
;                 __CONFIG    _CONFIG1,  _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
;                 __CONFIG    _CONFIG2,  _IESO_OFF & _FCMEN_OFF
;
                  processor 16f84a
                  include<p16f84a.inc>
                  __config  _RC_OSC & _WDT_OFF & _PWRTE_ON
;
;SPECIFY REGISTER
;
counter_l EQU     20H
counter_s EQU     21H
temp      EQU     22H
porta     EQU     05h
portb     EQU     06h
RS        EQU     0h
RW        EQU     1h
E         EQU     2h
;PROGRAM
                org 00h
SETPORT         movlw     b'00000000'  ;
                tris      porta        ;
;RA0,1,2 are RS, RW and E respectively of lcd control 
;lines, RA4 is the analog input for AD converter
;
                movlw     b'00000000'  ;
                tris      portb        ;
;all of the 8 pins of portb are configured as outputs.
;Only the higher nibble will be used to send data 
;and command to the lcd module
; 
                bcf       porta,E      ;
;setting E to high restrics any sort of write operation
;from the mcu to lcd module
;          
initio          movlw     14h          ;
                movwf     temp         ;
loop            call      delay_1ms    ;
                decfsz    temp,F       ;
                goto      loop         ;
;A 20ms delay will give the lcd module enough time to 
;stabilize itself on power up 
;
                bcf       porta,RS     ;
                bcf       porta,RW     ;
                movlw     30h          ;
                movwf     portb        ;
                call      enab_lcd     ;
;the above segment sends the command
;RS RW DB7 DB6 DB5 DB4=000011 as required by the module
;ref:HD44780 datasheet 4-bit mode
                movlw     05h          ;
                movwf     temp         ;
five_ms         call      delay_1ms    ;
                decfsz    temp,F       ;
                goto      five_ms      ;
;5ms delay ref:HD44780 datasheet 4-bit mode
;
               ; bcf       porta,RS     ;
               ; bcf       porta,RW     ;
                movlw     30h          ;
                movwf     portb        ;
                call      enab_lcd     ;
;RS RW DB7 DB6 DB5 DB4=000011 as required by the module
;ref:HD44780 datasheet 4-bit mode
;                
                movlw     46h          ;
                movwf     temp         ;
delay_200us     decfsz    temp,F       ;
                goto      delay_200us  ;
;200us delay ref:HD44780 datasheet 4-bit mode
;
               ; bcf       porta,RS     ;
               ; bcf       porta,RW     ;
                movlw     30h          ;
                movwf     portb        ;
                call      enab_lcd     ;
;again the same bit sequence is sent as before
;i.e 000011
;
fucntion_set    bcf       porta,RS     ;               
                bcf       porta,RW     ;
                movlw     20h          ;
                movwf     portb        ;
                call      enab_lcd     ; 
;DB4 is cleared to select 4-bit mode
;from now on every byte is sent in two nibbles and the 
;the higher nibble is sent first
;
               ; bcf       porta,RS     ;
               ; bcf       porta,RW     ;
                movlw     20h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                movlw     00h          ;
                movwf     portb        ;
                call      enab_lcd     ;
;the function set command is sent again. the upper nibble 
;being the same as before but the lower nibble specifying 
;1-line and 5*7 pixel format i.e N=0 F=0 
;ref:HD44780 datasheet 
;
                movlw     20h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                movlw     80h          ;
                movwf     portb        ;
                call      enab_lcd     ;  
;display off command 00001000 ref:HD44780 datasheet
                movlw     00h          ;
                movwf     portb        ;
                call      enab_lcd     ;  
                movlw     60h          ;
                movwf     portb        ;
                call      enab_lcd     ;
;display on command 00000001 ref:HD44780 datasheet                              
                movlw     00h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                movlw     0C0h          ;
                movwf     portb        ;                
                call      enab_lcd     ;
;entry mode set command 00000110. I/D=1 making the cursor
;to shift to the right while S=0 does not permit the 
;entire display to shift right or left
;
;END OF INITIALIZATION
;
;*****************DEMO_CODE*****************
;
                bsf       porta,RS     ;
                bcf       porta,RW     ;
                movlw     30h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                movlw     50h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                ;call      CURSOR_SHIFT ;
;writes 5 on the lcd screen                
                movlw     30h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                movlw     70h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                ;call      CURSOR_SHIFT ;
;writes 7 on the lcd screen
                movlw     70h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                movlw     00h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                ;call      CURSOR_SHIFT ;
;writes p on the lcd screen 
                movlw     70h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                movlw     00h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                ;call      CURSOR_SHIFT ;
;writes p on the lcd screen
                movlw     60h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                movlw     20h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                ;call      CURSOR_SHIFT ;
FIN             goto      FIN          ;
;writes b on the lcd screen
;CURSOR SHIFT COMMAND SUBROUTINE
CURSOR_SHIFT     bcf       porta,RW     ;
                bcf       porta,RS     ;
                movlw     10h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                movlw     40h          ;
                movwf     portb        ;
                call      enab_lcd     ;
                return                 ;
;********************DEMO_CODE_ENDS*************
;SUBROUTINES
;
enab_lcd        bsf       porta,E      ;
                nop                    ;
                bcf       porta,E      ;
                nop                    ;
               return                  ;     
;data is transferred when E goes from high to low
;
delay_1ms       movlw     0ffh         ;
                movwf     counter_s    ;
point           nop                    ;
                decfsz    counter_s,F  ;
                goto      point        ;
                return                 ;
                END
 
so kind of you sir, i was a bit confused about that 'cursor shift' thing when i wrote the program. as you understand i am trying this lcd module for the first time and hence misinterpreted the spec sheet.

i am going to try this right now.

thanks.
 
hi,

still the same eight squire appeared on the screen. all unused output pins are grounded through a resistor. a 3.3k resistor and .1uf capacitor is used as the rc oscillator.
Vdd is bypassed by a 1uf capacitor. unsused pins of lcd module are left open. do you think anything is missing? or i should go back to code to make sure if everything okay?
 
hi

i went back to datasheet and found that i didn't implement sufficient amount of delay after each instruction. so those delays are incorporated and the problem is solved.

thanks.
 
Status
Not open for further replies.

Latest threads

Back
Top