Hai,
i am controlling DC motor with MSP430F5438A Exp board. i am generating PWM signal at Port5.0 and Port5.1. This ports i am controlling through Joystick. That means when i press left side joy stick, Port5.0 has to generate PWM signal and When i press right side of joy stick, Port5.1 has to generate PWN signal.
But When i press left side joy stick, Port5.0 is generating PWM signal and when i press right side joy stick Port5.1 is not generating any signal( Port 5.0 also not generating).
This is my code:
#include<msp430f5438a.h>
int i,j;
/************ Main program start from here**********/
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
/************ Intilization of Input and output ports**********/
//P2DIR &=~ BIT6+BIT7; //P2.6 is used as Input Pin
P5DIR |= BIT0;
P2REN |= BIT1+BIT2; // Enable P2.6 internal resistance
P2OUT |= BIT1+BIT2; // Set P2.6 as pull-Up resistance
P2IE |= BIT1+BIT2; // P2.6 interrupt enabled
P2IES |= BIT1+BIT2; // P2.6 Hi/Lo edge
P2IFG &=~ BIT1+BIT2; // P2.6 IFG cleared
__bis_SR_register(GIE); // Enter LPM4 w/interrupt
while(1)
{
if(i)
{
P1DIR |= BIT0; // Port 1 and Bit 0 set as dircttion
P1OUT |= BIT0; // P1.0 High
P5OUT |= BIT0;
__delay_cycles(250);
P5OUT &=~ BIT0;
__delay_cycles(250);
}
else if(j)
{
P1DIR |= BIT1; // Port 1 and Bit 1 set as dircttion
P1OUT |= BIT1; // P1.0 High
P5OUT |= BIT1;
__delay_cycles(250);
P5OUT &=~ BIT1;
__delay_cycles(250);
}
else
{
P5OUT &= ~BIT0;
P5OUT &= ~BIT1;
}
}
}
// Port 2 interrupt service routine
#pragma vector=PORT2_VECTOR
__interrupt void Port_2(void)
{
if(P2IFG && BIT1)
{
i = 1;
j = 0;
P2IFG &=~ BIT1;
}
else if(P2IFG && BIT2)
{
j = 1;
i = 0;
P2IFG &=~BIT2;
}
else
{
i = 0;
j = 0;
P2IFG &=~ BIT1+BIT2;
}
}
i am unable find out mistake..
Where i am doing mistake..??
Please advice me if i m doing any wrong..??
Thankyou