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.

MSP-EXP430FR2433: Second UART eUSCI_A1 not working

Part Number: MSP-EXP430FR2433

I recently purchased an MSP-EXP430FR2433. I was trying to program it through CCS Cloud.  I'm trying to make the second UART eUSCI_A1 work. Following is the code.

/* --COPYRIGHT--,BSD
* Copyright (c) 2017, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/
//******************************************************************************
//
// main.c
//
// Out of box demo for the MSP-EXP430FR2433
//
// This demo uses the MSP432FR2433's internal Temperature Sensor and demonstrates
// how to setup a periodic temperature data logger, by utilizing a ring-buffer
// inside the MSP430F2433 device's FRAM memory. In addition, the demo also implements
// a real time temperature sensor
//
//
// E. Chen
// Texas Instruments Inc.
// October 2017
//******************************************************************************

#include "FRAMLogMode.h"
#include "LiveTempMode.h"

// ADC data
adc_data_t adc_data;

// NVS ring handle
nvs_ring_handle nvsHandle;

// FRAM storage for ADC samples using NVS ring storage
#if defined(__TI_COMPILER_VERSION__)
#pragma PERSISTENT(nvsStorage)
#elif defined(__IAR_SYSTEMS_ICC__)
__persistent
#endif
uint8_t nvsStorage[NVS_RING_STORAGE_SIZE(sizeof(adc_data_t), NVS_RING_SIZE)] = {0};

bool buttonS1Pressed;
bool buttonS2Pressed;
bool rtcWakeup;

// Application mode, selected between FRAM_LOG_MODE and LIVE_TEMP_MODE
char mode;

bool rxStringReady = false;
bool rxThreshold = false;
char rxString[MAX_STRBUF_SIZE];

#ifdef RECEIVE_JSON
#include <jsmn.h>

jsmn_parser p;
jsmntok_t t[5]; /* We expect no more than 5 tokens */
#endif

// UART Defines
#define UART_TXD_PORT GPIO_PORT_P1
#define UART_TXD_PIN GPIO_PIN4
#define UART_RXD_PORT GPIO_PORT_P1
#define UART_RXD_PIN GPIO_PIN5
#define UART_SELECT_FUNCTION GPIO_PRIMARY_MODULE_FUNCTION

// Function Definitions
void initGpio(void);
void initCs(void);
void initRtc(void);
void initAdc(void);
void initEusci(void);
void UART_receiveString(char);

void initEusciA1(void);
void UART_receiveString1(char);
void transmitString1(char *str);

int main(void)
{
/* Halt the watchdog timer */
WDT_A_hold(WDT_A_BASE);

/* Initialize GPIO and RTC */
initGpio();
initCs();

initEusci();
initEusciA1();

/* Enable global interrupts. */
__enable_interrupt();

while(1)
{
transmitString("uart0\n\r");

transmitString1("uart1\n\r");

// Add delay to ensure system clock stabilizes after waking up from LPM3.5
__delay_cycles(100000);
}
}

void initGpio(void)
{
// P2.6 as output
P2DIR |= BIT6;


// P2.6 as primary module function (UCA1TXD)
P2SEL0 |= BIT6;
}

void initCs(void)
{
//Set DCO FLL reference = REFO
CS_initClockSignal(
CS_FLLREF,
CS_REFOCLK_SELECT,
CS_CLOCK_DIVIDER_1
);

//Set ACLK = REFO
CS_initClockSignal(
CS_ACLK,
CS_REFOCLK_SELECT,
CS_CLOCK_DIVIDER_1
);

//Create struct variable to store proper software trim values
CS_initFLLParam param = {0};

//Set Ratio/Desired MCLK Frequency, initialize DCO, save trim values
CS_initFLLCalculateTrim(
16000,
488,
&param
);

//Clear all OSC fault flag
CS_clearAllOscFlagsWithTimeout(1000);

//For demonstration purpose, change DCO clock freq to 16MHz
CS_initFLLSettle(
16000,
488
);
}
// Initialize EUSCI
void initEusci(void)
{
// Configure UCA1TXD and UCA1RXD
P1SEL0 |= BIT4 | BIT5;
P1SEL1 &= ~(BIT4 | BIT5);

// Configure UART
// software-dl.ti.com/.../index.html
EUSCI_A_UART_initParam param = {0};
param.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK;
param.clockPrescalar = 8;
param.firstModReg = 10;
param.secondModReg = 247;
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);

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
#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
{
switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
// Read buffer
//UART_receiveString(UCA0RXBUF);
break;
case USCI_UART_UCTXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
default: break;
}
}

// Transmits string buffer through EUSCI UART
void transmitString(char *str)
{
int i = 0;
for(i = 0; i < strlen(str); i++)
{
if (str[i] != 0)
{
// Transmit Character
while (EUSCI_A_UART_queryStatusFlags(EUSCI_A0_BASE, EUSCI_A_UART_BUSY));
EUSCI_A_UART_transmitData(EUSCI_A0_BASE, str[i]);
}
}
}

// Initialize EUSCI_A1
void initEusciA1(void)
{




// Disable eUSCI_A
EUSCI_A_UART_disable(EUSCI_A1_BASE); // Set UCSWRST bit

UCA1CTLW0 |= UCSSEL__SMCLK; // Chose SMCLK as clock source

// Initialization of eUSCI_A
EUSCI_A_UART_initParam param = {0};
param.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK;
param.clockPrescalar = 8;
param.firstModReg = 10;
param.secondModReg = 247;
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;
}

// Enable eUSCI_A
EUSCI_A_UART_enable(EUSCI_A1_BASE); // Clear UCSWRST bit

EUSCI_A_UART_clearInterrupt(EUSCI_A1_BASE,
EUSCI_A_UART_RECEIVE_INTERRUPT);

// Enable USCI_A1 RX interrupt
EUSCI_A_UART_enableInterrupt(EUSCI_A1_BASE,
EUSCI_A_UART_RECEIVE_INTERRUPT); // Enable interrupt


}


// EUSCI interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A1_VECTOR))) USCI_A1_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(UCA1IV,USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
// Read buffer
//UART_receiveString1(UCA1RXBUF);
break;
case USCI_UART_UCTXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
default: break;
}
}

// Transmits string buffer through EUSCI UART
void transmitString1(char *str)
{
int i = 0;
for(i = 0; i < strlen(str); i++)
{
if (str[i] != 0)
{
// Transmit Character
while (EUSCI_A_UART_queryStatusFlags(EUSCI_A1_BASE, EUSCI_A_UART_BUSY));
EUSCI_A_UART_transmitData(EUSCI_A1_BASE, str[i]);
}
}
}

But the second UART doesnt seem to work. Am I missing something here? Any help will be greatly appreciated, thanks in advance.

**Attention** This is a public forum