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.

CCS/MSP430F5529: Motor Control using MSP430F5529

Part Number: MSP430F5529
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.

  • Hi Tharun,

    welcome to the forum. I edited your post above so that the code is easier readable.

    A good starting point are our code examples. For every device we provide a set of code examples describing how to use the different peripherals like timers,  ADC's, SPI, I2C ... They can be found in our product folders. Click on tab "Tools & Software" then you can find it under "Software".

    For the MSP430F5529 the code examples can be found here: http://www.ti.com/lit/zip/slac300

    For your example above using timers is a good way to start. E.g. see example MSP430F55xx_ta0_04.c It toggles a port pin using timer interrupts.

    Please make also sure to debug your generated signals using an oscilloscope or a logic analyzer. You need to make sure the generated timings are correct. E.g. if your ON signal is only a few ms or even us, then the motor will not spin.

    You also want to make sure the voltage levels are correct. The MSP430 is operating between 1.8V and 3.6V. The L239D is using TTL levels.

    Best regards,

    Andre

     

  • Hi,

    Please also have a look in this application note. http://www.ti.com/lit/slaa294 - Software Coding Techniques for MSP430 MCUs.
    In describes the general concepts of how to setup interrupts and low power modes to efficiently program embedded systems.

    Best regards,
    Andre
  • Hello Andre,

    Thank you for your advice. I will follow it and let you know what happens

    Regards,

    Tharun 

**Attention** This is a public forum