TA的每日心情 | 开心 2021-11-21 03:33 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
WREEA ;写EEPROM A,TEMP传送写入数据
BCF STATUS,RP0 ;取BANK0
MOVF EEADDRA,W ;取A地址
BSF STATUS,RP0 ;取BANK1
MOVWF EEADR ;A地址进入EEADR
BCF STATUS,RP0 ;取BANK0
MOVF TEMP,W ;取写入数据
BSF STATUS,RP0 ;取BANK1
MOVWF EEDATA ;待写数据进入EEDATA
BSF EECON1,WREN
BCF INTCON,GIE
MOVLW 55H
MOVWF EECON2
MOVLW 0AAH
MOVWF EECON2
BSF EECON1,WR
BSF INTCON,GIE
BCF STATUS,RP0
WWRA BTFSS PIR1,EEIF
GOTO WWRA
CLRF PIR1
RETURN
;----------------------------------------------------------
WREEB ;写EEPROM B,TEMP传送写入数据
BCF STATUS,RP0 ;取BANK0
MOVF EEADDRB,W ;取B地址
BSF STATUS,RP0 ;取BANK1
MOVWF EEADR ;B地址进入EEADR
BCF STATUS,RP0 ;取BANK0
MOVF TEMP,W ;取写入数据
BSF STATUS,RP0 ;取BANK1
MOVWF EEDATA ;待写数据进入EEDATA
BSF EECON1,WREN
BCF INTCON,GIE
MOVLW 55H
MOVWF EECON2
MOVLW 0AAH
MOVWF EECON2
BSF EECON1,WR
BSF INTCON,GIE
BCF STATUS,RP0
WWRB BTFSS PIR1,EEIF
GOTO WWRB
CLRF PIR1
RETURN
;----------------------------------------------------------
WREEC ;写EEPROM C,TEMP传送写入数据
BCF STATUS,RP0 ;取BANK0
MOVF EEADDRC,W ;取C地址
BSF STATUS,RP0 ;取BANK1
MOVWF EEADR ;B地址进入EEADR
BCF STATUS,RP0 ;取BANK0
MOVF TEMP,W ;取写入数据
BSF STATUS,RP0 ;取BANK1
MOVWF EEDATA ;待写数据进入EEDATA
BSF EECON1,WREN
BCF INTCON,GIE
MOVLW 55H
MOVWF EECON2
MOVLW 0AAH
MOVWF EECON2
BSF EECON1,WR
BSF INTCON,GIE
BCF STATUS,RP0
WWRC BTFSS PIR1,EEIF
GOTO WWRC
CLRF PIR1
RETURN
;----------------------------------------------------------
WREEG ;写EEPROM B,TEMP传送写入数据
BCF STATUS,RP0 ;取BANK0
MOVF EEADDRG,W ;取B地址
BSF STATUS,RP0 ;取BANK1
MOVWF EEADR ;B地址进入EEADR
BCF STATUS,RP0 ;取BANK0
MOVF TEMP,W ;取写入数据
BSF STATUS,RP0 ;取BANK1
MOVWF EEDATA ;待写数据进入EEDATA
BSF EECON1,WREN
BCF INTCON,GIE
MOVLW 55H
MOVWF EECON2
MOVLW 0AAH
MOVWF EECON2
BSF EECON1,WR
BSF INTCON,GIE
BCF STATUS,RP0
WWRG BTFSS PIR1,EEIF
GOTO WWRG
CLRF PIR1
RETURN
;----------------------------------------------------------
WREECC ;写EEPROM CC,TEMP传送写入数据
BCF STATUS,RP0 ;取BANK0
MOVF EEADDRCC,W ;取CC地址
BSF STATUS,RP0 ;取BANK1
MOVWF EEADR ;CC地址进入EEADR
BCF STATUS,RP0 ;取BANK0
MOVF TEMP,W ;取写入数据
BSF STATUS,RP0 ;取BANK1
MOVWF EEDATA ;待写数据进入EEDATA
BSF EECON1,WREN
BCF INTCON,GIE
MOVLW 55H
MOVWF EECON2
MOVLW 0AAH
MOVWF EECON2
BSF EECON1,WR
BSF INTCON,GIE
BCF STATUS,RP0
WWRCC BTFSS PIR1,EEIF
GOTO WWRCC
CLRF PIR1
RETURN
;----------------------------------------------------------
WREEH ;写EEPROM H,TEMP传送写入数据
BCF STATUS,RP0 ;取BANK0
MOVF EEADDRH,W ;取H地址
BSF STATUS,RP0 ;取BANK1
MOVWF EEADR ;H地址进入EEADR
BCF STATUS,RP0 ;取BANK0
MOVF TEMP,W ;取写入数据
BSF STATUS,RP0 ;取BANK1
MOVWF EEDATA ;待写数据进入EEDATA
BSF EECON1,WREN
BCF INTCON,GIE
MOVLW 55H
MOVWF EECON2
MOVLW 0AAH
MOVWF EECON2
BSF EECON1,WR
BSF INTCON,GIE
BCF STATUS,RP0
WWRH BTFSS PIR1,EEIF
GOTO WWRH
CLRF PIR1
RETURN
;----------------------------------------------------------
WREEI ;写EEPROM I,TEMP传送写入数据
BCF STATUS,RP0 ;取BANK0
MOVF EEADDRI,W ;取I地址
BSF STATUS,RP0 ;取BANK1
MOVWF EEADR ;I地址进入EEADR
BCF STATUS,RP0 ;取BANK0
MOVF TEMP,W ;取写入数据
BSF STATUS,RP0 ;取BANK1
MOVWF EEDATA ;待写数据进入EEDATA
BSF EECON1,WREN
BCF INTCON,GIE
MOVLW 55H
MOVWF EECON2
MOVLW 0AAH
MOVWF EECON2
BSF EECON1,WR
BSF INTCON,GIE
BCF STATUS,RP0
WWRI BTFSS PIR1,EEIF
GOTO WWRI
CLRF PIR1
RETURN
;----------------------------------------------------------
SOSDEY MOVLW 0D8H ;外循环常数
MOVWF DELY1 ;外循环寄存器
SOSDE0 MOVLW 0FFH ;中循环常数
MOVWF DELY2 ;中循环寄存器
SOSDE1 DECFSZ DELY2,F ;中循环寄存器递减
GOTO SOSDE1 ;继续中循环
DECFSZ DELY1,F ;外循环寄存器递减
GOTO SOSDE0 ;继续外循环
RETURN
;----------------------------------------------------------
DELAY10US
NOP
NOP
NOP
NOP
RETURN
;----------------------------------------------------------
DELAY500MS
MOVLW 03H ;外循环常数
MOVWF DELY1 ;外循环寄存器
LP110
MOVLW 0EBH ;中循环常数
MOVWF DELY2 ;中循环寄存器
LP210
MOVLW 0EBH ;内循环常数
MOVWF DELY3 ;内循环寄存器
LP310
DECFSZ DELY3 ;内循环寄存器递减
GOTO LP310 ;继续内循环
DECFSZ DELY2 ;中循环寄存器递减
GOTO LP210 ;继续中循环
DECFSZ DELY1 ;外循环寄存器递减
GOTO LP110 ;继续外循环
RETURN
;----------------------------------------------------------
DELAY166MS
MOVLW 01H ;外循环常数
MOVWF DELY1 ;外循环寄存器
LP330
MOVLW 0EFH ;中循环常数
MOVWF DELY2 ;中循环寄存器
LP331
MOVLW 0FCH ;内循环常数
MOVWF DELY3 ;内循环寄存器
LP332 CLRWDT
DECFSZ DELY3 ;内循环寄存器递减
GOTO LP332 ;继续内循环
DECFSZ DELY2 ;中循环寄存器递减
GOTO LP331 ;继续中循环
DECFSZ DELY1 ;外循环寄存器递减
GOTO LP330 ;继续外循环
RETURN
;----------------------------------------------------------
DELAY100MS
MOVLW 90H
MOVWF DELY1
L100MS2
MOVLW 0E6H
MOVWF DELY2
L100MS1
DECFSZ DELY2,F
GOTO L100MS1
DECFSZ DELY1,F
GOTO L100MS2
RETURN
;----------------------------------------------------------
DELAY10MS
MOVLW 0BH
MOVWF DELY1
L33MS2
MOVLW 0E6H
MOVWF DELY2
L33MS1 CLRWDT
DECFSZ DELY2,F
GOTO L33MS1
DECFSZ DELY1,F
GOTO L33MS2
RETURN
;----------------------------------------------------------
MIDLIGHT
MOVLW 40H
MOVWF DELY1
DL0 MOVLW 0FFH
MOVWF DELY2
CLRF TEMP1
DL1 DECFSZ DELY2
GOTO DL1
MOVF TEMP1
BTFSS STATUS,Z
GOTO DS1
BCF GPIO,00H
COMF TEMP1
DS0 DECFSZ DELY1
GOTO DL0
BCF GPIO,00H
RETURN
DS1 BSF GPIO,00H
CLRF TEMP1
GOTO DS0
;----------------------------------------------------------
DELAY50MS
MOVLW 48H
MOVWF DELY1
L50MS2
MOVLW 0E6H
MOVWF DELY2
L50MS1
DECFSZ DELY2,F
GOTO L50MS1
DECFSZ DELY1,F
GOTO L50MS2
RETURN
;----------------------------------------------------------
DELAY30MS
MOVLW 30H
MOVWF DELY1
L30MS2
MOVLW 0E6H
MOVWF DELY2
L30MS1
DECFSZ DELY2,F
GOTO L30MS1
DECFSZ DELY1,F
GOTO L30MS2
RETURN
;----------------------------------------------------------
END |
|