Isaac Marino Bavaresco wrote: > Em 8/2/2011 22:27, Bob Blick escreveu: > =20 >> On Tue, 08 Feb 2011 23:47 +0000, "Wortinguk" wrote: >> =20 >>> 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 MOSFE= T) >>> 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 = to >>> continue and re-test the current in the next interrupt. Setting RB0 =3D= 0 >>> wont >>> do it. >>> =20 >> 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 >> =20 > > > 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 I usually pass a 0x00 duty cycle to the PWM module. Then turn off Timer2 (or whatever timer is associated with PWM). And then as a final measure, turn off the output pin. --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .