You have turned off the WDT (for speed I suppose) but forgot to tell PBP about it so no speed gained.
Anyway, try this as your encoder logic and see if it beats 26us.
Code:
New_Encoder VAR BYTE
Old_Encoder VAR BYTE
Test VAR BYTE
Enc1_counter VAR WORD
BlinkLED1 VAR LatB.5 ' Switch these ON/OFF to determine time
BlinkLED2 VAR LatB.4
MainLoop:
BlinkLED1 = 1 ' Top of LOOP on Logic 2 probe
BlinkLED2 = 0
New_Encoder = PortA & %00000011 ' Read encoder signals on RA0 and RA1
Test = New_Encoder ^ Old_Encoder ' Bitwise XOR current state with previous state to see if any pins changed.
IF Test.0 = 1 THEN ' Edge detected on channel A?
IF Old_Encoder.0 ^ Old_Encoder.1 THEN ' If Old_Encoder is 0 or 3 we count up, otherwise we count down.
Enc1_counter = Enc1_counter + 1
ELSE
Enc1_counter = Enc1_counter - 1
ENDIF
GOTO MainLoop
ENDIF
IF Test.1 = 1 THEN ' Edge detected on channel B?
IF Old_Encoder.0 ^/ Old_Encoder.1 THEN ' If Old_Encoder is 1 or 2 we count up, otherwise we count down.
Enc1_counter = Enc1_counter + 1
ELSE
Enc1_counter = Enc1_counter - 1
ENDIF
Goto MainLoop
ENDIF
BlinkLED1 = 0 ' Bottom of IFs on Logic 2 probe
BlinkLED2 = 1
' Other stuff here...
Goto MainLoop
EDIT: Oh, the timing measurment will not work properly since we're jumping back to mainloop before flipping the LEDs but you can fix that.
Bookmarks