Hi All,
we have a question about using a PWM signal to create a buzzer sound at the right frequency on the MSP(MSP430F5359), we use a timer that is sourced by Aclk and Aclk is sourced by a 32768 Hz crystal. Our target frequency is 2880 Hz for the buzzer. But we can't get the right frequency because the timer has a to low resolution. We use the following code:
P4DIR |= BIT2; // PWM settings
P4SEL |= BIT2;
TA2CCR0 = 11; // // 32768 Hz ACLK / 2880 buzzer = 11.377 = 11
TA2CCTL1 = OUTMOD_3;
TA2CCR1 = 5;
TA2CTL = TASSEL__ACLK + MC_1; // ACLK, up-down mode
This gives a frequency of around 2730 Hz when we meassure it, we need a duty cycle of 50 procent so TACCR1 gets the half of TA2CCR0 but this is rounded to 5. The timer registers can only be whole values, using a higher and lower value for TA2CRR1 and TA2CRR0 gives a to high or to low frequency.
Is there a way to get a more preciese PWM signal? Could using the DCO be an option? To our understanding the DCO is not accurate enough. Does the DCO Always have the same preciese speed when booted up (with the same settings)?
Any feedback is welcome!