Hey,
I am developing a device that goes on a mini-computer embedded system. The communication between device and mini-computer happens by UART.
My device uses MSP430F5310 as it's microcontroller. I went through the FOUR example codes (in slac469e) of UART. They do not provide variety.
I would like to transmit a locally generated character array (64 characters) by UART. What all examples teach me is to echo the received character, I could not find any that explains the way to explicitly transmit a string by UART.
So I used those examples to derive a way. I wait for TX buffer to be ready and then transmit one character, and then wait for it to be ready again and then transmit next character, and so on, till all 64 are transmitted.
while (!(UCA1IFG&UCTXIFG));
UCA1TXBUF = rx_message[1]; while (!(UCA1IFG&UCTXIFG));
UCA1TXBUF = rx_message[2]; while (!(UCA1IFG&UCTXIFG));
UCA1TXBUF = rx_message[3]; while (!(UCA1IFG&UCTXIFG));
UCA1TXBUF = rx_message[4]; while (!(UCA1IFG&UCTXIFG));
....
Now this doesn't work efficiently. If I do this 10 times, only one time the message is flawlessly sent to the other end.
So I do this thing 20 times repeatedly in for loop to ensure that my message reaches there at least once.
What is the ideal way to do this? To transmit a string (char array) by UART?
My settings are:
P4SEL |= BIT4 | BIT5; // P4.4, 4.5 = USCI_A1 TXD/RXD
UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL1 |= UCSSEL_2; // SMCLK
UCA1BR0 = 9; // 1MHz 115200 (see User's Guide)
UCA1BR1 = 0; // 1MHz 115200
UCA1MCTL |= UCBRS_1 | UCBRF_0; // Modulation UCBRSx=1, UCBRFx=0
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA1IE |= UCRXIE; // Enable USCI_A1 RX interrupt
__bis_SR_register(GIE); // Enter LPM0, interrupts enabled