[原创] LaunchPad产生方波程序

amww   2012-8-20 23:02 楼主
#include  
#define pwm_sf 200
#define pwm_vf 1000
void pwm_sinit(unsigned char pwmvalue1)
{
  TACTL = TASSEL_2 + MC_1;
  CCR0 = 1002000/pwm_sf;
  CCTL1 = OUTMOD_7;         
  CCR1 = (1002000*pwmvalue1)/(100*pwm_sf);
  P1DIR |= 0x15;
  P1SEL |= 0x15;
  
}
/*
void pwm_vinit(unsigned char pwmvalue2)
{
// TACTL = TASSEL_2 + MC_1;
  CCR0 = 100200/pwm_vf;
  CCTL2 = OUTMOD_7;
  CCR2 = 1002000*pwmvalue2/100;
  P2DIR |= 0x10;
  P2SEL |= 0x10;
}
*/

void main(void)
{
  WDTCTL = WDTPW +WDTHOLD;  
  DCOCTL=CALDCO_1MHZ;
  BCSCTL1=CALBC1_1MHZ;
  pwm_sinit(50);   
  //pwm_vinit(50);
  
  BCSCTL3 = XCAP_2;


  while(1)
  {;}

}

回复评论

暂无评论,赶紧抢沙发吧
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复