⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sercom.sdi

📁 代码保护功能处于持续发展中。Microchip 承诺将不断改进产品的代码保护功能。任何试图破坏Microchip 代码保护功能的行为均可视 为违反了《数字器件千年版权法案(Digital Mille
💻 SDI
字号:
,,,;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
,,,;
,,,;       SERCOM.ASM      Version 1.0     10-9-05         MPB
,,,;...............................................................
,,,;
,,,;       Test RS232 communications using the
,,,;       USART Asynchronous Transmit and Receive
,,,;
,,,;       The Proteus Virtual Terminal allows ASCII characters
,,,;       to be displayed, and generated from the computer keys.
,,,;       The program outputs a fixed message to the display
,,,;       from a table, and then displays numbers input from the
,,,;       terminal on a BCD 7-segment LED display.
,,,;
,,,;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
,,,
,,,        PROCESSOR 16F877        ; define MPU
00002007,3731,,        __CONFIG 0x3731         ; XT clock (4MHz)
,,,
,,,;       LABEL EQUATES   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
,,,
,,,        INCLUDE "P16F877A.INC"  ; Standard register labels
,,,
,,,        Point   EQU     020
,,,        Inchar  EQU     021
,,,
,,,; Initialise ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
,,,
,,,        ORG     0               ; Place machine code
00000000,0000,,        NOP                     ; Required for ICD mode
,,,
00000001,1683 1303,,        BANKSEL TRISD           ; Select bank 1
00000003,0188,,        CLRF    TRISD           ; Display outputs
00000004,1318,,        BCF     TXSTA,TX9       ; Select 8-bit transmission
00000005,1298,,        BCF     TXSTA,TXEN      ; Disable transmission initially
00000006,1218,,        BCF     TXSTA,SYNC      ; Asynchronous mode
00000007,1518,,        BSF     TXSTA,BRGH      ; High baud rate
,,,
00000008,3019,,        MOVLW   D'25'           ; Baud rate counter value ..
00000009,0099,,        MOVWF   SPBRG           ; .. for 9600 baud, 4MHz clock
0000000A,1698,,        BSF     TXSTA,TXEN      ; Enable transmission
,,,
0000000B,1283 1303,,        BANKSEL RCSTA           ; Select bank 0
0000000D,1798,,        BSF     RCSTA,SPEN      ; Enable serial port
,,,
,,,
,,,; MAIN LOOP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
,,,
0000000E,2011,,        CALL    write           ; Display message on terminal
0000000F,201B,readin,readin  CALL    read            ; Get number input from terminal
00000010,280F,,        GOTO    readin          ; Keep reading until reset
,,,
,,,; SUBROUTINES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
,,,
,,,; Write message to terminal......................................
,,,
00000011,01A0,write,write   CLRF    Point           ; Table pointer = 0
00000012,0820,next,next    MOVF    Point,W         ; Load table pointer
00000013,2028,,        CALL    mestab          ; Get character
00000014,2024,,        CALL    sencom          ; Output to terminal
00000015,0AA0,,        INCF    Point           ; Point to next
00000016,300E,,        MOVLW   D'14'           ; Number of characters + 1
00000017,0220,,        SUBWF   Point,W         ; Check pointer
00000018,1D03,,        BTFSS   STATUS,Z        ; Last character done?
00000019,2812,,        GOTO    next            ; No - next
0000001A,0008,,        RETURN                  ; All done
,,,
,,,
,,,; Read input numbers from terminal...............................
,,,
0000001B,1618,read,read    BSF     RCSTA,CREN      ; Enable reception
0000001C,1E8C,waitin,waitin  BTFSS   PIR1,RCIF       ; Character received?
0000001D,281C,,        GOTO    waitin          ; no - wait
,,,
0000001E,081A,,        MOVF    RCREG,W         ; get input character
0000001F,00A1,,        MOVWF   Inchar          ; store input character
00000020,3030,,        MOVLW   030             ; ASCII number offset
00000021,0221,,        SUBWF   Inchar,W        ; Calculate number
00000022,0088,,        MOVWF   PORTD           ; display it
00000023,0008,,        RETURN                  ; done
,,,
,,,
,,,; Transmit a character ..........................................
,,,
00000024,0099,sencom,sencom  MOVWF   TXREG           ; load transmit register
00000025,1E0C,waitot,waitot  BTFSS   PIR1,TXIF       ; sent?
00000026,2825,,        GOTO    waitot          ; no
00000027,0008,,        RETURN                  ; yes
,,,
,,,
,,,; Table of message characters....................................
,,,
00000028,0782,mestab,mestab  ADDWF   PCL             ; Modify program counter
00000029,3445,,        RETLW   'E'             ; Point = 0
0000002A,344E,,        RETLW   'N'             ; Point = 1
0000002B,3454,,        RETLW   'T'             ; Point = 2
0000002C,3445,,        RETLW   'E'             ; Point = 3
0000002D,3452,,        RETLW   'R'             ; Point = 4
0000002E,3420,,        RETLW   ' '             ; Point = 5
0000002F,344E,,        RETLW   'N'             ; Point = 6
00000030,3455,,        RETLW   'U'             ; Point = 7
00000031,344D,,        RETLW   'M';            ; Point = 8
00000032,3442,,        RETLW   'B'             ; Point = 9
00000033,3445,,        RETLW   'E'             ; Point = 10
00000034,3452,,        RETLW   'R'             ; Point = 11
00000035,343A,,        RETLW   ':'             ; Point = 12
00000036,3420,,        RETLW   ' '             ; Point = 13
,,,
,,,
,,,        END     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -