LCD have KS0066
Archiver
Posts: 46,084
Hello,
Dose any one has a program which demonstrates the basic functions of LCD
with built-in Samsung KS0066 controller.
Thank You
Mohamed Refky
_________________________________________________________________
The new MSN 8 is here: Try it free* for 2 months
http://join.msn.com/?page=dept/dialup
Dose any one has a program which demonstrates the basic functions of LCD
with built-in Samsung KS0066 controller.
Thank You
Mohamed Refky
_________________________________________________________________
The new MSN 8 is here: Try it free* for 2 months
http://join.msn.com/?page=dept/dialup
Comments
BASIC Stamps should work fine. I did a quick search (using Google) and found
docs for LCDs using that controller -- the instruction set looked just like
the HD44780.
-- Jon Williams
-- Parallax
In a message dated 1/5/2003 11:22:28 AM Central Standard Time,
refky@h... writes:
> Dose any one has a program which demonstrates the basic functions of LCD
> with built-in Samsung KS0066 controller.
[noparse][[/noparse]Non-text portions of this message have been removed]
by an example for the BS2p that has the lcd commands built-in...
'{$STAMP BS2}
'
' Interface to the Hitachi 44780 based LCD devices
' for Basic Stamp uControllers.
'
' Wiring; p4-p7 on the stamp to db4 to db7 on the 44780
' p1 to the enable (E) line on the 44780.
' pull this down to Vss with a 10k ohm resistor
' p2 to the R/W line on the 44780
' p3 to the RS line on the 44780
'
' db0-db3 on the 44780 to Vss to support 4bit mode
'
' Use a 10K pot across Vcc/Vss to connect Vee to
' control LCD contrast.
'
pulstime con 500 'pulsout time interval
'changes based on stamp
model
'see "pulsout" command for
'timing details.
'
' Some command constants based on the Hitachi 44780 spec
'
WakeUp con %00110000 'Wake up
FourBitMode con %00100000 'Set to 4 bit mode
OneLine5x8Font con %00100000 '1 line 5x8 font
OneLine5x10Font con %00100100 '1 line 5x10 fnt
TwoLine5x8Font con %00101000 '2 line 5x8
TwoLine5x10Font con %00101100 '2 line 5x10
DisplayOff con %00001000 'Display off
DisplayOn con %00001100 'Display on, no cursor
DisplayOnULCrsr con %00001110 'Display on, underline cursor
DisplayOnBLCrsr con %00001101 'Display on, blink cursor
IncCrsr con %00000110 'Auto-increment cursor no
display shift
IncCrsrShift con %00000111 'Auto-increment display.
shift display left
DecCrsr con %00000100 'Decrement cursor. No
display shift
DecCrsrShift con %00000101 'Decrement cursor with
display shift
ClearDisplay con %00000001 'clear display
HomeDisplay con %00000010 'Cursor to home
ScrollLeft con %00011000 'Scroll to left
ScrollRight con %00010100 'Scroll right
CrsrLeft con %00010000 'Cursor to left
CrsrRight con %00010100 'Cursoft right
MoveCrsr con %10000000 'Move cursor to position
MoveToCGRAM con %01000000 'Move to CGRAM position
e con 1 'enable
rw con 2 'read/write
rs con 3 'register select
'outb is data bus for lcd (p4-p7)
x var byte 'scratchpad var
cmd var byte 'command to sendcmd sub
ch var byte 'character to sendchr sub
temp var nib 'temp scratchpad
index var byte 'index to eeprom
'
' Some eeprom data to display
'
data "This is a test",255
Init:
dirl = %11111110 'p1-p7 outputs
low e 'put
low rw ' control lines
low rs ' in initial state
pause 500 'wait til vcc stable
gosub InitLCD 'initialize LCD
index = 0
Display:
read index,ch 'read data from eeprom
if ch = 255 then Terminate 'sentinal?
gosub sendchr 'send to lcd
index = index + 1 'increment eeprom addr
goto Display
Terminate:
stop
'
' Initialize LCD according to specifications for the HD44780
'
InitLCD:
for x=1 to 3 'spec said to do three times
outb = WakeUp>>4 'send wakeup call
pulsout e,pulstime 'send command
pause 5
next
outb = FourBitMode>>4 'go to 4 but mode
pulsout e,pulstime 'send it
pause 1
'
' Initialization command sequence...
'
cmd = FourBitMode
gosub sendcmd
cmd = TwoLine5x8Font
gosub sendcmd
cmd = DisplayOff
gosub sendcmd
cmd = DisplayOnBLCrsr
gosub sendcmd
cmd = IncCrsr
gosub sendcmd
cmd = ClearDisplay
gosub sendcmd
cmd = HomeDisplay
gosub sendcmd
return
'
' send character to ddram on lcd
'
sendchr:
gosub busychk 'wait til lcd not busy
outb = ch.highnib 'upper part first
high rs 'rs high
pulsout e,pulstime 'send it
low rs 'reset rs
gosub busychk 'wait again
outb = ch.lownib 'lower nibble
high rs 'rs high
pulsout e,pulstime 'send it
low rs 'reset rs
return
'
' Send command in the var "cmd" to the lcd
'
sendcmd:
gosub busychk 'wait til lcd not busy
outb = cmd.highnib 'upper cmd first
pulsout e,pulstime 'send it
gosub busychk 'wait again
outb = cmd.lownib 'lower nibble
pulsout e,pulstime 'send it
return
'
' waits til the lcd is no longer busy and then returns
' uses the var "temp"
'
busychk:
dirl = %00001110 'make lcd databus input
high rw 'were reading
busyloop:
high e 'enable
temp = inb 'get data from lcd
low e 'toggle back enable
pulsout e,pulstime 'because were in 4bit mode
(two reads of 4 bits)
temp = temp & $80 'mask all but busy flag (db7
from lcd)
if temp <> 0 then busyloop 'loop until not busy
low rw 'back to write
dirl = %11111110 'reset databus back to output
return
And here's a BS2p version...
'{$STAMP BS2p}
WakeUp CON %00110000 'Wake up
ForBitMode CON %00100000 'Set to 4 bit mode
OneLine5x8Font CON %00100000 '1 line 5x8 font
OneLine5x10Font CON %00100100 '1 line 5x10 fnt
TwoLine5x8Font CON %00101000 '2 line 5x8
TwoLine5x10Font CON %00101100 '2 line 5x10
DisplayOff CON %00001000 'Display off
DisplayOn CON %00001100 'Display on, no cursor
DisplayOnULCrsr CON %00001110 'Display on, underline cursor
DisplayOnBLCrsr CON %00001101 'Display on, blink cursor
IncCrsr CON %00000110 'Auto-increment cursor no
display shift
IncCrsrShift CON %00000111 'Auto-increment display.
shift display left
DecCrsr CON %00000100 'Decrement cursor. No
display shift
DecCrsrShift CON %00000101 'Decrement cursor with
display shift
ClearDisplay CON %00000001 'clear display
HomeDisplay CON %00000010 'Cursot to home
ScrollLeft CON %00011000 'Scroll to left
ScrollRight CON %00010100 'Scroll right
CrsrLeft CON %00010000 'Cursor to left
CrsrRight CON %00010100 'Cursoft right
MoveCrsr CON %10000000 'Move cursor to position
MoveToCGRAM CON %01000000 'Move to CGRAM position
result var word
btnWork var byte
Init:
pause 1000
gosub InitLCD
Start:
high 8
pause 1
rctime 8,1,result
lcdcmd 1,ClearDisplay
lcdout 1,MoveCrsr+0,[noparse][[/noparse]DEC result]
'sleep 1
nap 3
button 0,1,255,0,btnWork,1,doMessage
goto Start
doMessage:
lcdcmd 1,ClearDisplay
lcdout 1,MoveCrsr+0,[noparse][[/noparse]"Button"]
lcdout 1,MoveCrsr+64,[noparse][[/noparse]"Pressed"]
sleep 1
goto Start
InitLCD:
lcdcmd 1,WakeUp
pause 10
lcdcmd 1,WakeUp
pause 1
lcdcmd 1,WakeUp
pause 1
lcdcmd 1,ForBitMode
lcdcmd 1,TwoLine5x8Font
lcdcmd 1,DisplayOff
lcdcmd 1,DisplayOn
lcdcmd 1,IncCrsr
lcdcmd 1,ClearDisplay
return
--- In basicstamps@yahoogroups.com, jonwms@a... wrote:
> I believe that controller is HD44780-compatible; so LCD programs
you find for
> BASIC Stamps should work fine. I did a quick search (using
Google) and found
> docs for LCDs using that controller -- the instruction set looked
just like
> the HD44780.
>
> -- Jon Williams
> -- Parallax
>
> In a message dated 1/5/2003 11:22:28 AM Central Standard Time,
> refky@h... writes:
>
> > Dose any one has a program which demonstrates the basic
functions of LCD
> > with built-in Samsung KS0066 controller.
>
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]