ВУЗ:
Составители:
35
ldi ZH, HIGH(2*TXT)
ldi ZL, LOW(2*TXT)
L3A:
lpm ; From prog mem into R0
mov PARAM, R0
tst PARAM
brne L3B
rjmp L4
L3B:
cpi PARAM, 0x0D ; Look for CR in message (new line)
brne L3C
ldi PARAM, 0xC0 ; Cursor to position 0x40, start of 2nd line
rcall LCD_CMD ; Sends command
rjmp L3D
L3C:
rcall LCD_DATA
L3D:
adiw ZL, 1 ; Increment pointer. This neat instruction does
rjmp L3A ; w16 bit addition to pointer ZHI:ZLO.
L4:
ret ; Done
TXT:
.DB "Type in TTY cell (tx) ",0x0D ; Must contain an even
.DB ">",0x00 ; number of bytes per line
; Sends a control function to the display (comes in PARAM)
LCD_CMD:
push PARAM
mov TEMP, PARAM
andi PARAM, 0xF0 ; Mask off lower 4 bits
sbr PARAM, 8 ; OE bit high (bit 3)
out PORTD, PARAM ; Send upper 4 bits to display
nop ; Brief delay to give reasonable OE
nop ; pulse width
cbi PORTD,3 ; OE goes low to clock in data
mov PARAM, TEMP ; Data back
swap PARAM ; Lower 4 bits
andi PARAM, 0xF0
sbr PARAM, 8 ; OE high (bit 3, port D)
out PORTD, PARAM ; Write lower 4 bits to LCD
nop
nop
cbi PORTD,3 ; OE clock low
ldi PARAM, 100 ; 50 usec approx
DEL0:
36
dec PARAM
brne DEL0
pop PARAM
ret
; Sends an ASCII character to the display (comes in PARAM)
LCD_DATA:
push PARAM
push TEMP
mov TEMP, PARAM
andi PARAM, 0xF0 ; Mask off lower 4 bits
sbr PARAM, OE ; OE bit high
sbr PARAM, RS ; Data/command bit high
out PORTD, PARAM ; Write upper 4 bits to display
nop ; Brief delay
nop
cbi PORTD, 3 ; OE low to clock data
swap TEMP ; Lower 4 bits
andi TEMP, 0xF0 ; Masked off
sbr TEMP, OE ; OE high
sbr TEMP, RS
out PORTD, TEMP ; Lower 4 bits to LCD
nop
nop
cbi PORTD, 3 ; OE low to clock data
ldi TEMP, 100
mov DELAY, TEMP ; 50 usec
DEL1:
dec DELAY
brne DEL1
pop TEMP
pop PARAM
ret
; Moves the LCD display cursor to address specified in PARAM
LCD_CURSOR:
ori PARAM, 0x80 ; MSB specifies address command
rcall LCD_CMD
ret
Страницы
- « первая
- ‹ предыдущая
- …
- 16
- 17
- 18
- 19
- 20
- …
- следующая ›
- последняя »