Other Parts Discussed in Thread: MSP-TS430RHL20,
I have an MSP430FR2522 plugged into the socket of the MSP-TS430RHL20 eval board. I have modified the loopback example project and have the UART working on P1.4 and P1.5. I have confirmed the baudrate is 115200 via the oscilloscope. I cannot get the UART working on P2.0 and P2.1. When I call the the remap function, I don't see any transmit data on either UART transmit pin. I confirmed the remap bit - USCIA0RMP - is being set via the emulator. I've created a #define in board.h to enable or disbale the remap functionality.
Any idea why this is not working?
/* --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--*/
//******************************************************************************
//! EUSCI_A0 External Loopback test using EUSCI_A_UART_init API
//!
//! Description: This demo connects TX to RX of the MSP430 UART
//! The example code shows proper initialization of registers
//! and interrupts to receive and transmit data.
//!
//! SMCLK = MCLK = BRCLK = DCOCLKDIV = ~1MHz, ACLK = 32.768kHz
//!
//!
//! MSP430FR2xx_4xx Board
//! -----------------
//! RST -| UCA0TXD|----|
//! | | |
//! | | |
//! | UCA0RXD|----|
//! | |
//!
//! This example uses the following peripherals and I/O signals. You must
//! review these and change as needed for your own board:
//! - UART peripheral
//! - GPIO Port peripheral (for UART pins)
//! - UCA0TXD
//! - UCA0RXD
//!
//! This example uses the following interrupt handlers. To use this example
//! in your own application you must add these interrupt handlers to your
//! vector table.
//! - USCI_A0_VECTOR.
//******************************************************************************
#include "driverlib.h"
#include "Board.h"
uint16_t i;
uint8_t RXData = 0, TXData = 0;
uint8_t check = 0;
#define TIMER_CLOCK_FREQ (CS_getSMCLK()) // Approx 16 MHZ
#define TIMER_TARGET_FREQ (6000) // Approx 6 kHZ
#define TIMER_COUNT (TIMER_CLOCK_FREQ / TIMER_TARGET_FREQ)
#define CS_MCLK_DESIRED_FREQUENCY_IN_KHZ (16000U)
#define CS_MCLK_FLLREF_RATIO ((uint16_t)(CS_MCLK_DESIRED_FREQUENCY_IN_KHZ/32.768f))
/*
**======================================================================
** Function: ConfigureClocks
** Description: Initialize CPU clock signals
** Inputs: None
** Outputs: None
**======================================================================
*/
void ConfigureClocks( void )
{
//uint32_t clockValueSM, clockValueM, clockValueA;
// Set FRAM wait state to 1 for 16 MHz operation - before switching to 16 MHz
FRAMCtl_configureWaitStateControl( FRAMCTL_ACCESS_TIME_CYCLES_1 );
// Set DCO FLL reference (input clock) = factory trimmed internal 32768 Hz REFO
CS_initClockSignal( CS_FLLREF, CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
// Set MCLK and DCO frequency to 16MHz
CS_initFLLSettle( CS_MCLK_DESIRED_FREQUENCY_IN_KHZ, CS_MCLK_FLLREF_RATIO );
// Set SMCLK frequency divider
CS_initClockSignal( CS_SMCLK, CS_DCOCLKDIV_SELECT, CS_CLOCK_DIVIDER_1 );
// Clear all OSC fault flag
CS_clearAllOscFlagsWithTimeout( 1000 );
// Verify if the Clock settings are as expected
//clockValueSM = CS_getSMCLK();
//clockValueM = CS_getMCLK();
//clockValueA = CS_getACLK();
// Configure CLK pins - so they can be meausred with the oscilloscope
GPIO_setAsPeripheralModuleFunctionOutputPin( GPIO_PORT_MCLK, GPIO_PIN_MCLK, GPIO_FUNCTION_MCLK );
GPIO_setAsPeripheralModuleFunctionOutputPin( GPIO_PORT_SMCLK, GPIO_PIN_SMCLK, GPIO_FUNCTION_SMCLK );
}
void main(void)
{
//Stop Watchdog Timer
WDT_A_hold(WDT_A_BASE);
ConfigureClocks();
//Configure UART pins
GPIO_setAsPeripheralModuleFunctionInputPin( GPIO_PORT_UCA0TXD, GPIO_PIN_UCA0TXD, GPIO_FUNCTION_UCA0TXD );
GPIO_setAsPeripheralModuleFunctionInputPin( GPIO_PORT_UCA0RXD, GPIO_PIN_UCA0RXD, GPIO_FUNCTION_UCA0RXD );
// Configure CLK pins - so they can be meausred with the oscilloscope
GPIO_setAsPeripheralModuleFunctionOutputPin( GPIO_PORT_MCLK, GPIO_PIN_MCLK, GPIO_FUNCTION_MCLK );
GPIO_setAsPeripheralModuleFunctionOutputPin( GPIO_PORT_SMCLK, GPIO_PIN_SMCLK, GPIO_FUNCTION_SMCLK );
/*
* Disable the GPIO power-on default high-impedance mode to activate
* previously configured port settings
*/
PMM_unlockLPM5();
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;
EUSCI_A_UART_init( EUSCI_A0_BASE, ¶m );
EUSCI_A_UART_enable(EUSCI_A0_BASE);
#ifdef REMAP_UART
// Move UART to the lower pins - in case a lower lin count package is used
EUSCI_A_UART_remapPins( EUSCI_A0_BASE, EUSCI_A_UART_REMAP_PINS_TRUE );
#endif
EUSCI_A_UART_clearInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT);
EUSCI_A_UART_clearInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_TRANSMIT_INTERRUPT);
// Enable USCI_A0 RX interrupt
EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT);
EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_TRANSMIT_INTERRUPT);
// Enable global interrupts
__enable_interrupt();
while (1)
{
// Increment TX data
TXData = 0x55;
// Load data onto buffer
EUSCI_A_UART_transmitData(EUSCI_A0_BASE, TXData);
__delay_cycles( 5000 );
//while(check != 1);
//check = 0;
}
}
//******************************************************************************
//
//This is the USCI_A0 interrupt vector service routine.
//
//******************************************************************************
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt
#elif defined(__GNUC__)
__attribute__((interrupt(USCI_A0_VECTOR)))
#endif
void EUSCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
RXData = EUSCI_A_UART_receiveData(EUSCI_A0_BASE);
// Check value
if(!(RXData == TXData))
{
while(1);
}
check =1;
break;
case USCI_UART_UCTXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
}
}
#ifndef __BOARD_H__
#define __BOARD_H__
#define REMAP_UART
#ifdef REMAP_UART
#define GPIO_PORT_UCA0RXD GPIO_PORT_P2 // Pin 7 - UART RX
#define GPIO_PIN_UCA0RXD GPIO_PIN1
#define GPIO_FUNCTION_UCA0RXD GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCA0TXD GPIO_PORT_P2 // Pin 8 - UART TX
#define GPIO_PIN_UCA0TXD GPIO_PIN0
#define GPIO_FUNCTION_UCA0TXD GPIO_PRIMARY_MODULE_FUNCTION
#else
#define GPIO_PORT_UCA0RXD GPIO_PORT_P1
#define GPIO_PIN_UCA0RXD GPIO_PIN5
#define GPIO_FUNCTION_UCA0RXD GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCA0TXD GPIO_PORT_P1
#define GPIO_PIN_UCA0TXD GPIO_PIN4
#define GPIO_FUNCTION_UCA0TXD GPIO_PRIMARY_MODULE_FUNCTION
#endif
#define GPIO_PORT_MCLK GPIO_PORT_P1 // Pin 19 -
#define GPIO_PIN_MCLK GPIO_PIN3
#define GPIO_FUNCTION_MCLK GPIO_SECONDARY_MODULE_FUNCTION
#define GPIO_PORT_SMCLK GPIO_PORT_P1 // Pin 20 -
#define GPIO_PIN_SMCLK GPIO_PIN2
#define GPIO_FUNCTION_SMCLK GPIO_SECONDARY_MODULE_FUNCTION
#endif // __BOARD_H__