Quote Originally Posted by Acetronics View Post
The only way I see to keep ( is it really necessary ??? Good Q.) a "neat" PWM output would be to switch between HPWM, to the last produced fixed freq. and duty, soft PWM ... while disabling CCP, changing Dutycycle and re-enabling the CCP.
The circuit Im using controls the feedback node of a switcher which its used to drive a power LED, any small glitch in the duty cycle is "visible" in the light output.

What puzzles me is the minute I stop using the ADCIN command, all the problems dissapear:

if calibrapin=0 then
ADCIN 1, pote
endif

if I put this calibrapin to 1 the output is steady. When it was bedtime yesterday (yes I keep thinking about problems in bed ), I tought: why not use software PWM, that may solve this issue. Well seeing it was suggested here too, makes me want to try it and I will

Regarding the DS section 11.3.3: "The PWM module may generate a premature pulse when changing the duty cycle."

Its the MAY word that puzzles me, I would expect more certainty here.

I still need to test Mister E suggestion, and speaking of it:

mm, you didn't disable the analog comparator.. maybe it worth to do it first?
In fact Im using the internal comparator, thats why I didnt disable it, if you check my 1st code post you will see:
vrcon = %10001010 ' set vref=2.25v

I need to put this value there so I can get more samples from my limited range sensor.

Also I tough it may be simply a reading problem, but this wasnt the case, I filled the available eeprom space with the read values and they were steady.

THANKS for the help guys! Back to the protoboard!


Pablo