?? rx9.lib
字號:
;;; RS-485 SERIAL COMMUNICATIONS.;;; Modes:;;; (1) Wait for address (REN = 1, T0 = 0, SM2 = 1);;; (2) Wait for data (REN = 1, T0 = 0, SM2 = 0);;; (3) Send data (REM = 0, T0 = 1)SER_ADDR equ 11110111b;;; All addresses should have the same number (7) of bits set.SetPort: mov SCON, #11000000b ;;; Serial comm: 8 bits, no parity, 1 stop bit. clr PS clr RCLK clr TCLK mov A, TMOD anl A, #00001111b add A, #00100000b ;;; Timer 1: baud rate timer. mov TMOD, A mov TH1, #-3 ;;; Baud rate: 19200 baud. setb TR1 clr TB8 clr RI clr TI setb ESretSetRx: ;;; Set mode for "Wait for address" clr T0 setb SM2 setb RENretSetTx: ;;; Set mode for "Send data" clr REN setb T0retgetchar: RecvLoop: mov R0, #SP_RI acall Pause mov A, SBUF jnb SM2, RecvData cpl A anl A, #SER_ADDR ;;; A = SER_ADDR & ~SBUF jnz NoMatch clr SM2 ;;; if (A == 0) Set mode for "Wait for data"; NoMatch: sjmp RecvLoop RecvData:retputchar: mov SBUF, A mov R0, #SP_TI acall Pauseret
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -