|
下面我是用到CCR0,CCR1?作PWM功能,啉用?出模式3, 同?也用到了CCR0中?(它的功能是TIMERA??到200?,CCR0?生中?, 然后清TAR,),但是?出劫果不是我想要的,?大家指?, ?铨出在哪里? 著著!!!
#include "msp430x20x3.h"
#pragma vector=TIMERA0_VECTOR
__interrupt void TimerA0 (void) //ccr0 interrupt subroutine
{
TACTL^=MC1; // stop timer counter
TAR=0; // clear counter
}
void initial(void)
{
WDTCTL = WDTPW + WDTHOLD; //disa××e watchdog
_EINT(); //ena××e all interrupt
P1DIR=0xFF;
P1OUT=0X00;
P1SEL=0X04;
}
void short_tone(void)
{
while(1)
{
CCTL0=CCIE;
CCR0=200; // PWM Period
CCTL1=OUTMOD_3; // CCR1 set/reset
CCR1=100; // CCR1 PWM duty cycle
TACTL=TASSEL0+MC1; // ACLK up mode
}
}
void main (void)
{
initial();
short_tone();
}
|
|