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.

MSP430FR2355: UART not transmitting all the data?

Part Number: MSP430FR2355

Hello...

I have four 8 byte messages I would like to send to a radio.  I notice that I am sending 7, 7, 7, 8 on a logic analyzer....The last byte of each of the first three blocks of data is getting cutoff and not sent....My code is as follows:

                else if (Button == DEFINE_SYS)
                {
                    for (sysLoop = 0; sysLoop < 4; sysLoop++)
                    {
                        mssg[4] = sysID[2*sysLoop];
                        mssg[5] = sysID[2*sysLoop + 1];
                        mssg[6] = crc[2*sysLoop];
                        mssg[7] = crc[2*sysLoop + 1];
                        TB0CCR2 = TB0R + 1;
                        TB0CCTL2 |= CCIE;
                        LPM3;
                        while (!UCTXCPTIFG);
                    }

I notice that if I remove

                        while (!UCTXCPTIFG);

and replace with __delay_cycles(10000); that all eight bytes of each message get sent out....

The code is supposed to work as follows:

Create 8 byte message....wait for 80ms....transmit 8 bytes over UART and then wake to create second message...go to sleep and wait for 80ms again....

I see two issues which I don't understand at the moment.

1.  the first seven bytes go out but not the eighth byte on first three messages?

2.  the bytes are ALL back to back with no 80ms window between each?

Can someone tell me something to look for?  I was trying to use the UCTXCPTIFG because I was thinking the LPM3 was waking due to another ISR (possibly one of the TBxIFG flags).

The other code section look as follows:

80ms wake up 

      case TB0IV_TBCCR2:
          TB0CCR2 = TB0R + TX_MESSAGE_SPACING_TIME;
          if (remote)
          {
              pTx = mssg;
              TB0CCTL2 &= ~CCIE;
              UCA1IFG |= UCTXIFG;
              UCA1IE |= UCTXIE;
          }
          break;

TX ISR: (the else portion is only valid here)

      case USCI_UART_UCTXIFG:
          if (radioConfiguration)
              LPM3_EXIT;
          else {
              UCA1TXBUF = *pTx;
              pTx++;
              if (pTx > (mssg + 7)) {
                  UCA1IE &= ~UCTXIE;
                  UCA1IFG &= ~UCTXIFG;
                  LPM3_EXIT;
              }
          }
          break;

One final thought....baud rate is 19.2k with 1 start bit and 1/2 bit for stop.....8 bytes is well within the 80ms period.

Thanks

  • > while (!UCTXCPTIFG);

    UCTXCPTIFG is a constant (and !=0) so this doesn't delay at all. You probably wanted "while (UCA1IFG & UCTXCPTIFG)" except you actually don't due to Erratum USCI42 [Ref Errata (SLAZ695h) p. 8].

    Since by the time you get here the final byte has been put in TXBUF, I suggest something like

    > while (UCA1STATW & UCBUSY) /*EMPTY*/;  // Wait for last byte(s)

  • Any thoughts on why the data from the UART continuously sends out all 4 bytes instead of waiting after each group of 8?

  • Do you mean the 4 packets? For each one you set TB0CCR2=TB0R+1, i.e. "very soon", so the change you make in the timer ISR doesn't do much. Maybe you meant to do that outside the for() loop?

  • That ccr + 1 is good...(32khz clock source)...Turns out I was coming out of the tx UART and my timer of 80ms was still running so I'd go right back into transmitting again and again and again....I found it by doing a quick wait on the CCR flag.....Also I believe I have a work around on not using the UCBUSY flag which as a purest I am happy....I hate using flags vs interrupts....I will create soft flags for main to run after the ISR has gone off but the UART should (and seems like it can) be set up to just use interrupt

    Thanks for the help!

    Steve

**Attention** This is a public forum