NTS Forums

Please login or register.

Login with username, password and session length
 

News:

Welcome to the Newtek Technology Services Forum!


Author Topic: MSP430F149's Programming Troubles  (Read 115 times)

Offline maydory

  • Hosting Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
MSP430F149's Programming Troubles
« on: April 28, 2017, 02:00:17 AM »
Good afternoon,I will be appreciated if you could give me some available information.
I have written a program about using msp430f149 according to its datasheet( http://www.kynix.com/uploadfiles/pdf8798/MSP430F1491IPM.pdf ) to control the step motor.I would like to show them here.
This is the program:

Code: [Select]
#include <msp430x14x.h>   
typedef    unsigned int  uint; 
typedef   unsigned char uchar;   
#define   PWM   BIT2   
void int_clk()   
{   
    uchar i;   
    BCSCTL1&=~XT2OFF;  //open XT oscillator   
    BCSCTL2|=SELM1+SELS;//MCLK 8M and SMCLK 1M     
    do   
    {   
        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   
    IFG1&=~OFIFG;   
}   
void int_pwm()   
{   
  P1SEL|=PWM;//choose P12 to bePWM output   
  P1DIR|=PWM;     
  TACCR0=800;//PWM signal cycle 10KHz   
  TACCR1=400;//duty cycle 1:1   
  TACCTL1=OUTMOD0+OUTMOD1+OUTMOD2; //outputted mode choosing   
  TACTL|=TASSEL1+MC0;   
}   
void main()   
{   
  WDTCTL=WDTPW+WDTHOLD;//close watchdog   
  int_clk();  //clock initialization   
  int_pwm();  //initialize PWM   
  while(1);//end
   


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 suggestions about my program? Welcome to discuss it with me.