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

📄 base1.sdi

📁 代码保护功能处于持续发展中。Microchip 承诺将不断改进产品的代码保护功能。任何试图破坏Microchip 代码保护功能的行为均可视 为违反了《数字器件千年版权法案(Digital Mille
💻 SDI
📖 第 1 页 / 共 3 页
字号:
,,,
0000007F,01A1,volmes,volmes  CLRF    Tabin           ; Zero table pointer
00000080,0821,next1,next1   MOVF    Tabin,W         ; Load table pointer
00000081,2093,,        CALL    mess1           ; Get next character
00000082,00A0,,        MOVWF   Temp            ; Test data...
00000083,08A0,,        MOVF    Temp,F          ; ..for zero
00000084,1903,,        BTFSC   STATUS,Z        ; Last letter done?
00000085,0008,,        RETURN                  ; yes - next block
00000086,20B5,,        CALL    send            ; no - display it
00000087,0AA1,,        INCF    Tabin           ; Point to next letter
00000088,2880,,        GOTO    next1           ; and get it
,,,
,,,; ---------------------------------------------------------
,,,
00000089,01A1,keymes,keymes  CLRF    Tabin           ; Zero table pointer
0000008A,0821,next2,next2   MOVF    Tabin,W         ; Load table pointer
0000008B,209D,,        CALL    mess2           ; Get next character
0000008C,00A0,,        MOVWF   Temp            ; Test data...
0000008D,08A0,,        MOVF    Temp,F          ; ..for zero
0000008E,1903,,        BTFSC   STATUS,Z        ; Last letter done?
0000008F,0008,,        RETURN                  ; yes - next block
00000090,20B5,,        CALL    send            ; no - display it
00000091,0AA1,,        INCF    Tabin           ; Point to next letter
00000092,288A,,        GOTO    next2           ; and get it
,,,
,,,;----------------------------------------------------------
,,,; Text strings for fixed messages
,,,;----------------------------------------------------------
,,,
00000093,0782,mess1,mess1   ADDWF   PCL             ; Set table pointer
00000094,3456 346F 346C,,        DT      "Volts = ",0    ; Text for display
,,,
0000009D,0782,mess2,mess2   ADDWF   PCL             ; Set table pointer
0000009E,344B 3465 3479,,        DT      "Key = ",0      ; Text for display
,,,
,,,;-------------------------------------------------------------
,,,
,,,
,,,;----------------------------------------------------------
,,,; INCLUDED ROUTINES
,,,;----------------------------------------------------------
,,,; LCD DRIVER
,,,;       Contains routines:
,,,;       init:   Initialises display
,,,;       onems:  1 ms delay
,,,;       xms:    X ms delay
,,,;               Receives X in W
,,,;       send:   sends a character to display
,,,;               Receives: Control code in W (Select,RS=0)
,,,;                         ASCII character code in W (RS=1)
,,,;
,,,        INCLUDE "LCDIS.INC"
,,,;
,,,;------------------------------------------------------------
,,,;       LCDIS.INC               MPB     19-12-05
,,,;       Include file to operate 16x2 LCD display
,,,;       Uses GPR 70 - 75
,,,;
,,,;------------------------------------------------------------
,,,
,,,Timer1  EQU     70              ; 1ms count register
,,,TimerX  EQU     71              ; Xms count register
,,,Var     EQU     72              ; Output variable
,,,Point   EQU     73              ; Program table pointer
,,,Select  EQU     74              ; Set or clear RS bit
,,,OutCod  EQU     75              ; Temp store for output code
,,,
,,,RS      EQU     1               ; Register select output bit
,,,E       EQU     2               ; Enable clocks display
,,,
,,,
,,,;------------------------------------------------------------
,,,;       1ms delay with 1us cycle time (1000 cycles)
,,,;------------------------------------------------------------
000000A5,30F9,onems,onems   MOVLW   D'249'          ; Count for 1ms delay
000000A6,00F0,,        MOVWF   Timer1          ; Load count
000000A7,0000,loop1,loop1   NOP                     ; Pad for 4 cycle loop
000000A8,0BF0,,        DECFSZ  Timer1          ; Count
000000A9,28A7,,        GOTO    loop1           ; until Z
000000AA,0008,,        RETURN                  ; and finish
,,,
,,,;------------------------------------------------------------
,,,;       Delay Xms
,,,;       Receives count in W, uses Onems
,,,;------------------------------------------------------------
000000AB,00F1,xms,xms     MOVWF   TimerX          ; Count for X ms
000000AC,20A5,loopX,loopX   CALL    onems           ; Delay 1ms
000000AD,0BF1,,        DECFSZ  TimerX          ; Repeat X times
000000AE,28AC,,        GOTO    loopX           ; until Z
000000AF,0008,,        RETURN                  ; and finish
,,,
,,,;------------------------------------------------------------
,,,;       Generate data/command clock siganl E
,,,;------------------------------------------------------------
000000B0,1508,pulseE,pulseE  BSF     LCDport,E       ; Set E high
000000B1,20A5,,        CALL    onems           ; Delay 1ms
000000B2,1108,,        BCF     LCDport,E       ; Reset E low
000000B3,20A5,,        CALL    onems           ; Delay 1ms
000000B4,0008,,        RETURN                  ; done
,,,
,,,;------------------------------------------------------------
,,,;       Send a command byte in two nibbles from RB4 - RB7
,,,;       Receives command in W, uses PulseE and Onems
,,,;------------------------------------------------------------
000000B5,00F5,send,send    MOVWF   OutCod          ; Store output code
000000B6,39F0,,        ANDLW   0F0             ; Clear low nybble
000000B7,0088,,        MOVWF   LCDport         ; Output high nybble
000000B8,18F4,,        BTFSC   Select,RS       ; Test RS bit
000000B9,1488,,        BSF     LCDport,RS      ; and set for data
000000BA,20B0,,        CALL    pulseE          ; and clock display
000000BB,20A5,,        CALL    onems           ; wait 1ms for display
,,,
000000BC,0EF5,,        SWAPF   OutCod          ; Swap low and high
000000BD,0875,,        MOVF    OutCod,W        ; Retrieve output code
000000BE,39F0,,        ANDLW   0F0             ; Clear low nybble
000000BF,0088,,        MOVWF   LCDport         ; Output low nybble
000000C0,18F4,,        BTFSC   Select,RS       ; Test RS bit
000000C1,1488,,        BSF     LCDport,RS      ; and set for data
000000C2,20B0,,        CALL    pulseE          ; and clock display
000000C3,20A5,,        CALL    onems           ; wait 1ms for display
000000C4,0008,,        RETURN                  ; done
,,,
,,,;------------------------------------------------------------
,,,;       Initialise the display
,,,;       Uses Send
,,,;------------------------------------------------------------
000000C5,3064,inid,inid    MOVLW   D'100'          ; Load count for 100ms delay
000000C6,20AB,,        CALL    xms             ; and wait for display start
000000C7,30F0,,        MOVLW   0F0             ; Mask for select code
000000C8,00F4,,        MOVWF   Select          ; High nybble not masked
,,,
000000C9,3030,,        MOVLW   0x30            ; Load initial nibble
000000CA,0088,,        MOVWF   LCDport         ; and output it to display
000000CB,20B0,,        CALL    pulseE          ; Latch initial code
000000CC,3005,,        MOVLW   D'5'            ; Set delay 5ms
000000CD,20AB,,        CALL    xms             ; and wait
000000CE,20B0,,        CALL    pulseE          ; Latch initial code again
000000CF,20A5,,        CALL    onems           ; Wait 1ms
000000D0,20B0,,        CALL    pulseE          ; Latch initial code again
000000D1,1208,,        BCF     LCDport,4       ; Set 4-bit mode
000000D2,20B0,,        CALL    pulseE          ; Latch it
,,,
000000D3,3028,,        MOVLW   0x28            ; Set 4-bit mode, 2 lines
000000D4,20B5,,        CALL    send            ; and send code
000000D5,3008,,        MOVLW   0x08            ; Switch off display
000000D6,20B5,,        CALL    send            ; and send code
000000D7,3001,,        MOVLW   0x01            ; Code to clear display
000000D8,20B5,,        CALL    send            ; and send code
000000D9,3006,,        MOVLW   0x06            ; Enable cursor auto inc
000000DA,20B5,,        CALL    send            ; and send code
000000DB,3080,,        MOVLW   0x80            ; Zero display address
000000DC,20B5,,        CALL    send            ; and send code
000000DD,300C,,        MOVLW   0x0C            ; Turn on display
000000DE,20B5,,        CALL    send            ; and send code
,,,
000000DF,0008,,        RETURN                  ; Done
,,,;------------------------------------------------------------
,,,;
,,,;----------------------------------------------------------
,,,; Convert 8 bits to 3 digit decimal
,,,;
,,,;       Receives 8-bits in W
,,,;       Returns BCD diits in 'huns','tens','ones'
,,,;
,,,        INCLUDE "CONDEC.INC";
,,,;
,,,;-----------------------------------------------------------
,,,; CONDEC.INC    MPB             1-7-05
,,,; Converts 8-bit binary to decimal
,,,; Returns digits in Huns, Tens, Ones registers
,,,;-----------------------------------------------------------
,,,
,,,ADbin   EQU     77      ; Binary input value
,,,Huns    EQU     78      ; Hundreds digit in decimal value
,,,Tens    EQU     79      ; Tens digit in decimal value
,,,Ones    EQU     7A      ; Ones digit in decimal value
,,,
,,,;-----------------------------------------------------------
,,,; Convert input to decimal
,,,
000000E0,00F7,condec,condec  MOVWF   ADbin           ; get ADC result
000000E1,01F8,,        CLRF    Huns            ; zero hundreds digit
000000E2,01F9,,        CLRF    Tens            ; zero Tens digit
000000E3,01FA,,        CLRF    Ones            ; zero Ones digit
,,,
,,,; Calclulate hundreds.......................................
,,,
000000E4,1403,,        BSF     STATUS,C        ; set carry for subtract
000000E5,3064,,        MOVLW   D'100'          ; load 100
000000E6,02F7,sub1,sub1    SUBWF   ADbin           ; and subtract from result
000000E7,0AF8,,        INCF    Huns            ; count number of loops
000000E8,1803,,        BTFSC   STATUS,C        ; and check if done
000000E9,28E6,,        GOTO    sub1            ; no, carry on
,,,
000000EA,07F7,,        ADDWF   ADbin           ; yes, add 100 back on
000000EB,03F8,,        DECF    Huns            ; and correct loop count
,,,
,,,; Calculate Tens digit......................................
,,,
000000EC,1403,,        BSF     STATUS,C        ; repeat process for Tens
000000ED,300A,,        MOVLW   D'10'           ; load 10
000000EE,02F7,sub2,sub2    SUBWF   ADbin           ; and subtract from result
000000EF,0AF9,,        INCF    Tens            ; count number of loops
000000F0,1803,,        BTFSC   STATUS,C        ; and check if done
000000F1,28EE,,        GOTO    sub2            ; no, carry on
,,,
000000F2,07F7,,        ADDWF   ADbin           ; yes, add 100 back on
000000F3,03F9,,        DECF    Tens            ; and correct loop count
000000F4,0877,,        MOVF    ADbin,W         ; load remainder
000000F5,00FA,,        MOVWF   Ones            ; and store as Ones digit
,,,
000000F6,0008,,        RETURN                  ; done
,,,;
,,,;----------------------------------------------------------
,,,; Read selected analogue input
,,,;
,,,;       Receives channel number in W
,,,;       Returns 8-bit input in W
,,,;
,,,        INCLUDE "ADIN.INC"
,,,;
,,,;-----------------------------------------------------------
,,,;       ADIN.INC        MPB     10-1-06
,,,;       Include file to read analogue input
,,,;       Receives channel selection in W
,,,;       Returns 8-bit voltage in W
,,,;-----------------------------------------------------------
,,,
,,,Count   EQU     20              ; Delay count
,,,ADcon   EQU     21              ; ADC control word
,,,Vin     EQU     22              ; Input voltage
,,,
,,,; Setup ADC .................................................
,,,
000000F7,01A1,adin,adin    CLRF    ADcon           ; Zero control bits
000000F8,00A1,,        MOVWF   ADcon           ; load channel number
000000F9,1003,,        BCF     STATUS,C        ; Clear carry flag
000000FA,0DA1,,        RLF     ADcon           ; to position..
000000FB,0DA1,,        RLF     ADcon           ; ...channel select bits
000000FC,3041,,        MOVLW   B'01000001'     ; Analogue input setup code
000000FD,06A1,,        XORWF   ADcon           ; Form control code
000000FE,009F,,        MOVWF   ADCON0          ; f/8, RA0, done, enable
,,,
000000FF,1683 1303,,        BANKSEL ADCON1          ; Bank 1

⌨️ 快捷键说明

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