It appears that If an object is really close to the SRF05 sensor the code will get stuck. I'm thinking this is because an interrupt occurs while i'm waiting for a pulse from the SRF05. since the object is close the pulse is short and ends before the program returns from the interrupt. I've tried to disable interrupts for just that short period of time but that isnt working.
my code looks like this (if you'd like to see more just ask)
bcf INTCON,GIE ;temporarily disable interrupts
SRF_wait:
btfss LATA,1 ;check if pin A1 has goine high
goto SRF_wait ;when pin A1 goes high the loop will exit
bsf INTCON,GIE ; re-enable interrupts
The problem i'm having is with the two lines of code seen in bold. without them it only has the minor problem with close objects. with thenm the code seems to stall all the time.