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.

getting a command from RS-232 device

Other Parts Discussed in Thread: MSP430F5438, MSP430F5438A, MAX3232

Hi,

I'm new here. I looked a lot, but didn't found an existing post that I can use.

I need to write a little program that gets a command from a sensor by RS-232 and turn on the Led for a Sec.

I tried to learn the UART communication by the UART-03 example, but it didn't work. i use the HyperTerminal on the Computer, and I don't get an echo.

I connect the Rx and the Tx connectors without the jumper. I didn't connect the ground connector to anywhere. shoud I suppose to connect him? where?

I will thanks anyone who help me.

I'm using msp430f5438A controller on msp430f5438 experimenter board, and CCS 5.3

  • USB RxD/TxD are using UCA1. Does your demo code use UCA1 too? (The MSP has four UCA modules)

    Shmuel Rachimi said:
    I connect the Rx and the Tx connectors without the jumper.

    ??? Both jumpers on JP5 must be set, to have the USB virtual COM port connected to the MSP.

  • Along with jmc's suggestion, make sure you are using rs232 level shifter between the MCU and your computer.

  • chethu gowda said:
    Along with jmc's suggestion, make sure you are using rs232 level shifter between the MCU and your computer.

    UCA1 is connected to the onboard TUSB USB/serial converter. No level shifter needed.
    The other USCI modules, however, are only connected to pin headers and if they are to be connected iwht a COM port, then yes, a level shifter like the MAX3232 is needed.

  • hi,

    a. I used a usb to serial converter to perform a rs232 communication (I don't have COM port on my PC). did I need a level shifter or the converter done the work?

    how I suppose to connect the pins without moving the jumpers? I suppose to connect the gnd?

    b. because it didn't work, I connect the PC to the mini-usb port of the board (without rs232) using a virtual com and HyperTerminal, and I reconnect the jumpers. its still doesnt work.

    I changed the code to use the UCA1, and its still doesn't work.

    here is the code:

    #include <msp430.h>

    int main(void)
    {
    WDTCTL = WDTPW + WDTHOLD; // Stop WDT
    P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
    UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
    UCA1CTL1 |= UCSSEL_1; // CLK = ACLK
    UCA1BR0 = 0x03; // 32kHz/9600=3.41 (see User's Guide)
    UCA1BR1 = 0x00; //
    UCA1MCTL = UCBRS_3+UCBRF_0; // Modulation UCBRSx=3, UCBRFx=0
    UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
    UCA1IE |= 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_A1_VECTOR
    __interrupt void USCI_A1_ISR(void)
    {
    switch(__even_in_range(UCA1IV,4))
    {
    case 0:break; // Vector 0 - no interrupt
    case 2: // Vector 2 - RXIFG
    while (!(UCA1IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
    UCA1TXBUF = UCA1RXBUF; // TX -> RXed character
    break;
    case 4:break; // Vector 4 - TXIFG
    default: break;
    }
    }

  • Shmuel Rachimi said:
    a. I used a usb to serial converter to perform a rs232 communication (I don't have COM port on my PC). did I need a level shifter or the converter done the work?

    Well, if you use a different USCI module than UCA1 for the serial port, or want to use UCA1 but not through the already present USB/serial converter on the board, then you might need a level shifter (and pull the jumpers for UCA1). The TUSB on the board internally acts as level shifter. External USB/ser converters usually emit RS232/V.24 singals which are +-3V to +-12V while the MSP of course only accepts and tansmist TTL level signals (0V/3V). There are, however, some converters available which directly accept/emit TTL level signals, some 5V, some 3V.  In fact, the 'fully RS232 compliant' converters have an USB chip followed by a level shifter of their own to generate the RS232 signals.

    But why don't you just use the already present TUSB chip, leave th ejumpers where they are and connect the USB port of the board to the PC?

    About the code: due to the large fractional portion in the 3.41 divider for 32k/9600Bd, this is a rather ugly constellation. The USCI can only generate bits with a full length of a clock cycle (how much is 0.41 clock cycles?). So some bits are 3, some 4 clock cycles, which introduces a rather large bit timing error. Together with the limited precision of the REFo clock (another 1%) and the possible timing error on the PC side, this is not guaranteed to give a reliable serial connection. It may work or may not.

    You should go for 4800 or 2400Bd with such a low reference.

    Shmuel Rachimi said:
    P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD

    But you are programming USCI A1 (UCA1xxx registers) which is on P5.6/P5.7.

    The four USCIAx modules are identical, but completely independent modules and connected to different pins. You can't program one and use it on the other one's pins.

**Attention** This is a public forum