Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

HD44780-based Character-LCD display PIC code

Status
Not open for further replies.

kemalkemal

Member level 1
Joined
Jan 27, 2013
Messages
38
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,672
Hi everyone
i'm trying to use HD44780-based Character-LCD(4line20character) . I found some material from some forums but couldn't make it.

If you check my software steps i appreciate it:

1st: I designate port configurations

Code:
	#define		RS			PORTA,0
	#define		RW			PORTA,1
	#define		E			PORTA,2
	#define		LCD_DATA	PORTB
	#define		LCD_CTRL	PORTA

Code:
movlw	b'00000111'
	banksel	ADCON1
	movwf	ADCON1
	banksel	TRISA
	clrf	TRISA		;RA0->RS
						;RA1->R/W
						;RA2->E
	banksel	TRISB
	clrf	TRISB

	banksel	LCD_CTRL
	clrf	LCD_CTRL	;

2nd:I make function set(8 bit interface and 2line(although my LCD is 4 line)
Code:
movlw		0X38
	banksel		LCD_DATA
	movwf		LCD_DATA
	banksel		LCD_CTRL
	bcf			RW
	bsf			RS
	bsf			E
	bcf			E
	call		delay_100u ; delay for 100us

3rd:I make -display off,clear display, entry mode set, display on- in sequence
Code:
movlw		b'00001011'			;disp off
	call		send_cmd
	movlw		b'00000001'			;clear disp
	call		send_cmd
	movlw		b'00000111'			;entry inc
	call		send_cmd
	movlw		b'00001111'			;disp on

Code:
send_cmd:
	banksel		temp
	movwf		temp
	call		busy_check
	banksel		temp
	movf		temp,w
	banksel		LCD_DATA
	movwf		LCD_DATA		
	banksel		LCD_CTRL
	bcf			RW
	bcf			RS
	bsf			E
	bcf			E
	call		delay_100u	
return

Code:
busy_check:
	banksel		TRISB
	movlw		b'11111111'
	movwf		TRISB
	banksel		LCD_CTRL
	bcf			RS
	bsf			RW
	bsf			E
	bcf			E
	banksel		LCD_DATA
	movf		LCD_DATA,w
	banksel		temp_busy
	movwf		temp_busy
	btfsc		temp_busy,7
	goto		busy_check
	banksel		LCD_CTRL
	bcf			RW
	banksel		TRISB
	clrf		TRISB
return

4th:send character-L- to LCD

Code:
	movlw		b'01001100'
	call		        send_lcd

Code:
send_lcd:
	banksel		temp
	movwf		temp
	call		busy_check
	banksel		temp
	movf		temp,w
	banksel		LCD_DATA
	movwf		LCD_DATA
	banksel		LCD_CTRL
	bcf			RW
	bsf			RS
	bsf			E
	bcf			E
	call		delay_100u	
return

But it didn't work.:shock:
 

Read attached pdf carefuly! I had same problems but then I read these two documents and it worked for me!
 

Attachments

  • lcd1.pdf
    263.6 KB · Views: 103
  • lcd2.pdf
    121.5 KB · Views: 108
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top