8/20/02 12:36:50 PM, Roman Black wrote: >So if anyone feels like a quickie challenge, >can this 15 cycle code be reduced to 12 cycle code >AND satisfy these: >* must be 8/4 cycles PWM. >* must have minimum 1 inst between write and read. If we can assume that the inputs variable is only accessed outside the loop (i.e. *not* by any interrupt handler that could be activated during the loop): >pwm_loop > ; first output current1 to motor > movf current1,w ; get currents and phase switching > movwf PORTB ; send to motor! > > nop ; > nop ; > nop ; (5 cycles) Drop that last nop. > > ;------------------------- > ; now output current2 > movf current2,w ; > movwf PORTB ; send to motor! > > nop ; let ports settle > nop ; + some delay Drop that last nop. > ; now test input pins > movf PORTA,w ; get pin values from port > movwf inputs ; store in var Drop the movwf > > xorwf inputs_last,w ; xor to compare new inputs with last values > skpnz > goto pwm_loop ; z, inputs not changed, so keep looping > ; (10 cycles) > ;------------------------------------------------- And add (now we're outside the loop): xorwf inputs_last,w movwf inputs -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads