User manual

00066_MCP402XEV.ASM Source Code
© 2005 Microchip Technology Inc. DS51546B-page 37
S13_10 retlw .0 ; shouldn’t be here, reset state
S13_11 retlw .0 ; shouldn’t be here, reset state
S14_00 retlw .0 ; shouldn’t be here, reset state
S14_01 retlw .0 ; shouldn’t be here, reset state
S14_10 retlw .0 ; shouldn’t be here, reset state
S14_11 retlw .0 ; shouldn’t be here, reset state
S15_00 retlw .0 ; shouldn’t be here, reset state
S15_01 retlw .0 ; shouldn’t be here, reset state
S15_10 retlw .0 ; shouldn’t be here, reset state
S15_11 retlw .0 ; shouldn’t be here, reset state
PerformState
movf State,w
andlw b’00001111’ ; mask all states >15
addwf PCL,f ; jump to desired State
retlw .0 ; State 0, no action
goto State1 ; (2s for repeating LV increment)
goto State2 ; (2s for repeating LV decrement)
goto State3
goto State4
goto State5 ; (2s for repeating HV increment)
goto State6 ; (2s for repeating HV decrement)
retlw .7 ; State 7, no action
retlw .8 ; State 8, no action
retlw .9 ; State 9, no action
retlw .10 ; State 10, no action
goto State11
goto State12
goto State13
goto State14
goto StateMachineReset ; State 15... shouldn’t be here
;***********************************************************************************************
InitGPIO
movlw b’00001011’ ; initialize UP and DOWN switches to be high & CP to be low.
movwf GPIO
movlw b’11111100’ ; make GP0/DECR/CS & GP1/INCR/UD outputs, block undesired U/D commands
tris GPIO
retlw b’11000000’
GPIO_TestUP
movlw b’00001011’ ; initialize UP and DOWN switches to be high & CP to be low.
movwf GPIO
movlw b’11111100’ ; make both GP0/DECR/CS & GP1/INCR/UD outputs, prevent undesired U/D
commands
tris GPIO
movlw b’11111110’ ; make GP1/INCR/UD an input (w/pu enabled)
tris GPIO
retlw b’10000000’
GPIO_TestDOWN
movlw b’00001011’ ; initialize UP and DOWN switches to be high & CP to be low.
movwf GPIO
movlw b’11111100’ ; make both GP0/DECR/CS & GP1/INCR/UD outputs, prevent undesired U/D
commands
tris GPIO
movlw b’11111101’ ; make GP0/DECR/CS an input (w/pu enabled)
tris GPIO
retlw b’01000000’
TABLE E-1: 00066_MCP402XEV.ASM SOURCE CODE (CONTINUED)