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

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

?? soft_uart.asm

?? 51常用子程序-4.0M.rar
?? 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一区二区三区免费野_久草精品视频
欧美精品tushy高清| 久久综合中文字幕| 麻豆极品一区二区三区| 中文一区在线播放| 欧美高清性hdvideosex| 国产黄色精品网站| 日本不卡一二三区黄网| 亚洲欧洲一区二区在线播放| 欧美成人bangbros| 欧美在线视频你懂得| 国产成人8x视频一区二区| 日韩av电影免费观看高清完整版| 亚洲欧美色图小说| 2020国产精品自拍| 91精品国产91久久久久久一区二区 | 久久成人免费日本黄色| 亚洲欧洲制服丝袜| 亚洲国产成人自拍| 日韩欧美国产一区在线观看| 欧洲精品在线观看| 97精品久久久午夜一区二区三区| 韩国精品主播一区二区在线观看| 香蕉成人啪国产精品视频综合网| 亚洲欧美日韩一区| 久久久99精品免费观看| 精品国产乱码久久| 欧美一区二区三区免费视频 | 国产一区二区三区| 日本怡春院一区二区| 亚洲五码中文字幕| 亚洲欧洲精品一区二区三区| 欧美国产精品一区二区| 精品欧美久久久| 日韩欧美国产不卡| 欧美一区日韩一区| 69久久99精品久久久久婷婷| 欧美乱熟臀69xxxxxx| 在线看日韩精品电影| 色婷婷久久久亚洲一区二区三区 | 精品久久久三级丝袜| 欧美一区二区三区在线观看| 欧美日韩综合在线免费观看| 日本道免费精品一区二区三区| 91视频.com| 91免费观看视频| 91免费观看国产| 欧美日韩精品福利| 欧美精品777| 精品国产欧美一区二区| 精品理论电影在线| 久久色在线视频| 久久精品男人的天堂| 国产精品三级久久久久三级| 中文字幕一区二区三区蜜月| 亚洲精品免费在线播放| 一级女性全黄久久生活片免费| 亚洲电影欧美电影有声小说| 五月天激情小说综合| 日韩影视精彩在线| 久久www免费人成看片高清| 国产一区二区免费看| 成人福利视频在线看| 色综合久久久久综合| 欧美裸体一区二区三区| 日韩精品在线网站| 国产精品免费久久久久| 亚洲美女电影在线| 午夜精品一区二区三区三上悠亚| 麻豆成人91精品二区三区| 国产一区二区三区蝌蚪| www.色综合.com| 欧美人与禽zozo性伦| 精品国产sm最大网站| 国产精品久久三| 香蕉成人啪国产精品视频综合网| 国产精品影视网| 91色porny| 精品欧美一区二区三区精品久久| 中文一区一区三区高中清不卡| 亚洲老司机在线| 免费国产亚洲视频| 91在线国产福利| 欧美大片国产精品| 综合婷婷亚洲小说| 久久国产综合精品| 99久久精品一区| 欧美一区二区视频在线观看2022| 国产精品卡一卡二| 婷婷国产在线综合| 懂色av中文字幕一区二区三区| 欧美日韩二区三区| 国产欧美一区二区精品秋霞影院| 亚洲激情成人在线| 国产一区久久久| 欧美精品久久一区| 国产精品久久久久久久岛一牛影视 | 欧美性大战久久久久久久| 精品粉嫩aⅴ一区二区三区四区 | 日本成人中文字幕在线视频| 不卡视频一二三四| 日韩三级视频在线观看| 亚洲人精品午夜| 国产麻豆精品久久一二三| 欧美日韩国产综合草草| 国产精品成人一区二区三区夜夜夜 | 欧美色偷偷大香| 国产精品久久久久婷婷| 麻豆国产欧美日韩综合精品二区| 日本高清成人免费播放| 国产精品欧美久久久久一区二区| 日本v片在线高清不卡在线观看| 91国在线观看| 亚洲欧洲性图库| 成人毛片在线观看| 久久久久久亚洲综合影院红桃 | 亚洲精品视频一区二区| 国产在线精品视频| 555夜色666亚洲国产免| 亚洲精品成人悠悠色影视| 成人久久18免费网站麻豆| 久久久精品tv| 精品一区二区成人精品| 欧美一区二区三区爱爱| 午夜视黄欧洲亚洲| 日本韩国欧美一区二区三区| 亚洲视频一区在线| www..com久久爱| 国产精品久久久久久久裸模| 国产中文字幕精品| www国产亚洲精品久久麻豆| 奇米影视7777精品一区二区| 欧美精品乱码久久久久久按摩| 亚洲一区二区五区| 91亚洲男人天堂| 亚洲欧美激情一区二区| 成人av电影免费观看| 中文字幕日韩av资源站| a级高清视频欧美日韩| 国产精品嫩草影院av蜜臀| 成人性生交大片免费看视频在线| 国产色产综合产在线视频| 国内精品写真在线观看| 精品免费日韩av| 国产精品一区二区三区四区| 国产日韩一级二级三级| 国产一区二区三区四区在线观看| 国产精品私人影院| 成a人片亚洲日本久久| 日韩一区在线播放| 色综合天天综合狠狠| 夜色激情一区二区| 欧美高清激情brazzers| 美腿丝袜亚洲一区| 久久综合色鬼综合色| 国产成人99久久亚洲综合精品| 国产精品美女久久福利网站| aaa国产一区| 亚洲一区二区三区精品在线| 制服丝袜国产精品| 九色|91porny| 国产精品视频一二| 色哟哟精品一区| 日本在线不卡视频| 久久男人中文字幕资源站| 91在线丨porny丨国产| 午夜精品视频在线观看| 欧美成人官网二区| 成人sese在线| 亚洲成av人片在线观看无码| 日韩视频免费观看高清完整版| 成人午夜私人影院| 一区二区三区在线播放| 日韩三级视频在线观看| 成人精品亚洲人成在线| 亚洲妇熟xx妇色黄| 精品区一区二区| 色综合久久久网| 久久99久久99| 亚洲欧美区自拍先锋| 欧美一激情一区二区三区| 国产成人无遮挡在线视频| 亚洲综合激情另类小说区| 欧美一区2区视频在线观看| 成人精品视频一区二区三区尤物| 亚洲大片一区二区三区| 国产亚洲女人久久久久毛片| 欧美日韩高清一区二区| 成人性生交大片| 麻豆精品国产91久久久久久| 一区二区三区四区蜜桃| 国产亚洲欧洲一区高清在线观看| 欧美最猛黑人xxxxx猛交| 国产精品亚洲а∨天堂免在线| 亚洲第一在线综合网站| 中文字幕国产一区二区| 91精品国产综合久久久蜜臀图片| 99久久免费国产| 国产一区二区三区最好精华液| 亚洲尤物视频在线| 中文字幕高清不卡|