Hello coders,
I'm stuck in a problem: I've connected a LC display with a 16F876A via a 74HC595 stack IC. But the display does'nt do what I want it to.
The cirquit is O.K., the communication to the stack works fine. And the communication to the display works also fine.
If I try to send the regular initialisation sequence, like there are code examples all over the net, it won't work. So what I did was sending a incrementing byte starting at zero. Code is something like this:

Code:
RS_state = 0

main:      ' 74HC595 : 5=6(E), 4=4(RS), 3=14(DB7), 2=13(DB6), 1=12(DB5), 0=11(DB4)

for char = 0 to 255
gosub tolcd

'pause 500
toggle led

next

goto main

' shiftout datapin,clockpin,msbfirst,[var1, var2]   ' MSBFIRST = 1

sendHalfnibble:
Tosend = char >> 4                          ' High Nibble only, needed for the initialisation routine, move Char 4 bits to the right
gosub sendtolcd  
return

ToLCD:
Tosend = char >> 4                           ' High Nibble, move Char 4 digits to the right
gosub sendtolcd     
tosend = char                                ' 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
'pause 250
 
tosend.5 = 1                                ' enable bit ON
shiftout datapin,clockpin,msbfirst,[tosend]   ' data to HC595
high latchpin                               ' sent to paralell buffer
low latchpin
'pause 250

tosend.5 = 0                                ' Enable OFF
shiftout datapin,clockpin,msbfirst,[tosend]   ' send data to HC595
high latchpin                               ' write to paralell
low latchpin
pause 500

return
As you see, the RS pin is always low, wich means there are only commands to the LCD.

What happens with this code is, that the LCD cursor is switching on and off, and moving around at some bytes, wich makes me sure that the cirquit works, but I don't know how to send the high and low nibbles correctly. Everything works, but I don't know why or how, wich gives me a headache.

The stack is connected like: Porta.0 -> clck, Porta.1 -> data, Porta.2 -> latch
porta.3 at the PIC is a LED for debug blinking stuff (to check if the code is still running)

the LCD is connected to the stack like described in the code example (first line)

I've connected a LED to every PIN of the LCD, so with some pauses I can see clearly the data sent to the LCD. This data seems to be O.K. too.

Well so much for that. Now my questions:

A byte within the PIC is bitwise like that: 76543210 wich means bit 7 is the first one, bit zero the last one. What about the nibbles? Are the bits 7654 the high nibble, or bits 3210?

Is it neccesary to send the data first with enable OFF, then with enable ON, then again with enable OFF?



THX for help, and pls excuse my bad english,
helloo