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.

MSP430FR2433: UART transmission, no output

Part Number: MSP430FR2433

Hello, everybody,

currently working with the MSP430FR2433, my goal is to use UARTs to transmit a message. I am at the beginning of this project so my current goal is to send only one message between two UARTs on the same launchpad. You will find below the code, it contains the hardware initialization (clock, UART etc...). However, there is no result, Putty which seems to be correctly configured (bauds, port, flow control) does not observe anything when it is put into serial mode. I'm sorry for the length of the code... And hope to have some help, in advance thank you very much.

#include <msp430fr2433.h>
#include "driverlib/MSP430FR2xx_4xx/driverlib.h"
#include <stdlib.h>
#include "C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include/string.h"
#include "C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include/time.h"
#include "C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include/stdio.h"


#define DCOFREQ 8000000 //8MHz

#define TXLED BIT0
#define RXLED BIT6
#define MAX_STRBUF_SIZE 1024

void systemInit(void);
void initCs(void);
void initEusci(void);
void initEusci1(void);
void UART_receiveString(char);
void UART_transmiteString1(char*);
void UART_transmiteString(char*);



bool rxStringReady;
char rxString[MAX_STRBUF_SIZE];
char txString1[MAX_STRBUF_SIZE] = {"ok"}; // 0110 1111 01101011



volatile uint32_t i; // Used in the main function in the for loop



int iii = 0;

int main(void)
{
   systemInit(); // System initialization

   UART_transmiteString1(txString1);

   while(1)
       {
           UART_transmiteString1(txString1);

           for(i=100000; i>0; i--);

      }

}

void systemInit(void)
{

   // Stop watchdog timer
   WDT_A_hold(WDT_A_BASE);
   printf("Hello in System Init\n");

   // Initialization of the clock
   initCs();

   // LED output
   P1DIR |= RXLED + TXLED;
   P1OUT &= 0x00;

   // Disable the GPIO power-on default high-impedance mode to activate
   // previously configured port settings
   PM5CTL0 &= ~LOCKLPM5;

   //Initialization of the UARTs.
   initEusci();
   initEusci1();

   // Enable gobal interrupts
  __enable_interrupt();
}


void initCs(void)
{
   // Initialization of the clocks
   CS_initClockSignal(CS_SMCLK, CS_DCOCLKDIV_SELECT, CS_CLOCK_DIVIDER_1);

   // For demonstration purpose, change DCO clock freq to 8MHz
   CS_initFLLSettle((DCOFREQ/1000), (DCOFREQ/32768));
}



// EUSCI 0
void initEusci(void)
{
   // Configure UCA1TXD and UCA1RXD
  P1SEL0 |= BIT4 | BIT5;
  P1SEL1 &= ~(BIT4 | BIT5);

  // Configure UART
  // software-dl.ti.com/.../index.html
  // 115 200 bps this value depends on the transmitter used
   EUSCI_A_UART_initParam param = {0};
   param.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK;
   param.clockPrescalar = 4;
   param.firstModReg = 5;
   param.secondModReg = 85;
   param.parity = EUSCI_A_UART_NO_PARITY;
   param.msborLsbFirst = EUSCI_A_UART_LSB_FIRST;
   param.numberofStopBits = EUSCI_A_UART_ONE_STOP_BIT;
   param.uartMode = EUSCI_A_UART_MODE;
   param.overSampling = EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION;

   if(STATUS_FAIL == EUSCI_A_UART_init(EUSCI_A0_BASE, &param))
   {
       return;
   }

   EUSCI_A_UART_enable(EUSCI_A0_BASE);

   // Interruption
   EUSCI_A_UART_clearInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT);

   // Enable USCI_A0 RX interrupt
   EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT); // Enable interrupt
}

// EUSCI interrupt service routine 0
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
   printf("i m before the switch\n");
   switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG))
   {
   printf("i m in the switch\n");

       case USCI_NONE: break;

       // Function which run the halt
       case USCI_UART_UCRXIFG:

           // Read buffer
           UART_receiveString(UCA0RXBUF);

           // Write in buffer
           UART_transmiteString(rxString);
           break;
       case USCI_UART_UCTXIFG: break;
       case USCI_UART_UCSTTIFG: break;
       case USCI_UART_UCTXCPTIFG: break;
       default: break;
   }
}

