> >>> 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 flowi= ng > >>> to > >>> see if there is an overcurrent. (1 ohm resistor in ground side of MOS= FET) > >>> This currently drives an LED if an overcurrent. > >>> > >>> But cant get my head around a method to tempory collapse the PWM outp= ut > >>> voltage if there is an over current condition and allow the PWM perio= d to > >>> 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 o= f > >> 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 i= s > >> 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 fro= m. > >> 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 > > pin at the last state set by the PWM controller. Sometimes it stopped a= t > > "1". To turn it off I needed also explicitly clearing the pin. Hmm, haven't been following this thread, but I wonder if you should really = be using a small PIC24 or other chip where the CCP is designed for motor co= ntrol, and has pins that accept over current signal inputs and deal with th= e CCP output appropriately. The difference in chip cost is not that large. --=20 Scanned by iCritical. --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .