Hi,

First ...

your ADC gives 1024 steps ...

HPWM has 256 steps

your PWMDuty has 512 possible values ...

sooooo .... pwmduty = analogvalue / 4 ...

OR .... DEFINE ADC_BITS 8 ' ADC resolution 8 bit

which is ... much better !!! ( try and see why ...)



Now, for PORTB.0 and B.7 ...

did you define their initial state somewhere ????

nooooo, you didn't !!! ... and you should had !!!

Have a Good day

Alain