I wrote a small quadrature encoder interface using RB4-7 (ifi interrupt 3-6) and ran across a problem that doesnt appear to be addressed in your code: If you call a subroutine from an interrupt handler, you need to save additional stuff. You can find this in the C compiler in section 2.9 (something) or on the quick reference card. You need to replace
#pragma interrupt InterruptHandlerLow
with
#pragma interruptlow InterruptHandlerLow save=section(".tmpdata")
For more info, see below:
http://www.chiefdelphi.com/forums/sh...91&postcount=4