Graham, You might consider to test if the switch is released. In your code the Loop will go on for ever if the switch is pressed. Meening the value in CCPR1L will rapidly go from 0-1-2-...-254-255-0-... Loop btfsc PORTA,0 ; If switch is not pressed goto Loop ; don't worry movlw B'00000001' addwf CCPR1L Loop2 btfss PORTA,0 ; Wait until released goto Loop2 ; Loop goto Loop This will not take care of bounces but I saw other answers on this. Regards Bjarne Nebelong -----Original Message----- From: Graham North [mailto:gs_piclist@HOTMAIL.COM] Sent: Wednesday, February 07, 2001 7:23 PM To: PICLIST@MITVMA.MIT.EDU Subject: [PIC]: PWM problems, HELP! Hi, if you read my last post you will know that I am controlling a motor in a pyrometer. Well I have achieved a PWM output, but am having a few problems. I think the motor is 'sending' (right word?!) some noise to the PIC, I have it running from a seperate supply, but have had to tie the two grounds together because the FET needs the source to be zero volts. I have a diode connected accross the motor, and decoupling caps everywhere! What else can I do? I have also written a piece of code that increases the duty cycle with a switch press connected to PORTA,0 but this does not work. I think it is switch bounce causing this. Is there a way to debounce a switch in S/W? Or is my code rubbish? Main call InitPorts call InitPWM Loop btfsc PORTA,0 ; If switch is not pressed goto Loop ; don't worry movlw B'00000001' addwf CCPR1L goto Loop This code does not take into account the CP1CON,5 and CCP1CON,4 bits. Is there a way to increase the duty cycle in this way, including these bits? Well thats enough questions now, I hope someone can give me some answers. Thanks for your help, Graham North _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.