Home > other >  Msp430f149 port interrupt problem
Msp430f149 port interrupt problem

Time:10-03

I made a port interrupt msp430f149, but the port I use hand to touch will interrupt, then I added a pull-up resistors, didn't buy low level is also an external signal or interrupt, is this why, confused me for three days, thanks for your bosses! Below is the procedure:

# include & lt; Msp430x14x. H>
# include "Config. H"
# include & lt; stdio.h>
# include & lt; string.h>
# include & lt; In430. H>
Unsigned int I;
Unsigned int s=0;
Unsigned int a=0;
Unsigned int b=0 x;
Unsigned int num0=0, num1=0, num2=0;
Char [r];
Char [] y;
Unsigned int times=0;
Char data [];


Void delay (void)
{
int i,j;
for(i=0; i<100; I++)
for(j=0; j<300; J++);
}
Void UART_Init ()
{
U0CTL |=SWRST;//reset SWRST
U0CTL |=CHAR;//8 bits of data model
U0TCTL |=SSEL1;//SMCLK for serial clock
U0BR1=baud_h;//BRCLK=8 MHZ, Baud=BRCLK/N
U0BR0=baud_l;//N=UBR +/8 (UxMCTL)
U0MCTL=0 x00;//fine-tuning register is 0, baud rate 9600 BPS
ME1 |=UTXE0;//UART0 send enabled
ME1 |=URXE0;//UART0 receive enabled
U0CTL & amp;=~ SWRST;
IE1 |=URXIE0;//receiving interrupt enabled a

P3SEL |=BIT4;//set the IO port for normal I/O mode
P3DIR |=BIT4;//set the IO mouth direction for the output
P3SEL |=BIT5;
}

Void Send_Byte (uchar data)
{
While ((IFG1 & amp; UTXIFG0)==0);//send register empty when sending data
U0TXBUF=data;

}


# pragma vector=PORT2_VECTOR
__interrupt void JSZD (void)
{
Delay ();
Send_Byte (' 0 ');
If ((P2IN & amp; 0 x01)==0 x00)
{
Num0 + +;
If (num0%4==0)
{
Send_Byte ('. ');
Times=times + 1;
}


}
If (P2IN==0 x02)
{num1 + +;
}
If (P2IN==0 x04)
{num2 + +; }
P2IFG=0 x00;
}




//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
From the serial port 0//receiving interrupt
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

# pragma vector=UART0RX_VECTOR
__interrupt void UART0_RX_ISR (void)
{

Data [s++]=U0RXBUF;//save the received data
For (I=0; i{
If (data (2 * I]=='r')
{r (+)=data/2 * I + 1 + 4 * times; }
The else
{[b++] y=data/2 * I + 1 + 4 * times; }
}
}

//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
From the serial port 0//send interrupt, reserved
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

# pragma vector=UART0TX_VECTOR
__interrupt void UART0_TX_ISR (void)
{

}

//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//the main function
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Void main (void)
{

WDT_Init ();//watchdog setting
Clock_Init ();//the system clock Settings
P2OUT=0 x00;
P2DIR & amp;=~ (BIT0 + + BIT2 BIT1);
P2IE |=BIT0 + BIT1 + BIT2;
P2IES |=BIT0 + BIT1 + BIT2;
UART_Init ();//initialization serial port Settings
_EINT ();//interrupt
While (1)//infinite loop

{
For (I=0; i{
[I] if (r==num1)
{delay ();
P3OUT |=0 x01;
Delay ();
P3OUT |=0 x00;
}
}
For (I=0; i{
If ([I] y==num2)
{delay ();
P3OUT |=0 x03;
Delay ();
P3OUT |=0 x00; }
}
}
}

CodePudding user response:

Press said you should be want to set the low level raise the interrupt, but you interrupt configuration I don't understand, after all, I also haven't touch 430

CodePudding user response:

Hello, it seems that the msp430f149 can only set up along the or down along, I also don't know how a low level trigger,
  • Related