Hey all, I'm trying to write a program so I can use a LCM1602A lcd screen with a pic 16f688. Here are datasheets for both components:
lcd - http://www.vintagecomputercables.com...02A-FL-YBW.pdf
16f688 - http://ww1.microchip.com/downloads/e...Doc/41203B.pdf
I believe the lcd is a HD44780 equivalent...but I'm not 100% sure. I have everything wired correctly to the best of my knowledge, but all I'm seeing on the screen are 16 black boxes across the top line. I'm using this website as guidance.
http://embedded-lab.com/blog/?p=203
I cannot take credit for this code, but this is the code I am using (how do I post my codes in the nice scrolling box?). Thanks to everyone for your help.
Code:
LED var porta.2
TRISC.0 = 0 '(pin 10) Blue Lcd Data bit 4
TRISC.1 = 0 '(pin 9) White Lcd Data bit 5
TRISC.2 = 0 '(pin 8) Green Lcd Data bit 6
TRISC.3 = 0 '(pin 7) Orange Lcd Data bit 7
TRISC.4 = 0 '(pin 6) Orange/Black Lcd Register select
TRISC.5 = 0 '(pin 5) Blue/White Lcd Enable bit
' PIC Hardware Definitions (ie Pin-Out & Port Assignments)
ANSEL = 0 ' all pins are digital
CMCON0 = 7 ' turn off comparators
ADCON0 = 0
ADCON1 = 0
'pin connection from pic chip to LCD
'1 VDD 5V
'2 OSC1 Crystal (internal 4MHz)
'3 OSC2 Crystal (internal 4MHZ)
'4 MCLR Pulled up
'5 RC5 E LCD
'6 RC4 RS LCD
'7 RC3 DB7
'8 RC2 DB6
'9 RC1 DB5
'10 RC0 DB4
'11 RA2 LED pin
'12 RA1 NC
'13 RA0 NC
'14 VSS Ov
'Define LCD registers and bits
DEFINE OSC 4 'Internal oscillator 4MHz
DEFINE LCD_DREG PORTC 'Define PIC port used for LCD Data lines
DEFINE LCD_DBIT 0 'LCD Data Starting Bit = Bit 0 or 4
DEFINE LCD_EREG PORTC 'Define PIC port used for E line of LCD
DEFINE LCD_EBIT 5 'Define Port pin used for E connection
DEFINE LCD_RSREG PORTC 'Define PIC port used for RS line of LCD
DEFINE LCD_RSBIT 4 'Define Port pin used for RS connection
DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD
DEFINE LCD_LINES 2 'Define using a 2 line LCD
DEFINE LCD_COMMANDUS 2000 'Define delay time between sending LCD commands
DEFINE LCD_DATAUS 50 'Define delay time between data sent.
Pause 500 ' Wait for LCD to startup
loop:
high led
pause 200
low led
Lcdout $fe, 1 ' Clear LCD screen
Lcdout "Hello" ' Display Hello
Pause 500 ' Wait .5 second
Lcdout $fe, 1 ' Clear LCD screen
Lcdout "World" 'Display World
Pause 500 ' Wait .5 second
Goto loop ' Do it forever
Bookmarks