Thank you Melanie. I got it to work, check it out:
DEFINE LCD_LINES 4
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1
DEFINE OSC 4 '10 MHz clock
Pause 5000
ADCON1 = 7 ' Set PORTA and PORTE to digital
' Low PORTE.2 ' LCD R/W line low (W)
TRISD = 0 ' Set PORTD (LEDs) to all output
' PORTD = 0 ' All LEDs off
INTCON2.7 = 0 ' Enable internal pullups on PORTB
TRISB=%11110000 ' =1 makes B port input and =0 makes B port output
PORTB = 0 ' PORTB lines low to read buttons
loop: LCDOut $fe, 1 ' Clear screen
Pause 1000 ' Wait .5 second
LCDOut $fe, $80, "Line 1" ' Display "Line 1"
Pause 1000
LCDOut $fe, $c0, "Line 2" ' Move to line 2 and display "Line 2"
Pause 1000
LCDOut $fe, $94, "Line 3" ' Move to line 3 and display "Line 3"
Pause 1000
LCDOut $fe, $D4, "Line 4" ' Move to line 4 and display "Line 4"
Pause 1000 ' Wait .5 second
LCDOut $fe, 1
GoTo loop ' Do it forever
End
I had to reduce the speed from 40Mhz to 4Mhz, add a 5 second boot pause, and then a 1 second pause after each LCDOUT statement. It's awful but it works, I guess the PIC18F is too fast for the HD44780 chip set.




Bookmarks