PDA

View Full Version : PIC to LCD interface



smooth
- 22nd November 2006, 02:29
Hi,
Anyone know how to interface a 4x20 DMC20481 backlite LCD to a PIC16F84?
I have tried almost everything... here is my code below, anyone see anything wrong?

org 0x00
goto start

start

movlw 0x00
tris PORTB

movlw 0x00
movwf PORTB

call Delay_5ms ; 5ms delay
call Delay_5ms
call Delay_5ms
call Delay_5ms

call LCD_Init

;------------------------------------------

LCD_Init

movlw 0x33 ; function set
movwf DispTemp
call LCD_Cmd

movlw 0x32 ; now in 4-bit mode
movwf DispTemp
call LCD_Cmd

movlw 0x28
movwf DispTemp ; sending 2 lines (2x40) 5x7 chars
call LCD_Cmd

movlw 0x08 ; display off
movwf DispTemp
call LCD_Cmd

movlw 0x01 ; cls
movwf DispTemp
call LCD_Cmd

movlw 0x06 ; entry mode shift lcd left
movwf DispTemp
call LCD_Cmd

movlw 0x0F ; display on, cursor/blink on
movwf DispTemp
call LCD_Cmd

call Delay_5ms
call Delay_5ms
call Delay_5ms

return
;------------------------------------------
LCD_Cmd
swapf DispTemp,0
andlw b'00001111'
movwf PORTB
bsf PORTB,7
call Delay_5ms
bcf PORTB,7
call Delay_5ms

movfw DispTemp
andlw b'00001111'
movwf PORTB
bsf PORTB,7
call Delay_5ms
bcf PORTB,7
call Delay_5ms

return

Archangel
- 22nd November 2006, 05:44
Hey Smooth,
that's all assembly, no picbasic pro. Some here can do it, not all. PBP forum, if you want to do it in basic check out the post listed or use the search button or check Picbasic manual page 95 and 96. Be alert to the fact that not all LCD modules are wired the same, as some switch power and ground pins acording to brand.




http://www.picbasic.co.uk/forum/showthread.php?p=19331
Regards
JS