I have a main program that looks something like this:
Main btfsc PORTB,4 call pin_high btfss PORTB,4 call pin_low btfsc condtion1 call routine1 btfsc condtion2 call routine2 btfsc condtion3 call routine4 btfsc condtion5 call routine5 goto main
routine1 do whatever return
routine2 do whatever return
routine3 Etc.
Interupt service routine run some code set condition 1,2,3,4 or 5 flag depending on result retfie
Over all the program works fine BUT if for example the program was at the line in the main routine "btfsc condtion2" when the interupt occurs, when it POPs out of the interupt routine it will return to PC+1. Hence it will end up on "call routine2" and will execute "routine2" even if that condition was not set. ... call routine1 NOP btfsc condtion2 call routine2 ...
Inserting a NOP seems to solve the problem because now it will end up at "btfsc condtion2" when it POPs and will not run the routine unless it's supposed to.
This is a really quick and dirty solution and is floored because the code only has be increased or reduced in size by one instruction for the NOP to be in the wrong place.
Any better suggestions? help please :)
Andy