Zatial dik moc…skusim nieco napisat a dam tu na kontrolu, dufam, ze pomozete …
dik…
Tak som nieco zbuichal, skuste kuknut a dat rady. Konstanty zatial neprepocitane… cerpane info viac menej z
mytutorialcafe.com/Microcont … rd%202.htm
$MOD51
;soft
kbdata equ P1.3
kbclock equ P1.2
kbdata1 equ 30h
kbdata2 equ 31h
timer1 equ 38h
timer2 equ 39h
org 00h
jmp start
org 0Bh
jmp citac0
org 023h
jmp rs232
org 30h
start: mov TMOD, #00100001B ;C/C0 - mod1, C/C1 - pre uart
mov TCOM, #00000000B ;obe citace vypnute
mov SCON, #01000000B ;UART rezim1
mov PCON, #00000000B ;normalna rychlost
mov IE, #00011010B ;povolenie preruseni podla potreby
mov TH0, #01111111B ;Hbyt C/C0 ?????
mov TL0, #11111111B ;Lbyt C/C0 ?????
mov TH1, #11111111B ;nastavenie rychlosti UART ?????
mov TR0, #1B ;spusti C/C0
mov TR1, #1B ;spusti C/C1
mov r5, #00H
;snimanie KB
snimkb: jb kbclock, $
call citajkb
jnc snimkb
acall posliznak
clr C
sjmp snimkb
,rutina pre citanie znaku z kb
citajkb: call citajznak
cjne a,#0F0h, pustene
JB Kbclock,$
call citajznak
Setb C
call convertuj
ret
pustene: clr C
ret
citajznak:
clr A
Jnb Kbclock,$
mov R0,#08h
citajznak2:
Jb Kbclock,$
Mov C,Kbdata
Rr A
mov acc.7,C
Jnb Kbclock,$
Djnz R0,citajznak2
Jb Kbclock,$
Jnb Kbclock,$
Jb Kbclock,$
Jnb Kbclock,$
ret
convertuj:
Mov DPTR,#TableKeyboard
movc A,@A+DPTR
mov kbdata1,A
ret
poslizank:
mov R7, kbdata1
mov SBUF, R7
mov timer2, r5
ret
citac0: inc timer1
jnz ok
inc timer2
mov r6, timer2
cjne r6, #200H , ok
mov a, #13H
call posliznak
mov timer1, #00H
mov timer2, #00H
ok: reti
TableKeyboard:
DB 00
DB 0F9H
DB 00
DB 0F5H,0F3H,0F1H,0F2H,0FCH
DB 00H
DB 0FAH,0F8H,0F6H,0F4H
DB 0C0H
DB '~'
DB 00H
DB 00H
DB 0C1H
DB 0C2H
DB 00H
DB 0C3H
DB 'Q1'
DB 00H,00H,00H
DB 'ZSAW2'
DB 00H,00H
DB 'CXDE43'
DB 00H,00H
DB ' VFTR5'
DB 00H,00H
DB 'NBHGY6'
DB 00H,00H,00H
DB 'MJU78'
DB 00H,00H
DB ',KIO09'
DB 00H,00H
DB './L;P-'
DB 00H,00H,00H
DB 27H
DB 00H
DB '='
DB 00H,00H
DB 0C5H
DB 0C6H
DB 0AH
DB ']'
DB 00H
DB '\'
DB 00H,00H,00H,00H,00H,00H,00H,00H
DB 08H
DB 00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H
DB 00H,00H
DB 0DH
DB 00H
DB 0FBH
DB 00H,00H,00H,00H,00H,00H,00H,00H,00H,00H
DB 0F7H
end
ka_x51_01.asm (2.69 KB)