The more I read the manuals and techref, the more I lose my intuition. I'm trying to make a simple and short routine to deal with the two *stupid* bits, just in the middle of CCP1CON. The routine must increment de Duty Cycle of the PWM module, when it's called. The limits to avoid rollover are in other routine, so disregard that issue. Any help to correct, erase, or whatever, is well appreciated. Regards, Dennis. I've arrived to this workable code: ;-------------------------------------------- ;takes 17 cycles and 14 for rollover PWMDutyIncr bcf STATUS,RP0 ;All registers are in bank 0 swapf CCP1CON,w ;bits 5:4 ---> 1:0 andlw b'00000011' ;Mask bits 1:0 addlw 0x0D ;set bits 3 and 2 and add 1 btfsc STATUS,DC ;So if 1:0 are set the sum affect DC goto IncrCCPR1L ;If DC is set b1=0 b0=0! the carry must go to ;CCPR1L andlw b'00000011' ;If DC=0, leave w only with bits 1:0 movwf pwmtemp ;I don't know how to do this without an aux. reg. swapf pwmtemp,f ;return the new value to position 5:4 movlw B'11001111' ;erase previous value in CCP1CON 5:4 andwf CCP1CON,F ;copy into CCP1CON without touching movfw pwmtemp ;anything else. iorwf CCP1CON,F ; ;Since results with no carry, return ;is not necessary to update CPR1L IncrCCPR1L movlw 0xFF ;Test if CCPR1L can increment xorwf CCPR1L,W ;If CCPR1L = 0xFF no increment is allowed skpnz ;Rollover Stops here! return ; bcf CCP1CON,CCP1X ;If Carry 5:4 =0 bcf CCP1CON,CCP1Y ; incf CCPR1L,f ;Now Increment CCPR1L return _PWMDutyIncr ;-------------------------------------------- ;takes 16cyles 20 for rollover PWMDutyDecr bcf STATUS,RP0 ;All registers are in bank 0 swapf CCP1CON,w ;bits 5:4 ---> 1:0 andlw b'00000011' ;Mask bits 1:0 movwf pwmtemp ;I don't know how to do this without an aux. reg. decf pwmtemp,F ;decrement btfsc pwmtemp,3 ;rollover? goto DecrCCPR1L ;go Decrement CCPR1L swapf pwmtemp,f ;return the new value to position 5:4 movlw B'11001111' ;erase previous value in CCP1CON andwf CCP1CON,F ;copy into CCP1CON without touching movfw pwmtemp ;anything else. iorwf CCP1CON,F ; ;Since it results with no borrow, return ;is not necessary to update CPR1L DecrCCPR1L movlw b'00000011' ;Mask bits 1:0 andwf pwmtemp,f ;I don't know how to do this without an aux. reg. swapf pwmtemp,f ;return the new value to positio 5:4 movlw B'11001111' ;erase previous value in CCP1CON andwf CCP1CON,F ;copy into CCP1CON without touching movfw pwmtemp ;anything else. iorwf CCP1CON,F ; decf CCPR1L,f return _PWMDutyDecr -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu