SX 칩 4비트 LCD 소스
LCD Hardware Interface and Assembler Source.
문자 표시용 LCD 핀의 기능과 설명
핀 기능 설명
1 GND Ground
2 +5 + 5 V Power
3 C Contrast voltage
4 RS Reg. Select
5 R/W Read/Write
6 E Enable
7 DB0 Data Bit 0
8 DB1 Data Bit 1
9 DB2 Data Bit 2
10 DB3 Data Bit 1
11 DB4 Data Bit 4
12 DB5 Data Bit 5
13 DB6 Data Bit 6
14 DB7 Data Bit 7
Some LCDs have 14-pin male single inline package (SIP) headers,
and they can be plugged directly into a breadboard.
Other LCDs have these pins arranged
with a piece of ribbon cable that ends in a dual-row header.
This isn't very handy for breadboarding. In this case,
jumper wires can be used to connect the header pins/sockets to the breadboard.
Figure 1.5 shows a connection diagram for operating a 14 pin LCD in 4-bit mode.
Hitachi’s data sheet shows a signal sequence that can be sent to the LCD to reset it
and force it into 4-bit mode.
Once in 4-bit mode, RS can be asserted, then ASCII characters can be sent.
In 4-bit mode, the four most
significant bits are sent first, and the lower four bits are sent second.
RS is taken low for sending command
codes. Each 4-bit transfer occurs when the E pin is pulsed.
If the LCD doesn’t appear to work,
try varying the contrast voltage on pin 3 of the LCD’s 14-pin connector.
Adjust the potentiometer connected to pin 3 until faint boxes
or characters become visible.
4 비트 LCD 구동 소스
; 4-bit LCD driver by Al Williams
freq 4000000 ; Run at 4MHz to simplify timing.
reset start ; Go to 'start' on reset.
dlyctr ds 1 ; Main delay counter.
dlymult ds 1 ; Delay multiplier.
tmp ds 1 ; Temp storage.
work ds 1 ; More temp storage.
i ds 1 ; Loop counter.
ebit equ ra.1 ; I/O: Enable and Register Select.
rsbit equ ra.0 ; Assumes DB4 to DB7 connect to RB.0-RB.3.
ldelay mov dlymult,#5 ; Long delay (5x256). Enter here if you want
delaym clr dlyctr ; to set your own dlymult.
init mov ra,#0 ; Call to init the LCD.
mov rb,#0 ; Set all bits to zero.
mov !rb,#%11110000 ; Set outputs.
call ldelay ; Give LCD some time to catch up.
mov rb,#$3 ; Write a 3 out to the display 3 times.
mov rb,#$2 ; Now go to 4-bit mode (twice).
; Set 2-line mode (remove next 2 lines if display has 1 line).
mov w,#14 ; Non blink cursor (use 15 for blinking).
mov w,#6 ; Activate the cursor.
clear ; Clear the screen (init falls Into this routine).
mov w,#1 ; Send a command (clear falls Into this routine).
cmd clrb rsbit
lcdout mov tmp,w ; Write to the LCD (4 bits at a time).
rr work ; Get top 4 bits first.
mov w,tmp ; Then bottom 4 bits.
pulsee setb ebit
; Pulse the E bit (lcdout falls into this).
; Set the cursor to the specified pos note that all displays think that
; line 2 starts at pos 40 even if they don't have 40 characters.
lookup mov w,i ; Get a byte from the string to display.
msg retw 'Assembly Language I/O '
retw 'with the SX-Key',13
retw 'by Al Williams and Parallax',0
start call init ; Here is the main program.
clr i ; Loop for each character.
ploop call lookup
; exit if 0
mov work,w ; If 13 then go to line #2.
call lcdout ; Not 0 or 13 so print it.
; this delay gives a "teletype" effectcomment the following 2 lines
; for full speed.
jmp ploop ; Keep going.
; This look waits for about 5 seconds or so and then starts the whole
; thing over.
:loop mov tmp,#64
:loop1 clr dlymult
nl mov w,#40 ; Move to line 2.
|병렬포트(LPT1) 시험 소프트웨어|
|SxSim (UBICOM의 SASM 어셈블러를 지원)|