converting analog to pwm
Beffo,
to generate a PWM signal from a voltage level, you need to put that voltage level into the input pin of a comparator. The other input pin of the comparator will need a sawtooth with a certain magnitude and frequency. The controller IC will usually have a timing resistor and timing capacitor Rt and Ct, that will determine the frequency of the sawtooth. The magnitude of the sawtooth is determined internally by the IC.
The beginning of the PWM pulse is determined by the beginning of the sawtooth and the pulse ends when the voltage level crosses the sawtooth. If you look at the datasheet for the Comparator section you should be able to see this.
Best regards,
v_c