以下为TI提供的Time_A 输出PWM波形的示例:
TI示例解释时说:P1.2|--> TACCR1 - 75% PWM
P2.0|--> TACCR2 - 25% PWM
而我认为:P1.2|--> TACCR1 输出PWM的占空比为 1/2*(1-384/512)=12.5%
P2.0|--> TACCR2 输出PWM的占空比为 1/2*(1-128/512)=37.5%
我刚学MSP430可能有弄错的地方,请指点~
计算依据:
TI提供示例代码:
#include
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW +WDTHOLD; // Stop WDT
FLL_CTL0 |= XCAP14PF; // Configure load caps
// Wait for xtal to stabilize
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0x47FF; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG)); // OSCFault flag still set?
P1DIR |= 0x04; // P1.2 output
P1SEL |= 0x04; // P1.2 TA1 option
P2DIR |= 0x01; // P2.0 output
P2SEL |= 0x01; // P2.0 TA2 option
TACCR0 = 512-1; // PWM Period
TACCTL1 = OUTMOD_7; // TACCR1 reset/set
TACCR1 = 384; // TACCR1 PWM duty cycle
TACCTL2 = OUTMOD_7; // TACCR2 reset/set
TACCR2 = 128; // TACCR2 PWM duty cycle
TACTL = TASSEL_1 + MC_1; // ACLK, up mode
_BIS_SR(LPM3_bits); // Enter LPM3
}