Hi all,

I use the code below, and it's my idea it will give me on my LCDisplay the letters "Camil" (and yes, that is my name)
All the first subroutines i just copied form http://home.iae.nl/users/pouweha/lcd/lcd2.shtml - it has to work.
From label start i did make anything myself.
I'm sure i did connect the LCD and the PIC right, and i am sure the contrast is OK.

I just think i don't understand how to use the subroutines.

What happens is the following: the backlight does work, but there isn't any character.

What's the problem - how do I solve it?

And: I'm dutch, and my english isn't very well - could you please try to make your sentences easy?? :)

Thanks for your help!

;**********************************************************************
;                                                                     *
;    Filename:	    LCDisplay test.asm                                *
;    Date:          17/7/2010                                         *
;    File Version:  v1.0                                              *
;                                                                     *
;    Author:        Camil Staps                                       *
;    Company:       none                                              *
;                                                                     * 
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files Required: P16F84A.INC                                      *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;**********************************************************************


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

	__CONFIG   _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;**********************************************************************
		ORG     0000h             ; processor reset vector
  		GOTO    start		      ; go to beginning of program
		ORG     0004h             ; interrupt vector location
		GOTO	start
		
;**********************************************************************
lcdinit		
			LCD_DATA		EQU		06h		;	PORTB
			LCD_DATA_TRIS	EQU		86h		;	TRISB
			LCD_CTRL		EQU		05h		;	PORTA
			LCD_TEMP		EQU		0x020	
			DELAY			EQU		0x023
			X_DELAY			EQU		0x024
			;	PORTA Control Bits
			LCD_E			EQU		02h		;	Enable
			LCD_RW			EQU		01h		;	Read/Write
			LCD_RS			EQU		00h		;	Register Select
			CLRF	LCD_CTRL		;	all RA on 0
			MOVLW	0x01E
			CALL	X_DELAY500
			MOVLW	0x038
			CALL	lcdputcmd
			MOVLW	0x000
			CALL	lcddmode		;	disp.off, curs.off, noblink
			CALL	lcdclear
			MOVLW	0x004
			CALL	lcddmode		;	disp.on, curs.off
			MOVLW	0x002
			CALL	lcdemode		;	auto-inc (shift-cursor)
			RETURN

;**********************************************************************
;Busy Flag
lcdbusy		BSF		03h,05h				;	bank 1
			MOVLW	0x0FF
			MOVWF	LCD_DATA_TRIS		;	PORTB input
			BCF		83h,05h				;	bank 0
			BCF		LCD_CTRL,LCD_RS		;	LCD Command Mode
			BSF		LCD_CTRL,LCD_RW		;	Setup busy flag
			BSF		LCD_CTRL,LCD_E		;	LCD Enable hoog
			MOVF	LCD_DATA,0
			BCF		LCD_CTRL,LCD_E		;	LCD Enable low
			ANDLW	0x080				;	check busy flag, high=busy
			BTFSS	03h,02h				;	Zero Flag
			GOTO	lcdbusy				;	still busy...
lcdnotbusy	BCF		LCD_CTRL,LCD_RW		
			BSF		03h,05h
			CLRF	LCD_DATA_TRIS		;	PORTB output
			BCF		83h,05h
			RETURN

;Clear Display
lcdclear	MOVLW	0x001
			CALL	lcdputcmd
			RETURN

;Cursor Home
lcdhome		MOVLW	0x002
			CALL	lcdputcmd
			RETURN

;Entry Mode
lcdemode	ANDLW	0x003
			IORLW	0x004
			CALL	lcdputcmd
			RETURN

;Display Mode
lcddmode	ANDLW	0x007
			IORLW	0x008
			CALL	lcdputcmd
			RETURN

;Set Character generator RAM address
lcdscga		ANDLW	0x03F
			IORLW	0x040
			CALL	lcdputcmd
			RETURN

;Set Display data RAM address
lcdsdda		IORLW	0x080
			CALL	lcdputcmd
			RETURN

;Get address counter contents
lcdgaddr	BSF		03h,05h
			MOVLW	0x0FF				;	PORTB input
			MOVWF	LCD_DATA_TRIS
			BCF		83h,05h
			BCF		LCD_CTRL,LCD_RS		;	command mode
			BSF		LCD_CTRL,LCD_RW		;	setup busy flag
			BSF		LCD_CTRL,LCD_E		;	Enable high
			MOVF	LCD_DATA,0			;	data to W register
			BCF		LCD_CTRL,LCD_E		;	Enable low
			ANDLW	0x07F
			BCF		LCD_CTRL,LCD_RW
			BSF		03h,05h
			CLRF	LCD_DATA_TRIS		;	PORTB output
			BCF		83h,05h
			RETURN

