|
出现了一个新的问题,就是串口通讯中,同样的设置,串口0跟串口1都能够正常通讯,但是串口3就没反应,测量芯片的引脚电压为T为-5.6V,R跟地为0V,这都正常,寄存器的值在仿真软件中看到的也跟USCIA0和USCIA1一样,P9的4,5引脚也都正常,第二功能也设置了,可惜就是通讯没反应,求高手帮忙。
我把程序贴出来
//串口2初始化
void UART1_Init()
{
P5SEL |= 0xc0; // P3.4,5 = USCI_A0 TXD/RXD
UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL1 |= UCSSEL_2; // SMCLK
UCA1BR0 = 104; // 1MHz 9600 (see User's Guide)
UCA1BR1 = 0; // 1MHz 9600
UCA1MCTL |= 0x02; // Modulation UCBRSx=1, UCBRFx=0
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA1IE |= UCRXIE; // Enable USCI_A0 RX interrupt
}
//串口3初始化
void UART2_Init()
{
P9SEL |= 0x30; // P3.4,5 = USCI_A0 TXD/RXD
UCA2CTL1 |= UCSWRST; // **Put state machine in reset**
UCA2CTL1 |= UCSSEL_2; // SMCLK
UCA2BR0 = 104; // 1MHz 9600 (see User's Guide)
UCA2BR1 = 0; // 1MHz 9600
UCA2MCTL |= 0x02; // Modulation UCBRSx=1, UCBRFx=0
UCA2CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA2IE |= UCRXIE; // Enable USCI_A0 RX interrupt
}
//串口2中断程序
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
//unsigned char data=0;
switch(__even_in_range(UCA1IV,4))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
while (!(UCA1IFG&UCTXIFG)); // USCI_A1 TX buffer ready?
UCA1TXBUF = UCA1RXBUF; // TX -> RXed character
//Send_Byte(data);
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
}
//串口3中断程序
#pragma vector=USCI_A2_VECTOR
__interrupt void USCI_A2_ISR(void)
{
//unsigned char data=0;
switch(__even_in_range(UCA2IV,4))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
while (!(UCA2IFG&UCTXIFG)); // USCI_A1 TX buffer ready?
UCA2TXBUF = UCA2RXBUF; // TX -> RXed character
//Send_Byte(data);
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
} |
|