This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Help!! UART using USCI_A0 with MSP430FG4618

Other Parts Discussed in Thread: MSP430FG4618

Hello,

This is my first time using msp430 series. I am using the MSP430FG4618 experimenter's board and I would like to have RS232 communication. After developing my own program, it doesn't work. Therefore, I tried with the TI sample code.

With the sample code from msp430xG46x_uscia0_uart_9600.c developed by TI, I still cannot transmit signal through RS232 via terminal. I don't know whether the setting in the program has something wrong or the hardware.

Can anyone give me help? I have tried to debug and the program can actually run into the interrupt.

#include  "msp430xG46x.h"

void main(void)
{
  volatile unsigned int i;

  WDTCTL = WDTPW+WDTHOLD;                   // Stop WDT
  FLL_CTL0 |= XCAP18PF;                     // Configure load caps

  P5OUT&=~BIT1;
  P5DIR|=BIT1;
  P2SEL = BIT4|BIT5;                        // P2.4,5 = USCI_A0 RXD/TXD
 
  UCA0CTL1 |= UCSSEL_1;                     // CLK = ACLK
  UCA0BR0 = 0x03;                              // 32k/9600 - 3.41
  UCA0BR1 = 0x00;                          
  UCA0MCTL = 0x06;                             // Modulation
  UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
  IE2 |= UCA0RXIE+UCA0TXIE;                 // Enable USCI_A0 RX interrupt

  _BIS_SR(GIE);                
  while(1);
}

//  Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCIA0RX_ISR (void)
{
  P5OUT^=BIT1;
  UCA0TXBUF = UCA0RXBUF;                    // TX -> RXed character
}

#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCIA0TX_ISR (void)
{
}

 

  • Hi,

    so  you see that the MSP430 code jumps into the ISR.

    Have you then checked the content of the UXCA0TXBUF register? Do you see the correct ASCII value you sent?

    In the past I had some issues with the terminal program I used on the PC. Which terminal program are you using?
    Have you done the correct setting on PC site (baud rate, number of data bits, parity, ....)?

  • If the TI sample code doesn't work evn if written for the same processor (porting sample code is often very tricky), then the problem is outside the interrupt.

    first, the code may run in the simulator rather than in the device itself. Check your project settings.
    next is that the clock won't work. You do not check whether the (external) 32.768Hz crystal is running properly. If it does, it will sooner or later come up and the loopback will work. if it doesn't, the sample code will fail.
    Last possibility is the RS232 connection itself. Depending on the terminal program, you might need to deactivate RTS/CTS handshake or do a physical loopback of DTR and DSR signals (or the line is considered inoperable)

    There is a faint possibility that the time base of the PCs RS232 chip is so far off that the MSP won't accept it. We once had a defective PC-RS232 card that caused problems.

    Do you see the P5.1 pin toggle?

  • Yes, put a BP on the line UCA0TXBUF = UCA0RXBUF; and put the cursor over the word UCA0RXBUF, you can see its contents.

     

    As far as good terminal programs, Hyperterminal has its issues and lacks some flexibility. I recommend:

    http://realterm.sourceforge.net/

    Putty - search it on google

    both are open source so they're free, although realterm is more flexible.

     

    You might want to ditch using the ACLK for baud generation. It's limited to 9600 because of errors. You seem to be using a uC that has a FLL so the DCO is stable enough for UART. You can use the following calculator to get new settings:http://mspgcc.sourceforge.net/baudrate.html

    Remember you'll need to select SMCLK and not ACLK as the clock for the module.

     

    In general the settings for any terminal program are in addition to the baudrate are 8N1
    where 8 N 1 are the data bits, no parity , and stop bits, respectively. Also disable the hardware/software flow control.

    You can implement things by going into a low power mode which would save energy, especially since you're using ACLK and not a DCO.

     

    The way you have the code, you simply echo characters. You type it into the the terminal and the terminal will show you the response. Normally, not having echo means the terninal will show you nothing as long as nothing is being received.

    I believe if your software settings are correct and you're using the correct port, it should work. If it doesn't then it's likely a hardware problem.

     

    Gustavo

     

     

**Attention** This is a public forum