void UART_receiveString(char data)
{
  printf("%c\n", data);
   bool rxInProgress = false;
   unsigned int charCnt = 0;

   if(!rxInProgress) // if it's wrong, start the interruption with this condition
   {
       if ((data != '\n') )  // if it's a new line, the value of the timer change to 0.
       {
           rxInProgress = true;
           charCnt = 0;
           rxString[charCnt] = data;
       }
   }
   else
   { // in progress
       charCnt++;
       if((data != '\n'))
       {
           if (charCnt >= MAX_STRBUF_SIZE) // If it has come to transmit a length greater than MAX_STRBUF_SIZE to read the data.
           {
               rxInProgress = false;
           }
           else
           {
               rxString[charCnt] = data;  // Read the data and write them in a table.

           }
       }
       else
       {
           rxInProgress = false;
           rxString[charCnt] = '\0';
           // String receive complete
           rxStringReady = true;
       }
   }
}


void UART_transmiteString(char *str)
{
   int ii = 0;
   for(ii = 0; ii < strlen(str); ii++)
   {
       if (str[ii] != 0)
       {
           // Transmit Character
           while (EUSCI_A_UART_queryStatusFlags(EUSCI_A0_BASE, EUSCI_A_UART_BUSY));
           EUSCI_A_UART_transmitData(EUSCI_A0_BASE, str[ii]);
       }
   }
}




// EUSCI 1
void initEusci1(void) {

   // Configure UCA1TXD and UCA1RXD
   P2SEL0 |= BIT6 | BIT5;
   P2SEL1 &= ~(BIT6 | BIT5);

   // Configure UART
   // software-dl.ti.com/.../index.html
   EUSCI_A_UART_initParam param = {1};
   param.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK;
   param.clockPrescalar = 4;
   param.firstModReg = 5;
   param.secondModReg = 85;
   param.parity = EUSCI_A_UART_NO_PARITY;
   param.msborLsbFirst = EUSCI_A_UART_LSB_FIRST;
   param.numberofStopBits = EUSCI_A_UART_ONE_STOP_BIT;
   param.uartMode = EUSCI_A_UART_MODE;
   param.overSampling = EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION;

   if(STATUS_FAIL == EUSCI_A_UART_init(EUSCI_A1_BASE, &param))
   {
       return;
   }

   EUSCI_A_UART_enable(EUSCI_A1_BASE);
   // Interruptions do not need to be enabled
}


void UART_transmiteString1(char *str1)
{
   int i1 = 0;
   printf("%d\n", strlen(str1));
   for(i1 = 0; i1 < strlen(str1); i1++)
   {
       if (str1[i1] != 0)
       {
           // Transmit Character
           while (EUSCI_A_UART_queryStatusFlags(EUSCI_A1_BASE, EUSCI_A_UART_BUSY));
           EUSCI_A_UART_transmitData(EUSCI_A1_BASE, str1[i1]);
       }
   }
}

  • I understand(?) that you've jumpered UCA1TXD to UCA0RXD, and UCA0TXD goes out through the USB.

    Did you remove the RXD jumper from the J3 ("bridge") header? If you didn't, both UCA1TXD and the ezFET will be driving the UCA0RXD (P1.5) line.

    I suggest you start by jumpering UCA1TXD directly to the TXD pin on J3 (USB side), and see if you get an "ok" using PuTTY. This will assure that you've got the clocks and such right.
  • Hello Bruce,

    Thank you for your answer, I admit, I don't understand all your recommendations, initialization for me is complicated. However, I will try to lighten the code and do what you advise me to do, thank you very much.
  • I was suggesting just moving some wires. First thing: Remove the RXD jumper (small black plastic thing) from J3 on the Launchpad.

    What wires do you have connected now?
  • Here is how the card is wired 

  • When I wire my Launchpad that way, and put your code on it (I had to fiddle the includes a little), PuTTY (115200-8-N-1) prints "ok" repeatedly.

    One thing to watch out for: When the debugger is active, UART data comes out in a bursty fashion (something like 64 bytes/3 seconds due to the USB), so you need to be somewhat patient. When I disconnected the debugger I got "ok" maybe four per second.

    I'm not sure what you and I are doing differently.

    [Edit: I was mistaken referring to J3 when J101 is the "bridge" header. I think J3 is that two-pin thing nearby with 5V/GND. You seem to have figured it out, but I'm mentioning it for future archaeologists.]

  • Good afternoon bruce,

    it works after several errors concerning the emulator I managed to get this code to work and send a message. I would now like to do this with 2 MSP, with some adjustments the code works however I need two computers. (Indeed, I didn't succed to launch this code in parallel on each MSP). Do you think it's possible to call 2 different MSPs in the same code ? Thank you very much.
  • It is possible to have two simultaneous debug sessions using (two) different targets (Launchpads), but it is somewhat arcane.

    I try to avoid it if I can, by choosing one target as "known good" (or at least "probably better") and running the debugger against the other.
  • Okay, thank you very much for all this advices.
  • Hi PA,

    Sounds good that it works now for you. Please feel free to come back to E2E for further question.

**Attention** This is a public forum