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.

USCI UART receive only one byte of two byte message, MSP430F5418A

Hello,

I've got a USCI UART on an MSP430F4318A connected to a Bluegiga WT12 (iWRAP v4 firmware) and whenever the device responds to a carriage return (0xD) or a newline (0xA) character sent to it, it spits out a 0xD and 0xA back (see o-scope shot at bottom, correct me if I'm reading it wrong, but I see a 0 start bit, then the LSB-first 8-bits of the first byte, then a 1 stop bit, then the same for the second byte of data) in a single 2-byte chunk (I'm sending just one at a time, and setting breakpoint on the UCA1TXBUF = 10;).  I'm concerned because I can only ever see the second character in the MSP430 as the second char immediately overwrites the first one (setting UCOE when this happens, as it should).  My question is, is there any way to get both characters?  I had figured with a fast enough clock (16MHz SMCLK) my ISR would go fast enough to get them both.  Has anyone successfully communicated with a WT12 using an MSP430?  My code is below:

// setup code for UART
    P5SEL |= (BT_RX | BT_TX);
    // port speed at startup is 115200 bps
    UCA1CTL1 |= UCSWRST;                      // **Put state machine in reset**
    UCA1CTL1 |= UCSSEL_2;                     // SMCLK
    UCA1BR1 = 0;
    UCA1BR0 = 8;
    UCA1MCTL = UCBRS_0 + UCBRF_11 + UCOS16;
    UCA1CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
    UCA1IE |= UCRXIE;

// code inside main while() loop

while (!(UCA1IFG&UCTXIFG));
while ((P1IN&BT_RTS));               // doesn't do anything
UCA1TXBUF = 13;

// ISR code

#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
    // note family users guide recommends (p902) checking stat for UCOE, then reading, then UCOE again
    //if(UCA1STAT & UCOE == 1)                     //check if UCOE is still high
    if (uart_rxchars<256) { datarx[uart_rxchars++] = UCA1RXBUF; }
    else
    {
        // set overflow condition, de-assert CTS
        // P1OUT |= BT_CTS; // doesn't work, WT12 ignores this...
        uart_rxchars=0; // wrap around the ring buffer
    }
    break;
  case 4:break;                             // Vector 4 - TXIFG
  default: break;
  }
}

  • Never mind, I got it working.  My timing was wrong in how I used flow control - I've attached my code at the bottom in case anyone is interested, note my ISR has not changed.

    However, I have another question, is it possible to de-select _part_ of a peripheral?  The reason I ask is I have a device which says SPI on it, but the SIMO/SOMI pins are tied together, and there is a data direction switch pin, so its not really SPI.  I have to perform two writes to it and then a lot of reads, asserting the data direction switch in between.  Does anyone know if it is possible to de-select the SIMO port pin on the USCI interface when enabled as 3-wire SPI slave mode?  Otherwise, I think my only alternative is to bit-bang part of the communications and remove one of the data direction connections from the MSP side.

    Thanks,

    Eriik

    // configure RTS as interrupt, then when int'ed, set CTS and listen
        P5SEL |= (BT_RX | BT_TX);
        P1SEL &= ~(BT_RTS | BT_CTS); // flow control as GPIO
        P1DIR &= ~BT_CTS; // CTS is input to MSP430
        P1DIR |= BT_RTS; // RTS is output from MSP430
        P1OUT |= BT_RTS; // set RTS high to assert flow control (active low)
        // port speed at startup is 115200 bps
        UCA1CTL1 |= UCSWRST;                      // **Put state machine in reset**
        UCA1CTL1 |= UCSSEL_2;                     // SMCLK
        // using 16MHz SMCLK, UCOS16 and divisor of 8.675555 -> 0.67555*8=5.4044, table recommends 8 0 11
        UCA1BR0 = 8;
        UCA1BR1 = 0;                              // 1MHz 115200
        UCA1MCTL = UCBRS_0 + UCBRF_11 + UCOS16;
        UCA1CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
        UCA1IE |= UCRXIE;                         // Enable USCI_A1 RX interrupt
        // end serial setup

    void command_tx_WT12()

    {

        P1OUT &= ~BT_RTS;
        while ((P1IN&BT_CTS));
        while (*uartbuffer)
        {
            while (!(UCA1IFG&UCTXIFG));
            UCA1TXBUF = *(uartbuffer++);
        }
        //UCA1IE |= UCRXIE; // turn RX IE back on - receive bytes
        __delay_cycles(100000); // delay by 100msec for all control commands
        P1OUT |= BT_RTS;

    }

**Attention** This is a public forum