Quote Originally Posted by pedja089 View Post
You can set and reset pin using hpwm Ch,0,freq and hpwm Ch,255,freq.
Or just set CCPxCON to 0 and use portx or latx register.
That was my initial thought, so I tried this:

HPWM 1, 255, 250 'Output high
PAUSEUS HPd 'for half the period
HPWM 1, 0, 250 'Output low
PAUSEUS (HPd-120) 'for other half, less ADCIN time

But the results were less than ideal. If I recall correctly I couldn’t get more than 140 Hz using this method. Without changing anything else in my code other than this:

PortB.0 = 1 'Output high
pauseus HPd 'for half the period
PortB.0 = 0 'Output low
Pauseus (Hpd-120) 'for other half, less ADCIN time

The output was smooth through the range.

I’ll try CCP1CON = 0

Thank you,

Gavin