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. :) Scott -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads