Skip to main content
Visitor II
September 11, 2017
Question

[ATT]9478

  • September 11, 2017
  • 1 reply
  • 773 views
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 

    This topic has been closed for replies.

    1 reply

    Graduate II
    September 11, 2017
    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%