|
MSP430F247两串口中断为什么不能同时工作?
[复制链接]
芯片为MSP430F247有两个串口收发模块,同时设置串口接收中断时,只有串口1模块响应中断串口0模块没有响应。当设置两个中的任意其中一个时则都是正常响应对应中断的。代码如下:
//******************************************************************************
#include
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
if (CALBC1_1MHZ==0xFF) // If calibration constant erased
{
while(1); // do not load, trap CPU!!
}
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P3SEL = BIT4+BIT5; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 104; // 1MHz 9600; (104)decimal = 0x068h
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
//
P3SEL = BIT6+BIT7; // P3.4,5 = USCI_A0 TXD/RXD
UCA1CTL1 |= UCSSEL_2; // SMCLK
UCA1BR0 = 104; // 1MHz 9600; (104)decimal = 0x068h
UCA1BR1 = 0; // 1MHz 9600
UCA1MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UC1IE |= UCA1RXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
}
#pragma vector=USCIAB1RX_VECTOR
__interrupt void USCI1RX_ISR(void)
{
while (!(UC1IFG&UCA1TXIFG)); // USCI_A0 TX buffer ready?
UCA1TXBUF = UCA1RXBUF; // TX -> RXed character
}
谁能帮忙解决一下!多谢!
|
|