cancel
Showing results for 
Search instead for 
Did you mean: 

[ATT]9478

bharti sharma
Associate II
Posted on September 11, 2017 at 14:54

TO Calculate PWM Duty Cycle

Hello all,

My question is regarding duty cycle vary according to ADC value I am using STM32F030R8T6 Controller TIM3 is used to generate 20khz signal Prescaler value is 47 and count period is 50 I want to vary duty cycle of 20khz signal according to ADC value(0-3.3v) but I am unable to do this so please guide me 

another question is if I want to reload any value of PWM how it can do 

1 REPLY 1
Posted on September 11, 2017 at 16:05

Prescaler of 48-1 (47) gives you 1 MHz from 48 MHz

Period of 50-1 (49) gives you 20 KHz from 1 MHz

A Pulse width = 50/2 (25) gives you 50/50 duty, pulse of  50/5 (10) gives you 20/80 duty, 50=100%, 0=0%

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..