📄 z.txt
字号:
return
Screen2
; display the fan percentages
movf DutyCycle0,W
call VFDdecimal
movlw H'25'
call VFDbyte
movf DutyCycle1,W
call VFDdecimal
movlw H'25'
call VFDbyte
movf DutyCycle2,W
call VFDdecimal
movlw H'25'
call VFDbyte
movf DutyCycle3,W
call VFDdecimal
movlw H'25'
call VFDbyte
VFDNEWLINE ; takes us to the next line
movf DutyCycle4,W
call VFDdecimal
movlw H'25'
call VFDbyte
movf DutyCycle5,W
call VFDdecimal
movlw H'25'
call VFDbyte
movf DutyCycle6,W
call VFDdecimal
movlw H'25'
call VFDbyte
movf DutyCycle7,W
call VFDdecimal
movlw H'25'
call VFDbyte
return
Screen3
movlw _Desired-Message_Start
call DisplayC
movf DESIREDTEMP,W
call VFDdecimal
DEGREES
movlw _Info2-Message_Start
call DisplayC
return
Screen4
MOVLF 0,SCREENNUM
goto Screen1
return
;;;;;;;;DisplayC subroutine;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; This subroutine is called with W containing the offset from CDS to the
; beginning of the desired constant display string. It uses a one-byte LCD_TEMP
; to the next byte in the display string
DisplayC
movwf DIS_TEMP ;Save pointer
call DisplayC_Table ;Get byte from string into W
incf DIS_TEMP,F ;Point to the next byte
movwf TEMP
bcf PORTA,3 ;Drive RS pin low for cursor positioning code
bcf PORTA,4 ;Drive R/~W low for writing
bsf PORTA,5
MOVFF TEMP,PORTB ;Position Code
bcf PORTA,5
bsf PORTA,3 ;Drive RS high for Character writing
DisplayC_1
call DisplayC_Table ;Get byte from string into W
incf DIS_TEMP,F ;Point to the next byte
iorlw 0 ;Set Z if end of string
btfsc STATUS,Z ;if not, then go on
goto DisplayC_done
movwf TEMP
bsf PORTA,5 ;Strobe E
movwf PORTB ;Write byte
bcf PORTA,5 ;Strobe E
goto DisplayC_1
DisplayC_done
return
;;;; VFDReset ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; reset the vfd, clears the display, and sets the cursor to 0.
VFDReset
bcf PORTA,3
bcf PORTA,4
bsf PORTA,5
MOVLF H'80',PORTB
bcf PORTA,5
bsf PORTA,5
MOVLF H'01',PORTB
bcf PORTA,5
bsf PORTA,3
call LoopTime
call LoopTime
call LoopTime
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;
VFDdecimal
call HexToDecimal
movf Digit2,W ;Output '1', ' ', or '-'
call VFDbyte
movf TempX,W
call VFDdebug
return
;;;; VFDdebug ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; sends W out onto the VFD
VFDdebug
movwf TEMP
swapf TEMP,W
call Hex2Ascii
call VFDbyte ; send it out
movf TEMP,W
call Hex2Ascii
call VFDbyte ; send it out
movf TEMP,W
return
;;; VFDbyte ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; send byte to VFD
VFDbyte
bsf PORTA,5
movwf PORTB
bcf PORTA,5
return
;;;;;; DisplayT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; display the strings on the terminal
; just like DisplayC
DisplayT
movwf DIS_TEMP
DisplayT_1
call DisplayC_Table
incf DIS_TEMP,F
iorlw 0 ; changes z bit
btfsc STATUS,Z
goto DisplayT_done
call TXbyte
goto DisplayT_1
DisplayT_done
return
;;;;;;; SendDebug ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; put a byte in W then call this to send it out over the USART
SendDebug
movwf TEMP
swapf TEMP,W
call Hex2Ascii
call TXbyte
movf TEMP,W
call Hex2Ascii
call TXbyte
movf TEMP,W
return
;;;;;;; TXbyte ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; w is to be sent out over USART
TXbyte
TXloop
btfss PIR1,TXIF
goto TXloop
movwf TXREG
TXEnd
return
;;;;;;; RCbyte ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; W is received over the USART
RCbyte
RCloop
btfss PIR1,RCIF
goto RCloop
movf RCREG,W
RCEnd
return
;;;;;;; EchoServer ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; spits back whatever is on the receive line leaving RCREG in W
Echo
call RCbyte
call TXbyte
return ; this keeps the received byte in W
;;;;;;; LoopTime subroutine ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; This subroutine waits for Timer2 to complete its ten millisecond count
; sequence.
LoopTime
btfss PIR1,TMR2IF ;Check whether ten milliseconds are up
goto LoopTime
bcf PIR1,TMR2IF ;Clear flag
return
;;;; I2C Subroutines ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;taken directly from John Peatman's PIC microcontroller book
; http://www.picbook.com
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I2Cout
call Start
movf DEVADD,W
call TX
movf INTADD,W
call TX
movf DATAOUT,W
call TX
call Stop
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I2Cin
call Start
movf DEVADD,W
call TX
movf INTADD,W
call TX
call ReStart
movf DEVADD,W
iorlw B'00000001'
call TX
bsf TXBUFF,7
call RX
movwf DATAIN
call Stop
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Start
movlw B'00111011'
movwf SSPCON
bcf PORTC,SDA
bcf PORTC,SCL
movlw TRISC
movwf FSR
ReStart
bsf INDF,SDA
bsf INDF,SCL
delay 0,1,2
bcf INDF,SDA
delay 0,1,2
bcf INDF,SCL
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Stop
bcf INDF,SDA
bsf INDF,SCL
delay 0,1,2
bsf INDF,SDA
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TX
movwf TXBUFF
bsf STATUS,C
TX_1
rlf TXBUFF,F
movf TXBUFF,F
btfss STATUS,Z
call BitOut
btfss STATUS,Z
goto TX_1
call BitIn
movlw B'00000001'
andwf RXBUFF,W
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
RX
movlw B'00000001'
movwf RXBUFF
RX_1
rlf RXBUFF,F
call BitIn
btfss STATUS,C
goto RX_1
rlf TXBUFF,F
call BitOut
movf RXBUFF,W
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BitOut
bcf INDF,SDA
btfsc STATUS,C
bsf INDF,SDA
bsf INDF,SCL
nop
nop
nop
nop
nop
nop
delay 0,1,2
bcf INDF,SCL
bcf STATUS,C
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BitIn
bsf INDF,SDA
bsf INDF,SCL
nop
nop
nop
nop
nop
nop
bcf RXBUFF,0
btfsc PORTC,SDA
bsf RXBUFF,0
bcf INDF,SCL
return
;;;;;;; IntService interrupt service routine ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; This interrupt service routine fields all interrupts. It first sets aside W
; and STATUS. It assumes that direct addressing will not be used in the
; mainline code to access Bank 1 addresses (once the Initial subroutine has
; been executed and interrupts enabled). It polls each possible interrupt
; source to determine whether it needs service.
IntService
; Set aside W and STATUS
movwf W_TEMP ;Copy W to RAM
swapf STATUS,W ;Move STATUS to W without affecting Z bit
movwf STATUS_TEMP ;Copy to RAM (with nibbles swapped)
; Execute polling routine
Poll
btfsc PIR1,CCP1IF ;Test RCIF flag
goto CCP1Handler
; Restore STATUS and W and return from interrupt
swapf STATUS_TEMP,W ;Restore STATUS bits (unswapping nibbles)
movwf STATUS ; without affecting Z bit
swapf W_TEMP,F ;Swap W_TEMP
swapf W_TEMP,W ; and swap again into W without affecting Z bit
retfie ;Return from mainline code; reenable interrupts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Handlers
CCP1Handler
bcf PIR1,CCP1IF ; clear the interrupt flag
btfsc CCP1CON,0 ; skip if looking for falling edge
goto DetectRisingEdge
SUB1616 FSPEED0H,FSPEED0L,CCPR1H,CCPR1L,FSPEED1H,FSPEED1L
bsf CCP1CON,0 ; interrupt on rising edge
goto Poll
DetectRisingEdge
MOVFF CCPR1H,FSPEED0H
MOVFF CCPR1L,FSPEED0L
bcf CCP1CON,0 ; interrupt on falling edge
goto Poll
;;;;; HexToDecimal Subroutines ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Justin Domnitz, April 16, 2000
;
HexToDecimal
; TempX value has been passed in as W
; Is TempX > 99 C?
movwf TempX
btfsc TempX,7
goto LessThan0
movlw 100
subwf TempX, F ; Subtract 100 from W
btfss STATUS, C ; If carry bit is 1 skip next instruction b/c TempX > 99.
goto LessThan100
goto GreaterThan99
GreaterThan99 ; TempX > 99 C So...
MOVLF H'31', Digit2 ; Set Digit2 = '1'
goto RestOfNumber
LessThan100 ; TempX < 99 C So...
movlw 100
addwf TempX, F
MOVLF H'20', Digit2 ; Set Digit2 = ' '
goto RestOfNumber
LessThan0 ; TempX < 0 C So...
MOVLF H'2D', Digit2 ; Set Digit2 = '-'
TWOCOMP TempX
goto RestOfNumber
RestOfNumber
MOVLF 0, Digit1 ; Initialize Digit1 to 0.
MOVLF 0, Digit0 ; Initialize Digit0 to 0.
TensDigitLoop
MOVFF TempX, Digit0
movlw 10 ; Put 10 into W.
subwf TempX, F ; Subtract 10 from TempX
btfss STATUS, C ; If carry bit is 1 skip next instruction b/c TempX > 10.
goto OnesDigit
incf Digit1, F ; Increment tens digit.
goto TensDigitLoop
OnesDigit
MOVFF Digit1, TempX ; Store tens digit in lower nibble of TempX.
swapf TempX, W ; Put tens digit into upper nibble of W.
iorwf Digit0, W ; Or W (TempX) with Digit0.
movwf TempX
return
;
; Justin Domnitz, April 16, 2000
;
;;;;; HexToDecimal Subroutines ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
end
;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -