Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 62309

Forum Post: Motor rotation using Msp430g2553

$
0
0
Q.1 Can we rotate a motor clockwise and anticlockwise direction using MSP430G2553 microcontroller with ULN2003APG motor driver IC? Q.2.If yes,then what is the problem with this following C code,the motor is not rotating in clockwise and anticlockwise direction? #include " msp430g2553 .h" void main() { WDTCTL = WDTPW + WDTHOLD; // Stop the Watchdog void Delay(int j); P2SEL &= ~BIT6; // Clear P2.6 in P2SEL (by default Xin) P2SEL2 &= ~BIT6; // Clear P2.6 in P2SEL2 P2DIR |= BIT3 + BIT4 + BIT6; // P2.3,P2.4,P2.6 all output P2OUT &= ~BIT3 + BIT4 + BIT6; // Clear P2.3,P2.4,P2.6 // Rotate the Motor clockwise P2OUT |= BIT3; // P2.3 = 1,P2.4 = 0 P2OUT |= BIT6; // P2.6 = 1 ,3&4_EN = 1,Motor is started Delay(10); // Rotate motor for sometime // Stop the motor P2OUT &= ~BIT3 + BIT4; // P2.3 = 0,P2.4 = 0 Delay(5); // Stop the motor for sometime // Rotate the Motor Counter clockwise P2OUT &= ~BIT3; // P2.3 = 0 P2OUT |= BIT4; // P2.4 = 1 P2OUT |= BIT6; // P2.6 = 1 ,3&4_EN = 1,Motor is started Delay(10); // Rotate motor for sometime P2OUT &= ~BIT6; // P2.6 = 0,3&4_EN = 0,Motor is stoped }//End of Main void Delay(int j) { int i; for(j=0;j<10;j++) for(i=0;i<0xFFFF;i++); }

Viewing all articles
Browse latest Browse all 62309

Trending Articles