This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F417:CONTROLLING THE STEP MOTOR WITH PWM SIGNALS

Part Number: MSP430F417

hello everyone.

I am trying to drive a stepper motor using the MSP430F417 card. What I want to do now is for the stepper motor to stop completely after short circuit. Using PWM signals after googling felt like the right option.

But I still don't know how to do it. Can anyone give me an idea?

here is my code:

#include "io430.h"
#include "in430.h"

void begin_counting( unsigned target_count)
{
TA1CTL &= ~BIT4;
TA1R = 0;
TA1CCR0 = target_count;
TA1CCTL0 &= ~CCIFG;
TA1CTL |= BIT4;

}

void main()
{
  WDTCTL =  WDTPW + WDTHOLD;    // Stop the Watchdog
  
  void Delay(int j);
        
  P6SEL  &= ~BIT4;            
  P6DIR  |=  0xFF; 
  P6OUT  &= ~0XFF; 
 
  CCR0 = 128;                               // PWM Periyot/2
  CCTL1 = OUTMOD_7;                         // CCR1 reset/set
  CCR1 = 32;                                // CCR1 PWM duty cycle
  TACTL = TASSEL_2 + MC_3;                  // SMCLK, up-down mode
 
  begin_counting( 20 );
  
  P6OUT |= BIT4; 
  Delay(50);   
  
  while(1){
    
    if((P6IN & BIT5)==0){
   P6OUT &=~BIT4;
   Delay(30);
    }
  }
}

void Delay(int j)
{
  int i;
  for(j=0;j<100;j++)
      for(i=0;i<0xFFFF;i++);
}

thank you.

**Attention** This is a public forum