久久丫精品无码视频|亚洲成人黄色电影|超碰国产在线观看|亚洲Aⅴ综合免费在线|久久青青草原国产精品|极品美女三级片国产无码a|女人的黄色片子综合AV|日韩成人?毛片

技術(shù)熱線: 4007-888-234
設(shè)計(jì)開發(fā)

專注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命

開發(fā)工具

提供開發(fā)工具、應(yīng)用測試 完善的開發(fā)代碼案例庫分享

技術(shù)支持

從全面的產(chǎn)品導(dǎo)入到強(qiáng)大技術(shù)支援服務(wù) 全程貼心伴隨服務(wù),創(chuàng)造無限潛能!

新品推廣

提供新的芯片及解決方案,提升客戶產(chǎn)品競爭力

新聞中心

提供最新的單片機(jī)資訊,行業(yè)消息以及公司新聞動(dòng)態(tài)

PIC16C63單片機(jī)串口通信程序一覽

更新時(shí)間: 2019-03-21
閱讀量:487

 list      p=16c63           ; list directive to define processor
    #include 
        ; processor specific variable definitions
       
        __CONFIG _BODEN_OFF&_CP_OFF&_WRT_ENABLE_ON&_PWRTE_ON&_WDT_OFF&_XT_OSC&_DEBUG_OFF&_CPD_OFF&_LVP_OFF

; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.


;***** VARIABLE DEFINITIONS
w_temp        EQU     0x20        ; variable used for context saving 
status_temp   EQU     0x21        ; variable used for context saving
Buffer1          EQU     0x22
Buffer2          EQU     0x23
             
;**********************************************************************
        ORG     0x000             ; processor reset vector
            nop
                 clrf    PCLATH            ; ensure page bits are cleared
          goto    main              ; go to beginning of program


        ORG     0x004             ; interrupt vector location
        movwf   w_temp            ; save off current W register contents
        movf    STATUS,w          ; move status register into W register
        bcf     STATUS,RP0        ; ensure file register bank set to 0
        movwf    status_temp       ; save off contents of STATUS register

; isr code can go here or be located as a call subroutine elsewhere

        bcf     STATUS,RP0        ; ensure file register bank set to 0
        movf    status_temp,w     ; retrieve copy of STATUS register
        movwf    STATUS            ; restore pre-isr STATUS register contents
        swapf   w_temp,f
        swapf   w_temp,w          ; restore pre-isr W register contents
        retfie                    ; return from interrupt

                ORG 40H

main
                banksel    TRISC             ; MPLAB提供的宏,BANK選擇
                MOVLW   0X80
                MOVWF   TRISC             ; TX/RX口輸入輸出配置
                banksel SPBRG
                MOVLW   D'25'             ; 十進(jìn)制的25
                MOVWF   SPBRG             ; 9600 BPS/ 4MHZ
                banksel TXSTA
                CLRF    TXSTA
                BSF     TXSTA,BRGH        ; HIGH SPEED/ASYN/8BITS
                BSF     TXSTA,TXEN
        banksel    RCSTA
                CLRF    RCSTA  
                BSF     RCSTA,SPEN        ; SERIAL PORT ENABLE
                BSF     RCSTA,CREN        ; CONTINUOUS RECEIVE ENABLE
                                          ; 8BITS/DISABLE ADDEN
                banksel TXREG                
                movf    Buffer1,W    
                movwf   TXREG
                call    TXPOLL
                movf    Buffer2,W
        movwf   TXREG
        call    TXPOLL
        goto    $
            
;************************************************
;* RXPOLL - This function polls the USART       *
;* receive interrupt flag and waits until a     *
;* data byte is available in RCREG.             *
;************************************************
RXPOLL
    bcf    STATUS,RP0
    btfss    PIR1,RCIF
    goto    RXPOLL
    return

;************************************************
;* TXPOLL - This function polls the TRMT flag   *
;* and waits until the USART has finished       * 
;* shifting the data byte out of the transmit   *
;* shift register.                              *
;************************************************
TXPOLL
    bsf    STATUS,RP0
TLOOP
    btfss    TXSTA,TRMT
    goto    TLOOP
    bcf    STATUS,RP0
    return         
          
    END                       ; directive 'end of program'