Using Nop() instructions to create short accurate timer
dsPIC33EP256MU806 & XC16 (v1.33)
I've got a synchronous delay function to stall the uC if required. Normally it creates a HW Timer, waiting on the ISR, but that is a bit verbose as I set up data structures to manage that. So if the timer is suitably short there's no point in creating a HW Timer and you might as well calculate a number of Nop(); instructions and do those before returning to the caller.
That all sounds fine and dandy but the compiler is ignoring, or appears to be ignoring, my code. So if I put 4 Nop(); instructions in a function I get a delay of X. If I now double the number of Nop(); Instructions I still get exactly the same delay.
I suppose this is a case of looking at the disassembly for the code. Man it's going to be one of those days.