UART0 3.4 3.5 直连 自发自收
代码是官网例程~
1 直连
2 加1k上拉
1,2方法都试过了,串口就是没响应~
用示波器看过,不直连的时候,发送端有波形,而且很好~
不直连的时候,接收端一直是低电平。
直连后,量了还是低电平。发送端发送后没有任何波形~
请教我该咋办?
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x01; // Set P1.0 to output direction
UCTL0 = SWRST;
P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD
ME1 |= UTXE0 + URXE0; // Ena××e USART0 TXD/RXD
UCTL0 |= CHAR; // 8-bit character
UTCTL0 |= SSEL0; // UCLK = ACLK
UBR00 = 0x03; // 32k/9600 - 3.41
UBR10 = 0x00; //
UMCTL0 = 0x4A; // Modulation
UCTL0 &= ~SWRST; // Initialize USART state machine
_EINT();
IE1 |= URXIE0; // Ena××e USART0 RX interrupt
for (;;)
{
while (!(IFG1 & UTXIFG0)); // USART0 TX buffer ready?
TXBUF0 = 0x55; // RXBUF0 to TXBUF0
}
}
// UART0 RX ISR will for exit from LPM3 in Mainloop
#pragma vector=USART0RX_VECTOR
__interrupt void usart0_rx (void)
{
int test = 0;
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
test = RXBUF0;
} |