;Write Character
lcdputchar	MOVWF	LCD_TEMP			;	char is in W
			CALL	lcdbusy
			BCF		LCD_CTRL,LCD_RW		;	Read mode
			BSF		LCD_CTRL,LCD_RS		;	Data mode
			BSF		LCD_CTRL,LCD_E		;	Enable high
			MOVF	LCD_TEMP,0			;	char back to W
			MOVWF	LCD_DATA			;	data to LCD
			BCF		LCD_CTRL,LCD_E		;	Enable low
			RETURN

;Write Command
lcdputcmd	MOVWF	LCD_TEMP			;	Command is in W
			CALL	lcdbusy
			BCF		LCD_CTRL,LCD_RW		;	Read mode
			BCF		LCD_CTRL,LCD_RS		;	Command mode
			BSF		LCD_CTRL,LCD_E		;	Enable high
			MOVF	LCD_TEMP,0			;	char back to W
			MOVWF	LCD_DATA			;	command to LCD
			BCF		LCD_CTRL,LCD_E		;	Enable low
			RETURN

DELAY500	MOVLW	D'165'
			MOVWF	DELAY
DELAY500_LOOP
			DECFSZ	DELAY,1
			GOTO	DELAY500_LOOP
			RETURN

X_DELAY500	MOVWF	X_DELAY
X_DELAY500_LOOP
			CALL	DELAY500
			DECFSZ	X_DELAY,1
			GOTO	X_DELAY500_LOOP
			RETURN

;Here does my program start
start		CALL	lcdinit
			MOVLW	b'01000011'		;	C
			CALL	lcdputchar
			MOVLW	b'01100001'		;	a
			CALL	lcdputchar
			MOVLW	b'01101101'		;	m
			CALL	lcdputchar
			MOVLW	b'01101001'		;	i
			CALL	lcdputchar
			MOVLW	b'01101100'		;	l
			CALL	lcdputchar
			
loop		GOTO	loop
			
			






		END                     ; directive 'end of program'

First, are you sure you have an LCD character display using An HD44780x controller, and second, are you sure it is physically set up to run in 8bit/4bit mode? There is a massive amount of surplus displays being dumped on the market in various character widths and line densities that do the same job, but use different display driver chips. If you do not have an industry standard HD44780 display driver on you display, you will have to download the specs for the driver you have and the actual character display manufacturer. Even using the specs for the display driver, I have seen display manufacturers lock them into 4bit mode or 8bit mode. You need all this info to determine how to initialize your display, how your character lines are split and what the character DDRAM display addresses are and what control characters you need.

After that, you're good to go

Raymond

Hi all,

I use the code below, and it's my idea it will give me on my LCDisplay the letters "Camil" (and yes, that is my name)
All the first subroutines i just copied form http://home.iae.nl/users/pouweha/lcd/lcd2.shtml - it has to work.
From label start i did make anything myself.
I'm sure i did connect the LCD and the PIC right, and i am sure the contrast is OK.

I just think i don't understand how to use the subroutines.

What happens is the following: the backlight does work, but there isn't any character.

What's the problem - how do I solve it?

And: I'm dutch, and my english isn't very well - could you please try to make your sentences easy?? :)

Thanks for your help!

;**********************************************************************
;                                                                     *
;    Filename:	    LCDisplay test.asm                                *
;    Date:          17/7/2010                                         *
;    File Version:  v1.0                                              *
;                                                                     *
;    Author:        Camil Staps                                       *
;    Company:       none                                              *
;                                                                     * 
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files Required: P16F84A.INC                                      *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;**********************************************************************


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

	__CONFIG   _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;**********************************************************************
		ORG     0000h             ; processor reset vector
  		GOTO    start		      ; go to beginning of program
		ORG     0004h             ; interrupt vector location
		GOTO	start
		
;**********************************************************************
lcdinit		
			LCD_DATA		EQU		06h		;	PORTB
			LCD_DATA_TRIS	EQU		86h		;	TRISB
			LCD_CTRL		EQU		05h		;	PORTA
			LCD_TEMP		EQU		0x020	
			DELAY			EQU		0x023
			X_DELAY			EQU		0x024
			;	PORTA Control Bits
			LCD_E			EQU		02h		;	Enable
			LCD_RW			EQU		01h		;	Read/Write
			LCD_RS			EQU		00h		;	Register Select
			CLRF	LCD_CTRL		;	all RA on 0
			MOVLW	0x01E
			CALL	X_DELAY500
			MOVLW	0x038
			CALL	lcdputcmd
			MOVLW	0x000
			CALL	lcddmode		;	disp.off, curs.off, noblink
			CALL	lcdclear
			MOVLW	0x004
			CALL	lcddmode		;	disp.on, curs.off
			MOVLW	0x002
			CALL	lcdemode		;	auto-inc (shift-cursor)
			RETURN

