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.

MSP430FR4133: Stepper Motor W/ ULN2003 driver issues

Part Number: MSP430FR4133

Hello, 

I have been trying to control a stepper motor (BYJ48) with a ULN2003 driver for the past several days to no avail, the stepper motor moves but extremely slowly and vibrates back and forths, here is my very simple code:

void main(void)
{
    WDTCTL = WDTPW | WDTHOLD; // Stop WDT
    // Stepper Pin 1 = GPIO_PIN3, Pin2 = GPIO_PIN4, etc.
    GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN3 | GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6);
    
    while(1) 
    {   
      for(int i = 0; i < 12; i++) 
      {
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000);    
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000); 
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000); 
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000);
      }
      
      GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN3);
      GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4);
      GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN5);
      GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN6);
      __delay_cycles(1000);
      
      for(int j = 0; j < 12; j++) 
      {
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000);    
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000); 
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000); 
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000);
      }
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN3);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4);
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN5);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN6);
        __delay_cycles(1000);            
    };   
    // __bis_SR_register(LPM0_bits); // Enter LPM0
}

Where GPIO_PIN3 is IN1, GPIO_PIN4 = IN2, GPIO_PIN5 = IN3, GPIO_PIN6 = IN4.

I am also using an external supply to power the motor. 

I simply just want the stepper motor to rotate continuously 360 degrees.  I am following this video for reference... https://www.electronicwings.com/ti-launchpad/stepper-motor-interfacing-with-msp-exp430g2-ti-launchpad

It's Arduino based but the code is equivalent. 

Help is much appreciated Thanks

**Attention** This is a public forum