Tool/software: Code Composer Studio
#include <msp430.h> #define MA1 BIT0 #define MA2 BIT1 #define MB1 BIT2 #define MB2 BIT4 int main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer P2DIR &= ~BIT1 + BIT2 + BIT3 + BIT4 ; //explicitly making P2 as Input - even though by default its Input P2REN |= BIT1 + BIT2 + BIT3 + BIT4; //Enable Pullup/down P2OUT |= BIT1 + BIT2 + BIT3 + BIT4; //Select Pulldown P1DIR |= MA1 + MA2 + MB1 + MB2; while(1) { if(!(P2IN & BIT1)) // forward { P1OUT |= MA1 + MB1; P1OUT &= ~MA2 + MB2; __delay_cycles(500); } if (!(P2IN & BIT2)) // REVERSE { P1OUT |= MB2; P1OUT |= MA2; P1OUT &= ~MA1 + MB1; __delay_cycles(500); } if (!(P2IN & BIT3)) // RIGHT { P1OUT |= MA1; P1OUT &= ~MA2 + MB1; P1OUT &= ~MB2; __delay_cycles(500); } if (!(P2IN & BIT4)) // LEFT { P1OUT |= MB2; P1OUT &= ~MA1 + MA2; P1OUT &= ~MB1; __delay_cycles(500); } else { P1OUT = 0x00; __delay_cycles(500); } } //return 0; }
This is my code my using this for motor controller
but its not working properly.
MB2 is not working it provides only 0.2v at output when it is on. while other 2.1v
i tried many thing but its power priblem remains constant.
please give me a proper solution
Thanking you.