亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? soft_uart.asm

?? 51系列單片機常用子程序
?? ASM
?? 第 1 頁 / 共 2 頁
字號:
TxEx2:      MOV   TxCnt,#11h            ; Set TX bit counter for a start.
            MOV   TxTime,#TxBitLen-1    ; Reset time slice count, stop bit
                                        ;   > 1 bit time for synch.
            SJMP  CheckRx               ; Restore state and exit.



;*******************************************************************************
;                             RS-232 Receive Routine
;*******************************************************************************


RS232RX:    MOV   C,RxPin               ; Get current serial bit value.
            JNB   RxCnt.4,RxData        ; Go if data bit.
            JNB   RxCnt.0,RxStop        ; Go if stop bit.


;Verify start bit.

RxStart:    JC    RxErr                 ; If bit=1, then not a valid start.
            MOV   RxCnt,#08h            ; Init counter to expect data.
            MOV   RxTime,#RxBitLen      ; Reset time slice count.
            SJMP  T0Ex                  ; Restore state and exit.


; Get Next Data Bit.

RxData:     MOV   A,RxShift             ; Get partial received byte.
            RRC   A                     ; Shift in new received bit.
            MOV   RxShift,A             ; Store partial result in buffer.
            INC   RxCnt                 ; Increment received bit count.
            MOV   RxTime,#RxBitLen      ; Reset time slice count.
            SJMP  T0Ex                  ; Restore state and exit.


; Store Data Byte, "push"ing it into the FIFO buffer.

RxStop:     CLR   EA                    ; Don't interrupt the following.
            MOV   A,RxBuf               ; "PUSH" the receive buffer.
            XCH   A,RxBuf+1
            XCH   A,RxBuf+2
            MOV   RxBuf,RxShift         ; Add just completed data to buffer.
            INC   RxDatCnt              ; Increment the received byte count.
            SETB  EA                    ; Re-enable interrupts.

            SETB  RxAvail               ; There is data in the RX buffer.
            PUSH  PSW                   ; Save Carry (received bit)for later.
            MOV   A,RxDatCnt            ; Check receiver buffer status.
            CJNE  A,#4,RxChk1           ; Is RX buffer overrun?
            SETB  OverrunErr            ; Set status reg overrun error flag.
            MOV   RxDatCnt,#3           ; Re-set buffer counter to "full".

RxChk1:     CJNE  A,#3,RxChk2           ; Is RX buffer full?
            SETB  RxFull                ; Set buffer full status.

RxChk2:     POP   PSW                   ; Retrieve last received bit in Carry.
            JC    RxEx                  ; If bit=0, then not a valid stop.
RxErr:      SETB  FramingErr            ; Remember bad start or stop status.

RxEx:       JB    TxOn,RxTimerOn        ; If transmit active, timer stays on,
            CLR   TR                    ;   otherwise turn timer off.
RxTimerOn:  CLR   RxOn                  ; Turn off receive active.
            SETB  RxTime.7              ; Set bit for no service to
                                        ;   RX Time Slice Branches.
            SETB  IE.0                  ; Re-enable RS-232 receive interrupts.
            AJMP  T0Ex                  ; Restore state and exit.


;*******************************************************************************
;                                  Subroutines
;*******************************************************************************


; BaudRate - Determine and set the baud rate from switches.
;   Note: if the baud rate is altered, the actual change will only occur when 
;   a transmit or receive is begun while the timer was not already running 
;   (i.e.: not already busy transmitting or receiving).

BaudRate:   MOV   DPTR,#BaudTable       ; Set pointer to baud rate table.
            ANL   A,#03h                ; Limit displacement for lookup.
            RL    A                     ; Double the table index since these 
                                        ;   are 2 byte entries.
            PUSH  ACC                   ; Save the table index for second byte.
            MOVC  A,@A+DPTR             ; Get first byte, and save as the high
            MOV   BaudHigh,A            ;    byte of the baud rate timer value.
            POP   ACC                   ; Get back the table index.
            INC   A                     ; Advance to next table entry.
            MOVC  A,@A+DPTR             ; Get second byte, and save as the low
            MOV   BaudLow,A             ;    byte of the baud rate timer value.
            RET


