I am involving in a program which is written by myself about using MSP430F149 to control the step motor.I would like to show them here.( this is the datasheet of MSP430F149: [^]
)And I think maybe they could be improved but I don’t know how to do it. Could you give me some suggestions?
This is the program:
typedef unsigned int uint;
typedef unsigned char uchar;
#define PWM BIT2
BCSCTL1&=~XT2OFF; //open XT oscillator
BCSCTL2|=SELM1+SELS;//MCLK 8M and SMCLK 1M
IFG1 &= ~OFIFG; //clean the wrong sign of vibration
for(i = 0; i < 100; i++)
_NOP(); //delay waiting
while ((IFG1 & OFIFG) != 0); //If sign is 1,continue to wait
P1SEL|=PWM;//choose P12 to bePWM output
TACCR0=800;//PWM signal cycle 10KHz
TACCR1=400;//duty cycle 1：1
TACCTL1=OUTMOD0+OUTMOD1+OUTMOD2; //outputted mode choosing
int_clk(); //clock initialization
int_pwm(); //initialize PWM
The program is base on controlling the return of step motor by using MSP4300f149. The outputted port of PWM is P1.2 while the signal cycle is 10KHZ. The duty cycle is 1:1.
Do you have any advice about my program?