hi,
i want to set PWM for controlling speed of dc motor but don't know how to calculate period(clock tick)???
thanks in advance
best regards
Afridi
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
hi,
i want to set PWM for controlling speed of dc motor but don't know how to calculate period(clock tick)???
thanks in advance
best regards
Afridi
This desire (calculating PWM period) requires a "three-step" process:
SysCtlPWMClkSet() ... SYSCTL_PWMDIV_1, 2, 4, 8, 16. 32, 64 (must choose one of these 7 values) If this function is not called the System Clock is usually the default PWM clock.
PWMPulseWidthSet() ... param 3 is the number of PWM Clock (not System clock) ticks!
You should employ those 3 functions in the order shown (via the bullet points.) Allez (and award "Resolved" S'il Vous Plait...)
Hi Jangrez & CB1
PWM period is the time for which the signal stays on & off as defined by duty cycle.
Now in Tiva the period is calculated with respect to the clock as
SysCtlPWMClockSet(SYSCTL_PWMDIV_1);//This function allows the default clock tied to the PWM to be divided by 1,2,4 ...
For example
Configure the PWM for 75% duty cycle.
PWMGenPeriodSet(PWM1_BASE, PWM_GEN_2, 400);//this line sets the period of PWM,here 400 is period & measured in clock ticks.
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_4, 300);///this line will set the duty cycle to 75%(300ticks) of 400 clock ticks
period.
So this way you can calculate and setup the duty cycle as required.
Thank You
Sajad Rather4 said:SysCtlPWMClockSet(SYSCTL_PWMDIV_1); //This function allows the default clock tied to the PWM to be divided by 1,2,4 ...
It is good that you've assisted - but as the "divide by 1" is the "default" - the function "serves no purpose" - unless another value divisor (non 1) had been (earlier) employed.
Hi Cb1_mobile
Yes divide by 1 takes the default clock,Anyway the user can use the divider of his choice available.