void PWM_init()
{
//设置pwm端口为输出
P0DIR|= BV(3)|BV(4)|BV(5);
//设置pwm端口为外设端口,非gpio
P0SEL|= BV(3)|BV(4)|BV(5);
//由于uart等会占用我们当前使用的pwm端口,因此需要将uart等重映射到别的端口去。
PERCFG |= 0x33; // Move USART1&2 to alternate2 location so that T1 is visible


T1CTL = 0x0e; // Div = 128, CLR, MODE = module
T1CCTL1 = 0x1c; // IM = 0; CMP = Clear output on compare; Mode = Compare
T1CCTL2 = 0x1c; // IM = 0; CMP = Clear output on compare; Mode = Compare
T1CCTL3 = 0x1c; // IM = 0, CMP = Clear output on compare; Mode = Compare
T1CNTL = 0; // Reset timer to 0;
T1CNTH = 0; // Reset timer to 0;

//必须设置,否则定时器不工作
T1CCTL0 = 0x4C; // IM = 1, CMP = Clear output on compare; Mode = Compare
T1CC0H = 0x07; // Ticks = 375 (2.4ms)
T1CC0L = 0XF8; // Ticks = 375 (2.4ms)

T1CC1H = 0x03; // Ticks = 375 (1,5ms initial duty cycle)
T1CC1L = 0Xc0;
T1CC2H = 0x03; // Ticks = 375 (1,5ms initial duty cycle)
T1CC2L = 0Xc0;
T1CC3H = 0x03; // Ticks = 375 (1,5ms initial duty cycle)
T1CC3L = 0Xc0;

EA=1;
IEN1 |= 0x02; // Enable T1 cpu interrupt
}