人狗畜禽COMPANY LIMITED|全是肉的高H文〈男男〉|全篇肉高H秘书被C办公室四爱|全黄H全肉共妻|全黄H全肉短篇禁乱NP慕浅浅|全黄H全肉短篇N男男

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

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

開發(fā)工具

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

技術(shù)支持

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

新品推廣

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

新聞中心

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

PIC16C63單片機串口通信程序一覽

更新時間: 2019-03-21
閱讀量:384

 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'             ; 十進制的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'


安陆市| 东乡县| 上高县| 纳雍县| 合阳县| 怀柔区| 叶城县| 文化| 金山区| 云和县| 缙云县| 乾安县| 汪清县| 正镶白旗| 莲花县| 杂多县| 正安县| 清远市| 清镇市| 封丘县| 同德县| 汉寿县| 石台县| 石景山区| 随州市| 武强县| 福泉市| 长阳| 竹溪县| 小金县| 涞水县| 沙湾县| 璧山县| 四川省| 黑水县| 友谊县| 枣强县| 长沙市| 安顺市| 大连市| 唐海县|