为何在示波器上上下移动 同时占空比变化 附录程序
#include
unsigned aa;
void main(void)
{WDTCTL = WDTPW + WDTHOLD;
DCOCTL=0;
BCSCTL1=CALBC1_1MHZ;
DCOCTL=CALDCO_1MHZ;
TACTL = TASSEL_2 + MC_1;
TA0CCTL1=OUTMOD_3; //MODEL 3 CCR1越大 占空比越小
TA0CCR0=10000-1; //PMW 500000/10000=50HZ
TA0CCR1=10; // 占空比 1-CCR1/CCR0
DCOCTL=0;
BCSCTL1=CALBC1_1MHZ;
DCOCTL=CALDCO_1MHZ;
TA1CTL = TASSEL_2 + MC_1;
TA1CCTL0=CCIE;
TA1CCR0=15000; //中断发生的频率330HZ
P1DIR|=BIT0+BIT6;
P1OUT&=~BIT0+~BIT6;
P1SEL|=BIT6;//P1.6第二功能打开
_EINT();
LPM0;
}
// Timer A0 interrupt service routine
#pragma vector=TIMER1_A0_VECTOR
__interrupt void Timer_A0()
{
aa=TA0CCR1;
if(aa>=9990)
{
TA0CCR1=10;
}
TA0CCR1+=10;
}