Wouter van Ooijen wrote: > > I think I have a 10-instruction solution. > > That was too optimistic, I think 15 might be more like it. Still > struggling. No other takers? I came up with a 12-instruction solution, but didn't post because it wasn't less than 10. The key is to have two comparison loops. I'm assuming that interrupts won't lock you out long enough to miss an exact match on the high byte of the timer. ; wait for an exact match on the high byte loop1: movf tmr1h, w xorwf t1h, w btfss status, z goto loop1 ; wait for low byte of timer >= low byte of trigger value (unsigned ; comparison), or for high byte to increment, which catches cases ; like when the trigger value is xxFF and the low byte of the timer ; appears to skip from FE to 00 because of an interrupt. loop2: movf tmr1l, w subwf t1l, w btfsc status, c goto done movf tmr1h, w xorwf t1h, w btfsc status, z goto loop2 done: -- Dave Tweed -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics