Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ISR vector (only TMR0)
- org 4
- movwf isr_w ; Save context
- movfw STATUS
- movwf isr_status
- bcf INTCON, T0IF ; Clear interrupt flag
- rrf rotaryEncoder, w ; Shift old encoder A value to the right
- andlw 01 ; Get rid of extra garbage (incl carry bit)
- movwf rotaryEncoder
- swapf PORTB, w ; Get new encoder A and B (RB5 and RB6)
- andlw 06
- iorwf rotaryEncoder, w ; OR in new values
- movwf rotaryEncoder
- ; Only transisions on A count, B determines which way to go
- addwf PCL, f ; Jump into table
- b ISREncNop
- b ISREncDec
- b ISREncInc
- b ISREncNop
- b ISREncNop
- b ISREncInc
- b ISREncDec
- b ISREncNop
- ISREncNop:
- b ISREncEnd ; Chew up one cycle for equal timing
- ISREncInc:
- incf encoderCount, f
- ISREncEnd:
- movfw isr_status ; Restore context
- movwf STATUS
- swapf isr_w, f
- swapf isr_w, w
- retfie
- ISREncDec:
- decf encoderCount, f
- movfw isr_status ; Restore context
- movwf STATUS
- swapf isr_w, f
- swapf isr_w, w
- retfie
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement