User manual

00066_MCP402XEV.ASM Source Code
© 2005 Microchip Technology Inc. DS51546B-page 39
;***********************************************************************************************
; High Voltage Increment & Decrement Subroutines
;***********************************************************************************************
HV_Increment_WL_Disable
movwf Exit ; load the loop counter
bsf UD
goto $+1 ; creates a 3us total delay
bsf HV_CS ; starts 1Mhz Charge Pump
movlw .100 ; 5*100 = 500us delay for Charge Pump ramp time
movwf DLYCNT1
DLOOP_HVI
clrwdt ;or NOP
nop
decfsz DLYCNT1,f
goto DLOOP_HVI
HV_IncrLoop
bcf UD
goto $+1 ; creates a 3us total delay
bsf UD
goto $+1 ; creates a 3us total delay
decfsz Exit,f ; Have we incremented the wiper enough?
goto HV_IncrLoop
bcf HV_CS ; shut off 1Mhz Charge Pump
bcf CS ; helps pull the signal down from HV
goto $+1
bsf CS
retlw 0x02 ; Follow w/long delay to discharge pump & EEPROM Write Cycle
HV_Decrement_WL_Disable
movwf Exit ; load the loop counter
bcf UD
goto $+1 ; creates a 3us total delay
bsf HV_CS ; starts 1Mhz Charge Pump
movlw .100 ; 5*100 = 500us delay for Charge Pump ramp time
movwf DLYCNT1
DLOOP_HVD
clrwdt ;or NOP
nop
decfsz DLYCNT1,f
goto DLOOP_HVD
HV_DecrLoop
bsf UD
goto $+1 ; creates a 3us total delay
bcf UD
goto $+1 ; creates a 3us total delay
decfsz Exit,f ; Have we decremented the wiper enough?
goto HV_DecrLoop
bcf HV_CS ; shut off 1Mhz Charge Pump
bcf CS ; helps pull the signal down from HV
goto $+1
bsf CS
retlw 0x03 ; Follow w/long delay to discharge pump & EEPROM Write Cycle
HV_Increment_WL_Enable
bsf UD
goto $+1 ; creates a 3us total delay
bsf HV_CS ; starts 1Mhz Charge Pump
movlw .100 ; 5*100 = 500us delay for Charge Pump ramp time
movwf DLYCNT1
TABLE E-1: 00066_MCP402XEV.ASM SOURCE CODE (CONTINUED)