> -----Original Message----- > From: Simon-Thijs de Feber [SMTP:stdf23173@YAHOO.CO.UK] > Sent: Tuesday, April 09, 2002 7:01 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC]:PWM > > Hello All, > > Yesterday evening i have been struggling with a PWM > function. > > A char should be loaded with e.g. 0xF0, afterwards > rotated right, and every passing LSB should be put on > a output pin. > > So i did this in CC5x > > led1 = pwm.0; > pwm = pwm >> 1; > > this generates something like > > BTFSS pwm,0 > BCF led1 > BTFSC pwm,0 > BSF led1 > CLR 0x05, C //clear carry > RRF pwm,1 > > The clear carry is not required cause i want a > continues rolling function. > > So i removed the "clear carry" in an inline assembly > block and included that in my code, but that has not > solved the problem. > > any one an idea ? > Yes, you cannot expect the carry bit to contain the previous LSbit of the pwm variable if you are performing any other operations that set/clear the carry flag. What you have to do is preload the carry bit with the LSbit like thisL rrf pwm,w ; move LSbit into carry, pwm unaffected rrf pwm,f ; rotate pwm, carry bit now moved to MSbit Regards Mike -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.