[MSP430]/MSP430F20132011. 10. 26. 17:27

[MSP430 PWM] MSP430F2013 PWM

[MSP430 PWM] MSP430F2013 PWM

MSP430의 PWM 출력은 TA0, TA1에서 가능한데 P1.1, P1.2 (P1.5, P1.6)에서 출력 가능하다.



PWM 초기화
void PwmInit2(void)
{
 Sbi(P1DIR, BIT2);                  // P1.2 output
 Bit(P1SEL, BIT2);                  // P1.2 TA1 options

 CCR0 = PWM_PERIOD;                 // PWM Period/2
 CCTL1 = OUTMOD_6;                  // CCR1 toggle/set
 CCR1 = PWM_PERIOD/2;               // CCR1 PWM duty cycle
 TACTL = TASSEL_2 + MC_3;           // SMCLK, up-down mode  
}


PWM출력
#define SetPWMp2(Percent)  CCR1 = (float)PWM_PERIOD/(100.0/(100.0-Percent))


Posted by nexp

댓글을 달아 주세요