Last active
September 15, 2015 18:10
-
-
Save marioIncandeza/b9ee58616c906ad7a02f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ORG 000H | |
GOTO INITIALIZE | |
ORG 004H | |
GOTO INCREMENTER | |
INITIALIZE | |
BCF STATUS,RP0 | |
BCF STATUS,RP1 | |
WCOPY EQU 70H ;Since the upper 16 bytes of all GPR banks are common in the PIC16F882/883/884/886/887, | |
STATCOPY EQU 71H ;temporary holding registers, W_TEMP and STATUS_TEMP, should be placed in here. | |
COUNT EQU 72H ;These 16 locations do not require banking and therefore, make it easier to context save and restore. | |
BSF INTCON,GIE | |
BSF INTCON,3 | |
BSF STATUS,RP0 | |
CLRF TRISB | |
COMF TRISB,1 | |
CLRF IOCB | |
COMF IOCB,1 | |
BSF STATUS,RP1 | |
CLRF ANSEL | |
CLRF ANSELH | |
GOTO MAIN | |
MAIN | |
NOP | |
NOP | |
NOP | |
GOTO MAIN | |
INCREMENTER | |
MOVWF WCOPY | |
SWAPF STATUS,W | |
MOVWF STATCOPY | |
BCF STATUS,Z | |
MOVLW 007H | |
XORFW PORTB,0 | |
BTFSC STATUS,Z | |
INCF COUNT,1 | |
SWAPF STATCOPY,W ;I don't know how the swap is working here, but I trust the code in the datasheet | |
MOVWF STATUS | |
SWAPF WCOPY,F | |
SWAPF WCOPY,W | |
RETFIE | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment