标题: msp430f5529双路输出pwm波 [打印本页]

作者: heicad    时间: 2016-3-11 20:50
标题: msp430f5529双路输出pwm波

  1. #include <msp430.h>
  2. extern unsigned int period,period1;
  3. int pwm1(period,period1)                           调节占空比
  4. {

  5.   P2DIR |= BIT0+BIT5;                       // P2.0 and P2.1 output
  6.   P2SEL |= BIT0+BIT5;                       // P2.0 and P2.1 options select
  7.   TA1CCR0 = 1000-1;                          // PWM Period
  8.   TA2CCR0 = 1000-1;
  9.   TA1CCTL1 = OUTMOD_7;                      // CCR1 reset/set
  10.   TA1CCR1 = period;                            // CCR1 PWM duty cycle
  11.   TA2CCTL2 = OUTMOD_7;                      // CCR2 reset/set
  12.   TA2CCR2 = period1;                            // CCR2 PWM duty cycle
  13.   TA1CTL = TASSEL_1 + MC_1 + TACLR; // ACLK, up mode, clear TAR
  14.   TA2CTL = TASSEL_1 + MC_1 + TACLR;
  15.   __bis_SR_register(LPM3_bits);             // Enter LPM3
  16.   __no_operation();                         // For debugger
  17. }
复制代码







欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1