; Entries in BaudTable are for a timer setting of 1/4 of a bit time at the given
;   baud rate. The two values per entry are the high and low bytes of the value
;   respectively.

; Values are calculated as follows: 
;                                             Osc Frequency
;   1/4 Bit cell time (in machine cycles) = -----------------
;                                            Baud Rate * 48

; Example for 9600 baud with a 16MHz crystal:
;    16,000,000 / 9600 * 48 = 34.7222... machine cycles per quarter bit time.
;    Rounded, this is 35. The hexadecimal value for 35 is 23. 
;    10000 hex - 23 hex (truncated to 16 bits) = FFDD. Thus, the BaudTable entry
;    for 9600 baud is FF, DD hex.

BaudTable:  DB    0FEh,0EAh             ; 1200 baud. 
            DB    0FFh,75h              ; 2400 baud.
            DB    0FFh,0BBh             ; 4800 baud.
            DB    0FFh,0DDh             ; 9600 baud.


; TxSend - Initiate RS-232 Transmit.

TxSend:     JB    TxFull,$              ; Make sure TX buffer is free.
            SETB  TxFull                ; Reserve the buffer for our use.
            MOV   TxDat,A               ; Put character in buffer.
            JB    TxOn,TSTimerOn        ; Exit if transmitter already running.

            SETB  TxOn                  ; Transmit active flag set.
            MOV   TxCnt,#11h            ; Init bit counter to expect a start.
            MOV   TxTime,#TxBitLen      ; Reset time slice count.
            JB    RxOn,TSTimerOn        ; Exit if receiver already active.

            MOV   RTH,BaudHigh          ; Set up timer for selected baud rate.
            MOV   RTL,BaudLow
            MOV   TH,BaudHigh
            MOV   TL,BaudLow
            SETB  TR                    ; Start up the bit timer.
TSTimerOn:  RET


; PrByte - Output a byte as ASCII hexadecimal format.

PrByte:     PUSH  ACC                   ; Print ACC contents as ASCII hex.
            SWAP  A
            ACALL  HexAsc               ; Print upper nibble.
            ACALL  TxSend
            POP   ACC
            ACALL  HexAsc               ; Print lower nibble.
            ACALL  TxSend
            RET


; HexAsc - Convert a hexadecimal nibble to its ASCII character equivalent.

HexAsc:     ANL   A,#0Fh                ; Make sure we're working with only 
                                        ;   one nibble.
            CJNE  A,#0Ah,HA1            ; Test value range.
HA1:        JC    HAVal09               ; Value is 0 to 9.
            ADD   A,#7                  ; Value is A to F, needs pre-adjustment.
HAVal09:    ADD   A,#'0'                ; Adjust value to ASCII hex.
            RET


; GetRx - Retrieve a byte from the receive buffer, and return it in A.

GetRx:      CLR   EA                    ; Make sure this isn't interrupted.
            DEC   RxDatCnt              ; Decrement the buffer count.
            MOV   A,RxDatCnt            ; Get buffer count.
            JNZ   GRX1                  ; Test for empty receive buffer.
            CLR   RxAvail               ; If empty, clear data available status.
GRX1:       ADD   A,#RxBuf              ; Create a pointer to end of buffer.
            MOV   Temp,R0               ; Save R0.
            MOV   R0,A                  ; Put pointer where we can indirect.
            MOV   A,@R0                 ; Get last buffer data.
            MOV   R0,Temp               ; Restore R0.
            CLR   RxFull                ; Buffer can't be full anymore.
            SETB  EA                    ; Re-enable interrupts.
            RET


;*******************************************************************************
;                                      Reset
;*******************************************************************************

Reset:      MOV   SP,#2Fh               ; Initialize stack start.
            MOV   TCON,#0               ; Set timer off, INT0 to level trigger.
            MOV   P3,#0                 ; Turn off all status outputs.

