Other Parts Discussed in Thread: L293D,
Tool/software: Code Composer Studio
I have been trying to implement motor control using an L293D with an MSP430F5529. I am not able to rotate the motor for a specific time and make it stop for a specific time. My code is as follows:
#include<msp430.h> void Delay(int); void Stop1(); void rotate_Clockwise(); void main() { WDTCTL = WDTPW + WDTHOLD; // Stop the Watchdog P2DIR |= BIT3 + BIT4 + BIT6; // P2.3,P2.4,P2.6 all output P2OUT &= ~BIT3 + BIT4 + BIT6; // Clear P2.3,P2.4,P2.6 start: rotate_Clockwise(); // Rotate the Motor clockwise Delay(5); Stop1(); Delay(10); goto start; }//End of Main void Delay(int j) { int i,k; for(i=0;i<j;i++) for(k=0;k<0x00FF;k++); } void Stop1() { P2OUT &= ~BIT3+BIT4+BIT6; } void rotate_Clockwise() { P2OUT |= BIT3; // P2.3 = 1,P2.4 = 0 P2OUT |= BIT6; // P2.6 = 1 ,3&4_EN = 1,Motor is started }
When I debug the program step by step, the motor stops. But when I run the program continuously, it doesn't. I thought of implementing timers instead of for loops. But I am not sure where to start on timers with the MSP. Any help will be much appreciated.