Sorry Scott, you were indeed right with your code! I did understand the xor storage of the dif and the recovery associated. Thanks again! :o) -Roman Scott Dattalo wrote: > > On Wed, 21 Aug 2002, Roman Black wrote: > > > > Actually it is. You store the new pins in an XORed > > form. :o) But there is a problem that your code below > > still takes 9 cycles (once goto is included). > > > > Maybe I don't follow. This is what I meant: > > pwm_loop > > ; first output current1 to motor > movf current1,w ; get currents and phase switching > movwf PORTB ; send to motor! > > movf diff,w ; > xorwf inputs_last ; > > ;------------------------- > ; now output current2 > movf current2,w ; > movwf PORTB ; send to motor! > > ; nop ; let ports settle > ; nop ; + some delay > > movf inputs_last,w ; now test input pins > xorwf PORTA,w > movwf diff > > skpnz > goto pwm_loop ; z, inputs not changed, so keep looping > ;------------------------------------------------- > > That has the 4/8 cycle requirement. There's a trick to squeeze in another > instruction and still meet the timing. It's probably obvious, so I won't > bother mentioning it. :) -- 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