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.

关于430f5438a中ta模块配合中断产生PWM

源程序如下:

#include "msp430x54x.h"
#include "init_clk.h"
void main()
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
init_clk(); //初始化时钟
P1DIR |=BIT0; // P1.0 output
TA1CCTL0 = CCIE; // CCR0 interrupt enabled
TA1CCR0 = 50000;
TA1CTL = TASSEL_2 + MC_2 + TACLR; // SMCLK, contmode, clear TAR

__bis_SR_register(LPM0_bits+ GIE); // Enter LPM0, enable interrupts
__no_operation(); // For debugger
}

// Timer A0 interrupt service routine
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR()
{
P1OUT ^=BIT0; // Toggle P1.0
TA1CCR0 += 50000; // Add Offset to CCR0
}