在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 51單片機(jī)使用一個IO口做RC充放電來模擬ADC

            51單片機(jī)使用一個IO口做RC充放電來模擬ADC

            作者: 時間:2016-11-28 來源:網(wǎng)絡(luò) 收藏
            AUXR DATA 08EH ;Auxiliary register
            P1M1 DATA 091H ;P1M1.N,P1M0.N =00--->Standard, 01--->push-pull
            P1M0 DATA 092H ; =10--->pure input, 11--->open drain
            P_RC BIT P1.0 ;RC port
            DLY_H DATA 30H ;Delay high byte
            DLY_M DATA 31H ;delay mid byte
            DLY_L DATA 32H ;delay low byte
            SEND_CNT DATA 33H ;send counter
            ;//////////////////////////////////////////////////////////
            ORG 0000H
            LJMP RESET
            ORG 0100H
            RESET:
            LCALL INIT_UART ;initial UART
            LCALL INIT_IO ;initial io
            MOV SP,#40H
            MOV SEND_CNT,#10 ;10 results per line
            MAIN:
            MOV DLY_H,#25
            DLY1:
            MOV DLY_M,#HIGH 10000
            MOV DLY_L,#LOW 10000
            DLY2:
            DJNZ DLY_L,DLY3
            DEC DLY_M
            DLY3:
            MOV A,DLY_M
            ORL A,DLY_L
            JNZ DLY2
            DJNZ DLY_H,DLY1
            LCALL RC
            DJNZ SEND_CNT,MAIN
            MOV SEND_CNT,#10 ;10 results per line
            MOV A,#0DH ;send CR
            LCALL SEND_UART ;send to PC from the UART
            MOV A,#0AH ;send chage line
            LCALL SEND_UART ;send to PC from the UART
            SJMP MAIN
            ;//////////////////////////////////////////////////////////
            INIT_UART:
            MOV SCON,#5AH ;set UART mode as 8-bit variable baudrate
            MOV TMOD,#20H ;timer1 as 8-bit auto reload mode
            MOV AUXR,#40H ;timer1 work at 1T mode
            MOV TL1,#0FBH ;115200 bps(256 - 18432000 / 32 / 115200)
            MOV TH1,#0FBH
            SETB TR1
            RET
            ;//////////////////////////////////////////////////////////
            Init_IO:
            ORL P1M1, #0x01 ;P1.0 config as Open-Drain
            ORL P1M0, #0x01
            CLR P_RC ;Clear P1.0 to 0
            ORL TMOD, #0x01 ;T0 as 16 bits timer
            RET
            ;//////////////////////////////////////////////////////////
            SEND_UART:
            CLR TI ;clear TI flag
            MOV SBUF,A ;send current data
            JNB TI,$ ;wait data sent
            RET
            ;//////////////////////////////////////////////////////////
            RC:
            MOV TH0, #0 ;clear Timer 0
            MOV TL0, #0
            SETB P_RC ;RC charge
            SETB TR0 ;enable Timer 0
            JNB P_RC,$ ;wait charge finish
            CLR TR0 ;deable Timer 0
            CLR P_RC ;decharge
            MOV R3,TH0; ;read the RC time
            MOV R4,TL0;
            LCALL F_HEX2_DEC
            MOV A,R5
            ADD A,#30H ;Charge to ASCII code
            LCALL SEND_UART ;send to PC from the UART
            MOV A,R6
            SWAP A
            ANL A,#0FH
            ADD A,#30H ;Charge to ASCII code
            LCALL SEND_UART ;send to PC from the UART
            MOV A,R6
            ANL A,#0FH
            ADD A,#30H ;Charge to ASCII code
            LCALL SEND_UART ;send to PC from the UART
            MOV A,R7
            SWAP A
            ANL A,#0FH
            ADD A,#30H ;Charge to ASCII code
            LCALL SEND_UART ;send to PC from the UART
            MOV A,R7
            ANL A,#0FH
            ADD A,#30H ;Charge to ASCII code
            LCALL SEND_UART ;send to PC from the UART
            MOV A,#20H
            LCALL SEND_UART ;send to PC from the UART
            MOV A,#20H
            LCALL SEND_UART ;send to PC from the UART
            RET
            ;//////////////////////////////////////////////////////////
            F_HEX2_DEC: ;(R3---R4) HEX Change to DEC ---> (R5---R7), use (R2~R7), 344T
            MOV R2,#16
            MOV R5,#0
            MOV R6,#0
            MOV R7,#0
            L_HEX2_DEC:
            CLR C
            MOV A,R4
            RLC A
            MOV R4,A
            MOV A,R3
            RLC A
            MOV R3,A
            MOV A,R7
            ADDC A,R7
            DA A
            MOV R7,A
            MOV A,R6
            ADDC A,R6
            DA A
            MOV R6,A
            MOV A,R5
            ADDC A,R5
            DA A
            MOV R5,A
            DJNZ R2,L_HEX2_DEC
            RET
            END


            評論


            技術(shù)專區(qū)

            關(guān)閉