When I am using one button I have no problem. But I wont to more buttons. Example in my code. When I use P1.3 button. P1.0 active or I pressed P1.4 button P1.0 active.
But I am doing P1.3 button but P1.4 button isnt working.
If you are using the code above, output P1.0 is flipped whenever there is an interrupt on P1.x or P2.x (port 1 or port 2). However, only the inputs that have been properly configured will trigger the interrupt. The code that configures all the input settings for P1.3 is this part:
You need to update that code to also configure the interrupt settings for P1.4 or any other inputs you want to use as buttons. To make the lines of code above apply to P1.3 and P1.4 you should be able to just change all the #008h bitmasks to #018h. This works because:
#008h = #00001000b (only bit 3 is set, where bit 3 controls P1.3) #018h = #00011000b (bits 3 and 4 are set, where bit 4 controls P1.4)
You also need to update your P1_ISR subroutine on this line:
bic.b #008h,&P1IFG ;
The P1 interrupt flag register (P1IFG) must have the bit that was just set during the interrupt cleared before it can be triggered again.
If you are new to the MSP430 or Assembly programming I would suggest trying to write your code without using interrupts at first, until you get comfortable with writing this sort of code.
I starting with C. I write code. But I have problem again.
include “io430.h”
#include “in430.h”
void main( void )
{
WDTCTL = WDTPW + WDTHOLD;
DCOCTL=CALDCO_1MHZ;
BCSCTL1=CALBC1_1MHZ;
P1DIR = 0x00;
P1REN = 0xFF;
P1OUT = 0xFF;
P2OUT = 0x00;
P2DIR = 0xFF;
while(1)
{
P2OUT = (P1IN & 0xFF);
}
}
This is my code.But error is port 2s are 1 when no button press. But I press button 2.3 logic state is 0. But ı want to 0 is normal state. 1 is button press. This must be same as other pins.