Em 8/2/2011 22:27, Bob Blick escreveu: > > On Tue, 08 Feb 2011 23:47 +0000, "Wortinguk" wrote: >> I have a 16F88 project in need of advise. >> PWM output on CCP1 on RB0 drives a MOSFET to drive a motor. >> RB0/INT interrupt is enabled (on rising edge) >> The interrupt service routine does an adc sample of the current flowing >> to >> see if there is an overcurrent. (1 ohm resistor in ground side of MOSFET= ) >> This currently drives an LED if an overcurrent. >> >> But cant get my head around a method to tempory collapse the PWM output >> voltage if there is an over current condition and allow the PWM period t= o >> continue and re-test the current in the next interrupt. Setting RB0 =3D = 0 >> wont >> do it. > Hi Dave, > > A few things come to mind. I don't have the 16F88 datasheet in front of > me, so any of these could be wrong. But it is worth checking out: > > 1.Setting TRIS for the pin that PWM is coming out from. I think TRIS is > after the PWM circuitry so this might work. > 2.Setting TMR2 to some number higher than PR2 and stopping it. > 3.Setting CCPR1H to some number. > 4.AND-ing the PWM in hardware with the pin you are driving the LED from. > 5.Temporarily turning off PWM in CCP1CON. > 6.Setting PR2 to 0? Or does that only work on the next cycle? > > Cheers, > > Bob In an old project with PIC16F628, just turning off the CCP1CON left the=20 pin at the last state set by the PWM controller. Sometimes it stopped at "1". To turn it off I needed also explicitly clearing the pin. Isaac __________________________________________________ Fale com seus amigos de gra=E7a com o novo Yahoo! Messenger=20 http://br.messenger.yahoo.com/=20 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .