msp430f2619有Timer_A3,Timer_b7两个时钟源,利用GPIO的第二功能,将P2.7输出20kHz的PWM波,P4.1输出10kHz的PWM波,P4.2,P4.3输出100kHz相位相反的PWM,怎么实现?,必须使用timer的中断功能吗?
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.
msp430f2619有Timer_A3,Timer_b7两个时钟源,利用GPIO的第二功能,将P2.7输出20kHz的PWM波,P4.1输出10kHz的PWM波,P4.2,P4.3输出100kHz相位相反的PWM,怎么实现?,必须使用timer的中断功能吗?
那,能让timer_a的比较的TA1触发中断,TA0输出PWM可以吗?在中断服务程序里面令P3.0的电平翻转? 我现在程序感觉没法触发中断,请各位帮我分析一下,哪里出了问题?
void main(void) { int iq0=0; WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog Timer BCSCTL1 &= ~XT2OFF; //ACLK为XT1,开启XT2震荡 do { IFG1 &= ~OFIFG; //清除振荡器失效标志
for (iq0=0xFF; iq0>0; iq0--); //延时,等待XT2起振 }
while ((IFG1 & OFIFG)!= 0); //判断XT2是否起振
BCSCTL2=SELM_2+SELS+DIVS_0+DIVM_0; //选择MCLK、SMCLK为XT2 ,SMCLK 8分频
BCSCTL3=XCAP_1+LFXT1S_0+XT2S_2; //XT1工作在32.768KHz的低频模式下,内部电容为6PF,XT2的频率为2-16MHZ
P3DIR |= 0xff; P3SEL=0x00; P5DIR |= 0x78; // P5.6,5,4,3 outputs
P5SEL |= 0x70; // P5.6,5,4 options P1DIR |= 0x0C; // P1.2 and P1.3 output
P1SEL |= 0x0C; // P1.2 and P1.3 TA1/2 options
P2DIR|=0x80; // P2.7 output
P2SEL=0x80; // P2.7 TA1/2 options output=20khz,50% P4DIR|=0x46; //P4.1 and P4.6 output P4SEL=0x46; //P4.1TB1 and P4.6 TB7 options
CCR0 =124; // PWM Period/2
CCTL0=OUTMOD_4 +CCIE; //CCR0 toggle
TACTL = TASSEL_2 + MC_3+ID_0; // SMCLK, mode up/dowm
while (1) // 10 MCLK cycle loop
{ P5OUT |= 0x08; // P5.3 = 1 P5OUT &= ~0x08; // P5.3 = 0 } }
#pragma vector=TIMERA0_VECTOR __interrupt
void Timer_A (void)
{ P3OUT= 0x00; // Toggle P3.0 }