; For this demo, we only set up the baud rate once at reset:

            MOV   A, P1                 ; Read baudrate bits from P1.
            RR    A                     ; The switches are on bits 2 and 1.
            ACALL BaudRate              ; Set up the selected baud rate.

            MOV   FLAGS,#0              ; Init all status flags.
            MOV   RxDatCnt,#0           ; Clear buffer count.
            MOV   IE,#93h               ; Turn on timer 0 interrupt and 
                                        ;   external interrupt 0.
            CLR   RTS                   ; Assert RTS so we can receive.


; The main program loop processes received data and sends it back to the 
;   transmitter in hexadecimal format. This insures that we can always fill 
;   up the receiver buffer (since the returned data is longer than the 
;   received data) for testing purposes. Example: if the letter "A" is 
;   received, we will echo "A41 ".

MainLoop:   JNB   RxAvail,$             ; Make sure an input byte is available.
            ACALL GetRx                 ; Get data from the receiver buffer.
            ACALL TxSend                ; Echo original character.
            ACALL PrByte                ; Output the char in hexadecimal format,
            MOV   A,#20h                ;   followed by a space.
            ACALL TxSend
            SJMP  MainLoop              ; Repeat.

            END

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91丨porny丨在线| 麻豆精品一二三| 日韩欧美亚洲另类制服综合在线| 九九久久精品视频 | 国产精品理论在线观看| 欧美日韩国产综合一区二区三区 | 色狠狠av一区二区三区| 蜜臀精品久久久久久蜜臀| 亚洲欧美另类小说| 国产欧美精品国产国产专区| 欧美唯美清纯偷拍| 成人久久久精品乱码一区二区三区| 日日夜夜一区二区| 亚洲永久免费av| 国产精品久久久久精k8| 精品噜噜噜噜久久久久久久久试看 | 国产欧美日韩不卡免费| 日韩一区二区精品| 欧美在线视频你懂得| 国产精品18久久久| 老司机精品视频导航| 亚洲与欧洲av电影| 1区2区3区欧美| 国产农村妇女毛片精品久久麻豆| 日韩欧美成人一区| 欧美日韩国产成人在线免费| 亚洲va在线va天堂| 91精品国产欧美一区二区成人 | 亚洲激情图片小说视频| 国产乱一区二区| 久久免费的精品国产v∧| 99久久国产综合色|国产精品| 51精品久久久久久久蜜臀| 亚洲综合视频网| 久久九九久精品国产免费直播| 亚洲婷婷国产精品电影人久久| 色哟哟国产精品| 亚洲女子a中天字幕| 91在线视频网址| 亚洲尤物视频在线| 91精品国产综合久久久久| 亚洲午夜影视影院在线观看| 日韩一区二区三区高清免费看看| 欧美视频一区二区| 国产乱码精品一品二品| 亚洲另类在线制服丝袜| 亚洲免费av在线| 亚洲久草在线视频| 白白色亚洲国产精品| 成人avav影音| 狠狠色丁香久久婷婷综合_中| 亚洲成av人影院| 免费看欧美女人艹b| 韩国一区二区三区| 国产精品私房写真福利视频| 久久国产欧美日韩精品| 97国产精品videossex| 色8久久人人97超碰香蕉987| a级高清视频欧美日韩| 国产成人鲁色资源国产91色综| 欧美日韩免费一区二区三区视频| 欧美一级在线免费| 91九色最新地址| 国产精品456| va亚洲va日韩不卡在线观看| 亚洲激情校园春色| 亚洲色图视频免费播放| 亚洲精品久久久久久国产精华液| 亚洲天堂久久久久久久| 久久久亚洲综合| 日韩精品专区在线影院观看| 欧美一级艳片视频免费观看| 日韩美女视频一区二区在线观看| 亚洲欧美国产三级| 一区二区三区在线看| 亚洲国产精品一区二区久久恐怖片| 国产精品免费人成网站| 日韩理论在线观看| 亚洲高清一区二区三区| 中文字幕一区在线观看| 国产精品二三区| 午夜久久久影院| 亚洲观看高清完整版在线观看 | 亚洲成av人片| 日韩精彩视频在线观看| 国产精品影视网| 一道本成人在线| 欧美午夜在线观看| 久久夜色精品国产噜噜av| 欧美成人激情免费网| 久久久精品影视| 国产成人午夜高潮毛片| 粉嫩欧美一区二区三区高清影视 | 97久久久精品综合88久久| 91丨porny丨国产入口| 欧美色男人天堂| 欧美伦理电影网| 久久久久久久久蜜桃| 在线不卡免费av| 在线观看免费成人| 国产成人一区在线| 樱花草国产18久久久久| 国产精品毛片高清在线完整版| 视频一区二区不卡| 欧美色大人视频| 中文字幕不卡一区| 欧美午夜电影在线播放| 久久精品国产成人一区二区三区| 不卡一区二区在线| 欧美不卡一区二区| 午夜不卡av免费| 91在线国产观看| 国产日韩综合av| 免费观看久久久4p| 欧美日韩在线播放三区| 中文字幕一区二区三区不卡在线| 国内精品久久久久影院一蜜桃| 欧美精品久久久久久久多人混战 | 国产成人精品影视| 日韩午夜精品视频| 无吗不卡中文字幕| 日本高清不卡一区| 自拍偷拍欧美精品| 成人av资源网站| 国产欧美日韩精品a在线观看| 精品在线播放免费| 欧美日韩国产综合视频在线观看| 亚洲美女在线一区| 成人精品免费视频| 国产精品久久久久久亚洲伦| 国产乱码字幕精品高清av| 精品久久五月天| 久久精品理论片| 日韩三级中文字幕| 免费在线观看视频一区| 91精品国产丝袜白色高跟鞋| 亚洲第一激情av| 日韩电影免费在线观看网站| 亚洲成a人片在线观看中文| 日韩欧美国产一二三区| 国产高清无密码一区二区三区| 亚洲国产精品欧美一二99| 91九色最新地址| 精品一区二区免费在线观看| 中文字幕不卡的av| 精品污污网站免费看| 美国欧美日韩国产在线播放| 亚洲一区视频在线| av亚洲产国偷v产偷v自拍| 久久久精品综合| 国产91丝袜在线播放0| 国产精品亲子伦对白| 大白屁股一区二区视频| 中文字幕亚洲成人| 在线精品观看国产| 亚洲国产欧美日韩另类综合| 欧美日韩精品免费| 裸体歌舞表演一区二区| 久久久久久99精品| thepron国产精品| 一区二区三区四区不卡在线 | 亚洲风情在线资源站| 3751色影院一区二区三区| 精品一区二区综合| 久久久久88色偷偷免费| av一区二区三区四区| 亚洲成人资源在线| 日韩你懂的在线观看| 懂色中文一区二区在线播放| 一区二区三区在线观看动漫| 制服丝袜亚洲色图| 丰满白嫩尤物一区二区| 一区二区免费看| 91精品在线免费| 丁香婷婷综合激情五月色| 一区二区三区毛片| 精品国产91亚洲一区二区三区婷婷| 国产.精品.日韩.另类.中文.在线.播放| 中文字幕在线观看不卡| 7777精品伊人久久久大香线蕉经典版下载 | 久久一留热品黄| 91精品1区2区| 国产一区激情在线| 亚洲精品视频一区二区| 26uuuu精品一区二区| 91蜜桃在线观看| 毛片一区二区三区| 依依成人精品视频| 国产视频一区二区三区在线观看| 91久久久免费一区二区| 久久精品99国产国产精| 玉足女爽爽91| 中文字幕av一区 二区| 337p亚洲精品色噜噜噜| 色哟哟精品一区| jiyouzz国产精品久久| 九九国产精品视频| 亚洲超碰精品一区二区| 中文字幕一区二区三区精华液 | 欧美亚男人的天堂|