Steward
分享是一種喜悅、更是一種幸福
微處理器 - Lattice GAL22V10 - Assembly - UART
參考資訊:
https://www.stcmicro.com/datasheet/STC15F204EA-cn.pdf
https://www.stcmicro.com/datasheet/STC15F2K60S2-en.pdf
AUXR

Interrupt

SCON

main.s
led set p1.2
t2l data 0d7h
t2h data 0d6h
.org 0x00
jmp start
.org 0x23
jmp uart_handle
.org 0x100
start:
mov scon, #50h
mov t2l, #0e0h
mov t2h, #0feh
orl auxr, #10h
orl auxr, #1
orl auxr, #4
setb es
setb ea
setb led
mov dptr, #str_crlf
call send_string
mov dptr, #str_hello
call send_string
jmp $
uart_handle:
jnb ri, finish
clr ri
cpl led
mov dptr, #str_ok
call send_string
finish:
reti
send_string:
clr a
movc a, @a+dptr
jz send_done
mov sbuf, a
wait_ti:
jnb ti, wait_ti
clr ti
inc dptr
jmp send_string
send_done:
ret
str_crlf:
db 0dh, 0ah, 00h
str_hello:
db 'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!', 0dh, 0ah, 00h
str_ok:
db 'O', 'K', 0dh, 0ah, 00h
.end
完成