- #include
- //整个程序运行时候看到闪烁,电压在0.8~1.1V跳动.
- int main(void)
- {
- WDTCTL = WDTPW + WDTHOLD; // 关闭看门狗
- P1DIR |= BIT6;
- P1SEL |= BIT6; //使能第二功能 TA0.TACLK(PWM) ACLK
- CCR0 = 7;//(ACLK@32767Hz / 4000Hz) - 1 = 8.19175 - 1 = 7 PWM周期 ACLK 时钟对吗
- CCTL1 = OUTMOD_4;
- CCR1 = 3;//占空比 8.192*50% - 1 = 3
- TACTL = TASSEL_1 + MC_1; //ACLK + 增计数
- char i_t=0;
- for(i_t=0;i_t<8;i_t++){
- CCR1 = i_t;
- if(i_t == 7){
- i_t = 0;
- }
- }
- while(1);
- }