Hi,

I have a problem using USART in asynchronous recieve mode. I guess the
problem is very simple, but I cannot debug it anyway. Could anybody help me
to find out what's going on? Thank you in advance.

The problem:
     MSP should echo a symbol. But when I send a symbol to MSP from
HyperTerminal, for example 'e' (= 65h ), the software reads the buffer
RXBUF0 and sends it back through TXBUF0. However I don't get back 65h but
D9h instead. Or if I send 6Ch I get back FBh and so on.

It is definately not the HyperTerminal which sends the wrong code, we've
checked it. And baud rates are OK too, since when I hardcode MSP to send
some definate symbol, for example the same 'e' (= 65h ), I recieve it
corectly, i.e 'e' (= 65h ).

My code actually is almost the same as the example "fet140_uart05_09600.c".
Here it is:

#include <msp430x16x.h>
#include <signal.h>

void InitPins();

int main(void)
{
 WDTCTL = WDTPW + WDTHOLD;       // Stop WDT
 InitPins();                            // Pins' initialization
 U0CTL = SWRST;               // SWRST=1
 U0CTL |= CHAR;                 // 8-bit character
 U0TCTL |= SSEL0;              // UCLK = ACLK
 U0BR0 = 0x03;                   // 32k/9600 - 3.41
 U0BR1 = 0x00;                   //
 U0MCTL = 0x4A;                // Modulation
 ME1 |= UTXE0 + URXE0;     // Enabled USART0 TXD/RXD
 U0CTL &= ~SWRST;           // Initialize USART state machine SWRST=0
 IE1 |= URXIE0;                    // Enable USART0 RX interrupt
 _EINT();                              // Interrupts enabled

 while (1);
}
//-------------------------------------------------------------------------------
interrupt (UART0RX_VECTOR) usart0_rx (void)
{
 while (!(IFG1 & UTXIFG0));             // USART0 TX buffer ready?
 TXBUF0 = RXBUF0;                       // read and transmit a symbol
}
//-------------------------------------------------------------------------------
void InitPins()
{
  ...
 P3SEL = 0x30;             //P3.4 and P3.5 used in USART0/UART mode
 P3DIR = 0xDF;              //P3.5/receive data in = IN
 ...
}

Reply via email to