;**********************************************************************
;Busy Flag
lcdbusy		BSF		03h,05h				;	bank 1
			MOVLW	0x0FF
			MOVWF	LCD_DATA_TRIS		;	PORTB input
			BCF		83h,05h				;	bank 0
			BCF		LCD_CTRL,LCD_RS		;	LCD Command Mode
			BSF		LCD_CTRL,LCD_RW		;	Setup busy flag
			BSF		LCD_CTRL,LCD_E		;	LCD Enable hoog
			MOVF	LCD_DATA,0
			BCF		LCD_CTRL,LCD_E		;	LCD Enable low
			ANDLW	0x080				;	check busy flag, high=busy
			BTFSS	03h,02h				;	Zero Flag
			GOTO	lcdbusy				;	still busy...
lcdnotbusy	BCF		LCD_CTRL,LCD_RW		
			BSF		03h,05h
			CLRF	LCD_DATA_TRIS		;	PORTB output
			BCF		83h,05h
			RETURN

;Clear Display
lcdclear	MOVLW	0x001
			CALL	lcdputcmd
			RETURN

;Cursor Home
lcdhome		MOVLW	0x002
			CALL	lcdputcmd
			RETURN

;Entry Mode
lcdemode	ANDLW	0x003
			IORLW	0x004
			CALL	lcdputcmd
			RETURN

;Display Mode
lcddmode	ANDLW	0x007
			IORLW	0x008
			CALL	lcdputcmd
			RETURN

;Set Character generator RAM address
lcdscga		ANDLW	0x03F
			IORLW	0x040
			CALL	lcdputcmd
			RETURN

;Set Display data RAM address
lcdsdda		IORLW	0x080
			CALL	lcdputcmd
			RETURN

;Get address counter contents
lcdgaddr	BSF		03h,05h
			MOVLW	0x0FF				;	PORTB input
			MOVWF	LCD_DATA_TRIS
			BCF		83h,05h
			BCF		LCD_CTRL,LCD_RS		;	command mode
			BSF		LCD_CTRL,LCD_RW		;	setup busy flag
			BSF		LCD_CTRL,LCD_E		;	Enable high
			MOVF	LCD_DATA,0			;	data to W register
			BCF		LCD_CTRL,LCD_E		;	Enable low
			ANDLW	0x07F
			BCF		LCD_CTRL,LCD_RW
			BSF		03h,05h
			CLRF	LCD_DATA_TRIS		;	PORTB output
			BCF		83h,05h
			RETURN

;Write Character
lcdputchar	MOVWF	LCD_TEMP			;	char is in W
			CALL	lcdbusy
			BCF		LCD_CTRL,LCD_RW		;	Read mode
			BSF		LCD_CTRL,LCD_RS		;	Data mode
			BSF		LCD_CTRL,LCD_E		;	Enable high
			MOVF	LCD_TEMP,0			;	char back to W
			MOVWF	LCD_DATA			;	data to LCD
			BCF		LCD_CTRL,LCD_E		;	Enable low
			RETURN

;Write Command
lcdputcmd	MOVWF	LCD_TEMP			;	Command is in W
			CALL	lcdbusy
			BCF		LCD_CTRL,LCD_RW		;	Read mode
			BCF		LCD_CTRL,LCD_RS		;	Command mode
			BSF		LCD_CTRL,LCD_E		;	Enable high
			MOVF	LCD_TEMP,0			;	char back to W
			MOVWF	LCD_DATA			;	command to LCD
			BCF		LCD_CTRL,LCD_E		;	Enable low
			RETURN

DELAY500	MOVLW	D'165'
			MOVWF	DELAY
DELAY500_LOOP
			DECFSZ	DELAY,1
			GOTO	DELAY500_LOOP
			RETURN

X_DELAY500	MOVWF	X_DELAY
X_DELAY500_LOOP
			CALL	DELAY500
			DECFSZ	X_DELAY,1
			GOTO	X_DELAY500_LOOP
			RETURN

;Here does my program start
start		CALL	lcdinit
			MOVLW	b'01000011'		;	C
			CALL	lcdputchar
			MOVLW	b'01100001'		;	a
			CALL	lcdputchar
			MOVLW	b'01101101'		;	m
			CALL	lcdputchar
			MOVLW	b'01101001'		;	i
			CALL	lcdputchar
			MOVLW	b'01101100'		;	l
			CALL	lcdputchar
			
loop		GOTO	loop
			
			






		END                     ; directive 'end of program'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.