HPWM and A to D interaction question 18F252
PIC18F252 with HPWM on C2... 20 Mhz osc.
Using A0 and A1 as analog input with internal 5 volt ref.
Fixed low Z analog input for testing.
All power is stable
HPWM 1,{0 to 255},17000
As I change the duty cycle of the HPWM my A to D results jump +/- 10 counts or so
If I delete the HPWM the A to D count is stable +/- 1 count
This holds true even when there is no load on the C2 PWM output.
What resources does the PB HPWM statement use that would affect the A to D function?
My code changes the HPWM duty cycle between each A to D read... If I do not change the HPWM duty cycle and hold it constant, The A to D result is stable.
Has anyone seen this on the 18F252?
tcbcats
Have you tried changing the sampling frequency?
Hi,
According to you when your CCP pin is floating (there is no load connected) you are experiencing the same problem. This perhaps indicates that your HPWM is not playing anything with the VDD line as this is Vref as well (I assume). A schematic post (with layout if possible) would be appreciated. By that time try playing with the sampling frequency (use the RC clock) and a bit more time for the sampling.
Got it working.... with ADCIN
I did not find the problem but did get the code working.
I was setting up the A to D with the direct registers and had the setup wrong.
I just changed the code to use the ADCIN command and all is now working.
Something was messed up where I was reading the A to D justified register into a variable word using. .highbyte and. .Lowbyte
Yes this is on a breadboard but the results are now very stable as expected.
Thanks all…
tcbcats