You were getting close, but it did need a bit more.
The pins I used are probably different than yours.
Code:
INCLUDE "ModeDefs.bas"
INCLUDE "AllDigital.pbp"
datapin VAR PORTB.1
clockpin VAR PORTB.0
latchpin VAR PORTB.2
led VAR PORTA.5
Tosend VAR BYTE
char VAR BYTE
RS_state VAR BIT
GOSUB InitLCD
main: ' 74HC595 : 5=6(E), 4=4(RS), 3=14(DB7), 2=13(DB6), 1=12(DB5), 0=11(DB4)
for char = 32 to 90
gosub SendData
pause 500
toggle led
next char
goto main
;----[Initialize LCD]----------------------------------------------------------
InitLCD:
RS_state = 0
char = $30
GOSUB sendHalfnibble
PAUSE 6
GOSUB sendHalfnibble
PAUSE 1
GOSUB sendHalfnibble
PAUSE 1
char = $20 ; Start 4-bit mode
GOSUB sendHalfnibble
char = $28 ; Function Set, 4-bit, 2-line, 5x7
GOSUB SendCommand
char = $0C ; Display ON
GOSUB SendCommand
char = $01 ; Clear Screen
GOSUB SendCommand
char = $06 ; Entry Mode
GOSUB SendCommand
RETURN
;----[Send the Upper nibble to the LCD]----------------------------------------
sendHalfnibble:
Tosend = char >> 4 ' High Nibble only, needed for the initialisation routine, move Char 4 bits to the right
GOTO sendtolcd
return
SendCommand:
RS_state = 0
GOSUB ToLCD
PAUSE 2
RETURN
SendData:
RS_state = 1
ToLCD:
Tosend = char >> 4 ' High Nibble, move Char 4 digits to the right
gosub sendtolcd
tosend = char & $0F ' Low nibble = char, the other bit's won't matter
gosub sendtolcd
return
SendToLCD:
tosend.4 = RS_state ' RS state setzen "0" = command für LCD, "1" = Zeichen an LCD
tosend.5 = 0 ' Enable Bit OFF
shiftout datapin,clockpin,msbfirst,[tosend] ' send data to HC595
high latchpin ' write into paralell buffer
low latchpin
tosend.5 = 1 ' enable bit ON
shiftout datapin,clockpin,msbfirst,[tosend] ' data to HC595
high latchpin ' sent to paralell buffer
low latchpin
tosend.5 = 0 ' Enable OFF
shiftout datapin,clockpin,msbfirst,[tosend] ' send data to HC595
high latchpin ' write to paralell
low latchpin
pauseus 50
return
Attachment 4867