This code has the disadvantage that it is not isochronous -- ie: it doesn't take the same amount of time for each execution. That may or may not be important in the OP's application. Bob Ammerman RAm Systems ----- Original Message ----- From: "Mark Rages" To: "Microcontroller discussion list - Public." Sent: Thursday, May 26, 2005 4:39 PM Subject: Re: [PIC] Indirect file registers, 8 pin software pwm > D'oh! > > scewed it up. > > still untested code follows... > > ; Be careful where this goes in the program space -- > ; the addwf must clear the carry bit... > ; Uses one scratch file, named scratch > > set_bit macro ; bit is in 'w' 0..7 > clrf scratch > bsf scratch,7 > addwf PCL,f > rrf scratch,f ; 0100 0000 > rrf scratch,f ; 0010 0000 > rrf scratch,f ; 0001 0000 > rrf scratch,f ; 0000 1000 > rrf scratch,f ; 0000 0100 > rrf scratch,f ; 0000 0010 > rrf scratch,f ; 0000 0001 > > movfw scratch > iorwf PORTA,f > endm > > clear_bit macro ; bit is in 'w' 0..7 > clrf scratch > bsf scratch,7 > addwf PCL,f > rrf scratch,f ; 0100 0000 > rrf scratch,f ; 0010 0000 > rrf scratch,f ; 0001 0000 > rrf scratch,f ; 0000 1000 > rrf scratch,f ; 0000 0100 > rrf scratch,f ; 0000 0010 > rrf scratch,f ; 0000 0001 > comf scratch,w > andwf PORTA,f > endm > > -- > You think that it is a secret, but it never has been one. > - fortune cookie > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist