我买了科尔达的EZ430-KF02372开发模块,将P1.5和P1.6脚外接到一个max232串口通信模块上,通过串口线连接PC串口,用以下代码调试的时候,发现发送一串字符给单片机,单片机没有发送任何字符回来,监控单片机的读取缓存区,只能看到我发送字符的最后两位,求大神指导,我怎样才能实现单片机中的字符发送到串口,并被上位机接收到。
(附件是C代码,是cc430x613x_uscia0_uart_03修改的)
#include "cc430x513x.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
PMAPPWD = 0x02D52; // Get write-access to port mapping regs
P1MAP5 = PM_UCA0RXD; // Map UCA0RXD output to P1.6
P1MAP6 = PM_UCA0TXD; // Map UCA0TXD output to P1.7
PMAPPWD = 0; // Lock port mapping registers
P1DIR |= BIT6; // Set P1.7 as TX output
P1SEL |= BIT5 + BIT6; // Select P1.6 & P1.7 to UART function
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL1 |= UCSSEL_1; // CLK = ACLK
UCA0BR0 = 0x03; // 32kHz/9600=3.41 (see User's Guide)
UCA0BR1 = 0x00; //
UCA0MCTL = UCBRS_3+UCBRF_0; // Modulation UCBRSx=3, UCBRFx=0
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3, interrupts enabled
__no_operation(); // For debugger
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV,4))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
}