My LCD code is not working...


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2008
    Posts
    22

    Default My LCD code is not working...

    Hi,

    I am using CDM16216b LCD to interface with 16f72.I am trying to display characters on lcd,but i didnt get anything on LCD.

    Please kindly reply me,where i am going wrong.

    Code:
    list    p=16f72   		        ;PIC16f72 is the target processor
    	INCLUDE "P16f72.INC" 
    ;------------------------------------------------------------------------------------
    ; PORTA control bits
    
    
    	__CONFIG _PWRTE_ON & _XT_OSC & _WDT_OFF   ;  configuration switches
    #DEFINE LCD_RS 	PORTA, 0            ;  RA0 is RS line of LCD
    #DEFINE LCD_E  	PORTA, 1            ;  RA1 is E line of LCD
                                        ;  RC0-RC3 are D4-D7 of LCD
    Temp	equ		0x20
    delay1	equ		0x21
    
    	org	0x00
    	goto start
    
    	                          
    ;------------------------------------------------------------------------------------
    start
    		bsf 	STATUS, RP0 		; Bank1 
    		errorlevel 1,-302      ; Don't warn me about bank 1
    
    		movlw 	b'00000000'			; Defining input and output pins 
    		movwf 	TRISA 				; Writing to TRISA register 
    		movlw 	b'00000000'			; Defining input and output pins 
    		movwf	TRISB 				; Writing to TRISB register 1-input,0-output
    		movlw	b'00000000'
    		movwf	TRISC
    		movlw   b'10000110'			; TMR0,prescaler-128
    		movwf   OPTION_REG
    		movlw	0x07
    		movwf	ADCON1
    		bcf 	STATUS, RP0 		; Bank0 
    		clrf 	PORTA				; potra,portb initially set to low
    		clrf	PORTB
    		clrf	PORTC
    		
    
    		
    		call	lcd_init
    		bsf		PORTA,5				; Buzzer
    		call	delay_0.5s
    		bcf		PORTA,5
    
    		call	disp_main
    		movlw	0xC1
    		call    disp_cmd
    		btfsc	PORTB,4				;UPS RDY
    		call	disp_ups
    		
    
    lcd_init
    		
      			movlw  	0x28            ;  4 bit, 2 Line, 5x7 font
      			call   	disp_cmd
    			call	delay
      		;	movlw  	0x10            ;  display shift off
     		;	call   	disp_cmd
    		;	call	delay
    			movlw  	0x0E            ;  increment cursor
      			call   	disp_cmd
    			call	delay
     			movlw  	0x01            ;  Clear the Display RAM
     			call   	disp_cmd
      			call   	delay           ;  Note, Can take up to 4.1 msecs
      		
    			movlw  	0x06            ;  move the cursor to begining
      			call   	disp_cmd
    			call	delay
      		;	movlw 	0x0C            ;  display on cursor off
      		;	call  	disp_cmd
    		;	call	delay
      			return
    delay
    		movlw	d'236'			;2.5ms delay
    		movwf	TMR0
    loop1	btfss	INTCON,2
    		goto	loop1	
    		clrf	INTCON		        ; if overflow occur,clear INTCON
    		return
    d
    ;------------------------------------------------------------------------------------
    ;Display command for 4 bit LCD
    
    disp_cmd                            ;  Send the Instruction to the LCD
     			 movwf	Temp            ;  Save the Temporary Value
     			 swapf  Temp, w         ;  Send the High Nybble
      			 bcf    LCD_RS          ;  RS = 0
     			 call   nibbleout
     			 movf   Temp, w         ;  Send the Low Nybble
     			 bcf    LCD_RS
     			 call   nibbleout
     			 return
    ;------------------------------------------------------------------------------------
    ;sending ASCII character to LCD
    disp_write
      		;	addlw 	'0'             ;  Send nbr as ASCII character                      			  ;  Send the Character to the LCD
      			movwf  Temp             ;  Save the Temporary Value
      			swapf  Temp, w          ;  the High Nybble
      			bsf    LCD_RS           ;  RS = 1
      			call   nibbleout
      			movf   Temp, w          ;  Send the Low Nybble
      			bsf    LCD_RS
      			call   nibbleout
      			return
    ;------------------------------------------------------------------------------------ 
    ;sending lower and upper nibble
    nibbleout                           ;  Send a nibble to the LCD
     			 movwf  PORTC
      			 bsf	LCD_E
    			call	delay
     			 bcf	LCD_E
     			 nop
    			 nop
     			 return
    
    disp_main
    	  
    	  	
           movlw 	'M'                 ; output 'MAIN'
           call 	disp_write
           movlw 	'A'
           call 	disp_write
           movlw 	'I'
           call 	disp_write
           movlw 	'N'
           call 	disp_write
    
           movlw 	' '
           call 	disp_write
           movlw 	'N'
           call 	disp_write
           movlw 	'O'
           call 	disp_write
           movlw 	'R'               
           call 	disp_write
      
    	   return
    
    	end

  2. #2
    Join Date
    Mar 2006
    Location
    Hyderabad (India)
    Posts
    123


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by kvrajasekar View Post
    Hi,

    I am using CDM16216b LCD to interface with 16f72.I am trying to display characters on lcd,but i didnt get anything on LCD.

    Please kindly reply me,where i am going wrong.

    Code:
    list    p=16f72   		        ;PIC16f72 is the target processor
    	INCLUDE "P16f72.INC" 
    ;------------------------------------------------------------------------------------
    ; PORTA control bits
    
    
    	__CONFIG _PWRTE_ON & _XT_OSC & _WDT_OFF   ;  configuration switches
    #DEFINE LCD_RS 	PORTA, 0            ;  RA0 is RS line of LCD
    #DEFINE LCD_E  	PORTA, 1            ;  RA1 is E line of LCD
                                        ;  RC0-RC3 are D4-D7 of LCD
    Temp	equ		0x20
    delay1	equ		0x21
    
    	org	0x00
    	goto start
    
    	                          
    ;------------------------------------------------------------------------------------
    start
    		bsf 	STATUS, RP0 		; Bank1 
    		errorlevel 1,-302      ; Don't warn me about bank 1
    
    		movlw 	b'00000000'			; Defining input and output pins 
    		movwf 	TRISA 				; Writing to TRISA register 
    		movlw 	b'00000000'			; Defining input and output pins 
    		movwf	TRISB 				; Writing to TRISB register 1-input,0-output
    		movlw	b'00000000'
    		movwf	TRISC
    		movlw   b'10000110'			; TMR0,prescaler-128
    		movwf   OPTION_REG
    		movlw	0x07
    		movwf	ADCON1
    		bcf 	STATUS, RP0 		; Bank0 
    		clrf 	PORTA				; potra,portb initially set to low
    		clrf	PORTB
    		clrf	PORTC
    		
    
    		
    		call	lcd_init
    		bsf		PORTA,5				; Buzzer
    		call	delay_0.5s
    		bcf		PORTA,5
    
    		call	disp_main
    		movlw	0xC1
    		call    disp_cmd
    		btfsc	PORTB,4				;UPS RDY
    		call	disp_ups
    		
    
    lcd_init
    		
      			movlw  	0x28            ;  4 bit, 2 Line, 5x7 font
      			call   	disp_cmd
    			call	delay
      		;	movlw  	0x10            ;  display shift off
     		;	call   	disp_cmd
    		;	call	delay
    			movlw  	0x0E            ;  increment cursor
      			call   	disp_cmd
    			call	delay
     			movlw  	0x01            ;  Clear the Display RAM
     			call   	disp_cmd
      			call   	delay           ;  Note, Can take up to 4.1 msecs
      		
    			movlw  	0x06            ;  move the cursor to begining
      			call   	disp_cmd
    			call	delay
      		;	movlw 	0x0C            ;  display on cursor off
      		;	call  	disp_cmd
    		;	call	delay
      			return
    delay
    		movlw	d'236'			;2.5ms delay
    		movwf	TMR0
    loop1	btfss	INTCON,2
    		goto	loop1	
    		clrf	INTCON		        ; if overflow occur,clear INTCON
    		return
    d
    ;------------------------------------------------------------------------------------
    ;Display command for 4 bit LCD
    
    disp_cmd                            ;  Send the Instruction to the LCD
     			 movwf	Temp            ;  Save the Temporary Value
     			 swapf  Temp, w         ;  Send the High Nybble
      			 bcf    LCD_RS          ;  RS = 0
     			 call   nibbleout
     			 movf   Temp, w         ;  Send the Low Nybble
     			 bcf    LCD_RS
     			 call   nibbleout
     			 return
    ;------------------------------------------------------------------------------------
    ;sending ASCII character to LCD
    disp_write
      		;	addlw 	'0'             ;  Send nbr as ASCII character                      			  ;  Send the Character to the LCD
      			movwf  Temp             ;  Save the Temporary Value
      			swapf  Temp, w          ;  the High Nybble
      			bsf    LCD_RS           ;  RS = 1
      			call   nibbleout
      			movf   Temp, w          ;  Send the Low Nybble
      			bsf    LCD_RS
      			call   nibbleout
      			return
    ;------------------------------------------------------------------------------------ 
    ;sending lower and upper nibble
    nibbleout                           ;  Send a nibble to the LCD
     			 movwf  PORTC
      			 bsf	LCD_E
    			call	delay
     			 bcf	LCD_E
     			 nop
    			 nop
     			 return
    
    disp_main
    	  
    	  	
           movlw 	'M'                 ; output 'MAIN'
           call 	disp_write
           movlw 	'A'
           call 	disp_write
           movlw 	'I'
           call 	disp_write
           movlw 	'N'
           call 	disp_write
    
           movlw 	' '
           call 	disp_write
           movlw 	'N'
           call 	disp_write
           movlw 	'O'
           call 	disp_write
           movlw 	'R'               
           call 	disp_write
      
    	   return
    
    	end
    there are some errors like missing subroutines !!

    Error[113] E:\KVRAJASEKHAR.ASM 42 : Symbol not previously defined (delay_0.5s)
    Error[113] E:\KVRAJASEKHAR.ASM 49 : Symbol not previously defined (disp_ups)
    Halting build on first failure as requested.


    The best i could suggest you is to read some routines from

    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk
    Regards,
    Sarma

  3. #3
    Join Date
    Aug 2008
    Posts
    22


    Did you find this post helpful? Yes | No

    Default

    Thanks for the response.

    I will do the changes and get you back.

Similar Threads

  1. 2x16 lcd not working with pic16f72
    By vu2iia in forum Schematics
    Replies: 4
    Last Post: - 16th February 2011, 14:59
  2. Newbie? Problem with LCD
    By lew247 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 7th December 2009, 19:48
  3. Simple LCD code not working!...WHY?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th November 2009, 19:48
  4. lcd not working
    By robertpeach in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 4th September 2009, 16:29
  5. Why doesn't my code for 18f452 work on 18f252?
    By senojlr in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 23rd December 2005, 02:42

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts