我试过每个单独运行时都会产生625HZ左右,占空比30%左右的 PWM输出,只要屏蔽掉TC3输出,一切输出都正常,开TC3后,结果就不对了,TC3输出不是正常的波形,而单独打开TC3输出波形又没有什么问题,看程序中之间并没有相互的耦合关系,不明白什么原因,请指教~~ void Ect_init(void) { TIOS = 0xff; OC7M = 0XFF; OC7D = 0X00; TCTL2 = 0XFc; // 设置TC1 TC2 TC3 比较产生输出高电平 TSCR2 = 0x0f; // 128 分频 ,计时器TOP值更改 TIE = 0X0E ; // 设置 TC1 TC2 TC3 中断 TC1 = 10; TC2 = 110; TC3 = 209; TC7 = 65310; // 0<= TCNT <= TC7 TSCR1_TEN= 1; } interrupt void Enhanced_Capture_Timer_channel_1(void) //TIE0 { unsigned int time1 ; TFLG1_C1F=1; time1 = TC1; if( 1== TCTL2_OL1 ) { time1 = time1 + 90 ; //128/24M*90秒,(500us)后输出低电平 TCTL2_OL1 = 0 ; //输出低电平 TC1 = time1;
} else //如果当前输出低电平,则此刻输出高电平,并在一段时间后输出高电平 { time1 = time1 + 210 ;
TCTL2_OL1 = 1 ; //输出高电平 TC1 = time1;
}
if( time1 > 64310 ) TC1 = 10 ; } interrupt void Enhanced_Capture_Timer_channel_2(void) //TIE0 {
unsigned int time2 ; TFLG1_C2F=1; time2 = TC2; if( 1== TCTL2_OL2 ) { time2 = time2 + 90 ; //128/24M*90秒,(500us)后输出低电平 TCTL2_OL2 = 0 ; //输出低电平 TC2 = time2;
} else //如果当前输出低电平,则此刻输出高电平,并在一段时间后输出高电平 { time2 = time2 + 210 ; TCTL2_OL2 = 1 ; //输出高电平 TC2 = time2;
} if(time2 > 65310 ) TC2 = 110 ;
} interrupt void Enhanced_Capture_Timer_channel_3(void) //TIE0 { unsigned int time3 ;
TFLG1_C3F = 1 ;
time3 = TC3 ; if( 1== TCTL2_OL3 ) { time3 = time3 + 90 ; //128/24M*90秒,(500us)后输出低电平 TCTL2_OL3 = 0 ; //输出低电平 TC3 = time3;
} else //如果当前输出低电平,则此刻输出高电平,并在一段时间后输出高电平 {
time3 = time3 + 209 ;
TCTL2_OL3 = 1 ; //输出高电平 TC3 = time3; }
if( time3 > 65310 ) TC3 = 209 ; } // |