Well let's see what we can do here ...
Since it's an 18F, with "qualified" ASM handlers ...
You can remove the remaining overhead by removing DT_INTS all together, and using an ASM ISR, written in PBP of course.
Something like this ...Setpoint is handled as a LONG, but if you can use a BYTE sized result, you can change it to Setpoint.byte0 to reduce it by a few instructions.Code:DEFINE INTHAND _ISR DEFINE NO_CLRWDT 1 ;--------------------------------------------------------------------------- ISR: IF INTCON3.1 THEN ' IF INT2 triggered DoStep: If PortB.1 = 1 THEN 'Direction signal connected to PortB.1 Setpoint = Setpoint + 1 'Setpoint is a 32bit variable ELSE Setpoint = Setpoint - 1 ENDIF INTCON3.1 = 0 ' clear the int flag ENDIF RollOver: IF PIR3.2 = 1 THEN ' if IC2QEIF triggered IF QEICON.5 = 1 then Position.Word1 = Position.Word1 + 1 'Position is a LONG ELSE Position.Word1 = Position.Word1 - 1 ENDIF PIR3.2 = 0 ' clear the int flag ENDIF @ RETFIE FAST ; return from interrupt with shadow regs
The NO_CLRWDT drops a couple more instructions, but make sure the WDT is OFF.
Compiled, it looks like this, including both handlers ...Hope that gets it closer.Code:_ISR btfss INTCON3, 001h goto _RollOver _DoStep btfss PORTB, 001h goto L00003 incf _Setpoint, F clrf WREG addwfc (_Setpoint) + 1, F addwfc (_Setpoint) + 2, F addwfc (_Setpoint) + 3, F goto L00004 L00003 decf _Setpoint, F clrf WREG subwfb (_Setpoint) + 1, F subwfb (_Setpoint) + 2, F subwfb (_Setpoint) + 3, F L00004 bcf INTCON3, 001h _RollOver btfss PIR3, 002h goto L00005 btfss QEICON, 005h goto L00007 incf _Position??WORD1, F movlw 0 addwfc (_Position??WORD1) + 1, F goto L00008 L00007 decf _Position??WORD1, F movlw 0 subwfb (_Position??WORD1) + 1, F L00008 bcf PIR3, 002h L00005 RETFIE FAST ; return from interrupt with shadow regs




Bookmarks