PWM frequency calculation.
Posted: Sun Apr 19, 2009 11:34 pm
Hi. I'm trying to make a little musical instrument with my msp430f2013. I've been able to make it produce several tones using PWM, but I still haven't figured out how to calculate specific frequencies. To be honest I think I'm still a little confused about how PWM works.
So if timer a is running at 1.11Mhz and I set the period to 254
CCR0 = 0xFE;
Then that brings it down to ~4.3Khz
Then if I set the duty cycle to 20 which is about 1/12 the period
CCR1 = 20;
Then the final output frequency will be about 338Hz (E sharp)?
Is that how it works or am I completely off base? Any help, or even a link in the right direction, will be appreciated. Thank you.
So if timer a is running at 1.11Mhz and I set the period to 254
CCR0 = 0xFE;
Then that brings it down to ~4.3Khz
Then if I set the duty cycle to 20 which is about 1/12 the period
CCR1 = 20;
Then the final output frequency will be about 338Hz (E sharp)?
Is that how it works or am I completely off base? Any help, or even a link in the right direction, will be appreciated. Thank you.