Duty cycle of a pwm is controlled by the compare value. Duty cycle = (Period + 1)/(Compare + 1) * 100%
So you just read the slider position and set the compare value accordingly.
Using A/D, that tells you slider position, essentially.
Then using a loop, or DMA, you feed that value to compare register of PWM.
When PWM finishes its current cycle it will update the comparison
used to new value. In case of PWM immeadiate update occurs.
@dana: no need to use the ADC for the touch slider, there is a nice API for that :)