Hi,
My test board is up again.
I made a simple C program using Jack Botner's KTM library and sniffed the SI pin with oscilloscope:
[code:1:05e7a793cf]"A" = 0x20, 0x14, 0xF6, 0xD7, 0xD7,
"B" = 0x20, 0x14, 0xF6, 0xD4, 0xDF.
"AB" = 0x20, 0x14, 0xF4, 0xD4, 0xDF, 0xD7, 0xD7[/code:1:05e7a793cf]
With your slightly modified code the LCD works from Bascom to:
[code:1:05e7a793cf]Lcd_cd = 1 'CD line to command
Lcd_cs = 0 'CS line to select
Dat = &H20 'Clear data and pointer
Shiftout Lcd_si , Lcd_sck , Dat , 0
Call Wait_for_busy ' Wait to clear busy pin
Dat = &H14 'Turn off segment decoder
Shiftout Lcd_si , Lcd_sck , Dat , 0
Call Wait_for_busy
Ucbyte = &H77 'A or a if you do Ucbyte = Ucbyte -32
Tmp = Ucbyte And &H0F
Ucbuffer(2) = &HD0 Or Tmp
Shift Ucbyte , Right , 4
Ucbuffer(1) = &HD0 Or Ucbyte
Shiftout Lcd_si , Lcd_sck , Ucbuffer(1) , 0
Call Wait_for_busy
Shiftout Lcd_si , Lcd_sck , Ucbuffer(2) , 0
Call Wait_for_busy
Lcd_cs = 1 'Chip select off
[/code:1:05e7a793cf]
Now I understand what he is doing. From datasheet:
[quote:05e7a793cf]1.3.12 WRITE DATA MEMORY
[b:05e7a793cf][1 1 0 1 [color=red:05e7a793cf]D3 D2 D1 D0[/color:05e7a793cf]][/b:05e7a793cf]
This command stores the immediate data D3-D0 in the data memory addressed by the data pointer, incrementing
by (+1) the contents of the data pointer.[/quote:05e7a793cf]
So, you have to split the data byte into two 4-bit words and combine them with 1101 4-bit word into two bytes. This must be done in command mode (CD=1).
Btw, while comparing things on the scope, I've noticed that Bascom code is much faster while transfering data to LCD. He used 500usec delay while Bascom delay is 1.84usec. That's 431kHz vs. 1kHz bus speed.
br, Z
↧