Search code examples
msp430

Using MSPf5529 with UART returns spacing cedilla in Mac


I'm trying to use the MSPF5529 with my mac. I've downloaded code composer studio and can easily access the chip as well as blink lights and any other application I need.

The goal is for me to print a message using UART through serial communication on my Mac. I am currently using an application called "goSerial" in order to communicate with the chip. My code below initializes UART, takes in a single character, and then it is supposed to print out a character, and then blink a light. However, instead, the code takes in the character, and prints out a strange symbol, called a spacing cedilla, with a hex value of 0xFC, and then blinks the light.

This symbol appears regardless of which character I put into the MSP430 buffer.

My code is listed below. Has anyone had this problem before? How do I solve this?

 void Init_UART(void);
 void OUTA_UART(unsigned char A);
 unsigned char INCHAR_UART(void);
 #include "msp430f5529.h"
 #include "stdio.h"


 int main(void){
 volatile unsigned char a;
 volatile unsigned int i;
 WDTCTL = WDTPW + WDTHOLD;
 Init_UART();
 a=INCHAR_UART();

 a=INCHAR_UART();
 OUTA_UART(a);
 // go blink the light to indicate code is running
 P1DIR |= 0x01;
 for (;;){
 P1OUT ^= 0x01; i = 10000;
 do i--;
 while (i != 0); }

 }




 void OUTA_UART(unsigned char A){ 
 while ((UCA1STAT&UCBUSY));
 // send the data to the transmit buffer
 UCA1TXBUF =A;
 }



 unsigned char INCHAR_UART(void){ 
 while ((UCA1STAT&UCBUSY) == 0);
 // go get the char from the receive buffer
 return (UCA1RXBUF);
 }

 void Init_UART(void){
     P4SEL |= 0x30;     // Port 4.4 and port 4.5 controls the transfer 
     UCA1CTL1|= UCSWRST;  // Put state machine in reset
     UCA1CTL1|= UCSSEL_1;       //Choose 32765Hz
     UCA0BR0=3;             // Baud rate = 9600
     UCA0BR1=0;             // Choose 32765 hz
     UCA1MCTL=0x06;         // Modulation UCBRSx=3, UCBFx = 0
     UCA1CTL1 &= ~UCSWRST;      // Put USCI in operation mode

  }

Solution

  • The UCBUSY flag is not very useful, and cannot be used like this.

    That a byte has been received is indicated by UCRXIFG:

    while (!(UCA1IFG & UCRXIFG)) ;
    return UCA1RXBUF;
    

    That a byte can be sent is indicated by UCTXIFG:

    while (!(UCA1IFG & UCTXIFG)) ;
    UCA1TXBUF = a;