Code One:
1 /*******************************2 program function: Aclk=32768hz3 PWM wave t=512/32768 duty ratio 75%4 *********************************/5 6#include <msp430x14x.h>7 voidMain ()8 {9Wdtctl = Wdtpw +Wdthold;TenTactl = Tassel_1 +taclr; One ACCTL0 =0x00; -CCTL1 =0x00; - theCCR0 = +-1;//t=512/32768 -CCTL1 =outmod_7; -CCR1 =384;//384/512=0.75 -CCTL2 =outmod_7; + //CCR2 = 124; - +P1dir |=bit2;k AP1sel |=BIT2; atP2dir |=BIT0; -P2sel |=BIT0; - -Tactl |=mc_1; -}
Code two:
1#include <msp430x14x.h>2 voidINT_CLK ()3 {4BCSCTL1 &= ~Xt2off;5BCSCTL2 |= SELM1 + SELS;//Mclk-->1mhz Smclk-->8mhz6 Do7 {8IFG1 &= ~OFIFG;9 for(intI=0;i< -; i++)Ten _nop (); One} while((IFG1 & OFIFG)! =0); AIFG1 &= ~OFIFG; - } - voidMain () the { -Wdtctl = Wdtpw +Wdthold; - int_clk (); -P1dir |=BIT0; +P1sel |=BIT0; -TACCR0 = -;//PWM f=10khz +TACCR1 = -;//1:1 ATACCTL1 |=outmod_7; atTactl = tassel_2 +mc_1; -}
msp430f149 Learning Path--PWM signal