MSP430F5437: Using BSL-RX and TX pins as regular UART on Replicator REP430F

Part Number: MSP430F5437
Other Parts Discussed in Thread: REP430F, SN74LVC1T45

Tool/software:

Hello, 

My intention is to complement Replicator REP430F with custom code that allows communication and programming replicator with desired image.
My problem is that I cannot bring UART to work. I haven't found any notes that BSL-RX and TX pins cannot be used for user application as UART line.
Currently, I use Replicator430F from slau320 repository as a base code.

Here is my UART code:

#include "Config430.h"        // High-level user input
#include "driverlib.h"
#include "debug_log.h"

#ifdef MCLK_18MHZ
    #define MCLK_FREQ 18000000 // 18 MHz
#else
    #define MCLK_FREQ 12000000 // 12 MHz
#endif

#define UART_BASE USCI_A0_BASE
#define UART_BAUD_RATE 115200

bool is_init_done = 0;

void Debug_UART_Init(void)
{
    if (!is_init_done)
    {
        GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0);
        // Configure UART pins: P3.4 = UCA0TXD, P3.5 = UCA0RXD
        GPIO_setAsPeripheralModuleFunctionInputPin(
            GPIO_PORT_P3,
            GPIO_PIN4 | GPIO_PIN5
        );

        // Calculate baud rate settings
        uint32_t clockSource = MCLK_FREQ;
        uint32_t baudRate = UART_BAUD_RATE;
        uint32_t n = clockSource / baudRate;  // ~ 104.1667
        uint32_t brdiv = n / 16;              // = 6
        uint32_t remainder = n - (brdiv * 16); // ~ 8.1667
        uint32_t firstMod = (uint32_t)( ( (float)remainder / 16.0 ) * 16 + 0.5 ); // ~ 8
        uint32_t secondMod = 0; // Approximation for minimal setup

        // Initialize UART configuration structure
        USCI_A_UART_initParam uartParams = {
            .selectClockSource = USCI_A_UART_CLOCKSOURCE_SMCLK,
            .clockPrescalar = 6, // brdiv,
            .firstModReg =  8, // firstMod,
            .secondModReg = 0, // secondMod,
            .parity = USCI_A_UART_NO_PARITY,
            .msborLsbFirst = USCI_A_UART_LSB_FIRST,
            .numberofStopBits = USCI_A_UART_ONE_STOP_BIT,
            .uartMode = USCI_A_UART_MODE,
            .overSampling = USCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION
        };

        // Initialize UART module
        if (STATUS_FAIL == USCI_A_UART_init(UART_BASE, &uartParams)) {
            // Initialization failed
            while(1);
        }

        // Enable UART module
        USCI_A_UART_enable(UART_BASE);

        // Clear any pending interrupts
        USCI_A_UART_clearInterrupt(UART_BASE, USCI_A_UART_RECEIVE_INTERRUPT);

        is_init_done = 1;
    }

}

void Debug_UART_Log(const char* message)
{
    while(*message)
    {
        USCI_A_UART_transmitData(UART_BASE, *message++);
    }
}


This code is added after general MCU initialization from file Replicator430.c
void runProgramm(void)
{
    //! \brief Data pointer
    word p;
    //! \brief Buffer, used for memory read with ReadMemQuick()
    word ReadArray[0x40];

/*------------------------------------------------------------------------------------------------------*/
/*  1. | Initialize host MSP430 (on Replicator board) & target board                                    */
/*------------------------------------------------------------------------------------------------------*/    
    
    InitController();                     // Initialize the host MSP430F5437
    
    ShowStatus(STATUS_ACTIVE, 0);         // Switch both LEDs on to indicate operation.

    Debug_UART_Init();
    Debug_UART_Log(test_msg);


What I tried:
1. I verified that clock works and set to 12 Mhz(choose in config file), by enabling test through the pin and checking with logic analyzer.
2. I tried to use internal UART loop back and it works, I see register values change when I try to TX, RX register is populated with same value, if I enable interrupts, they also trigger.
3. I set level shifter SN74LVC1T45 (REP430F schematic), to output process signal B->A direction P2.0 LOW output. see document REP430F user guide for schematic.
4. I connected FTDI serial cable to check output and I see nothing. I cannot logic analyzer and it also doesn't register any signaling.

Any help would be appreciated!

  • Hi,

    I still not understanding what you are trying to do here. But looked into your code. Can you try below code to configure the P3.4 and P3.5 pin as UART function?

    P3SEL |= GPIO_PIN4 + GPIO_PIN5;

    instead of calling GPIO_setAsPeripheralModuleFunctionInputPin()

    Best regards,

    Cash Hao

  • Hello,
    Thank you for your response!
    I have tried to set pins in the following way as well, no result.

    I'm just trying to setup UART peripheral, in application code based on Replicator430 code(http://www.ti.com/lit/zip/slau320)


  • Found the issue, I used wrong function for Setting Direction pin to low.

    Instead of GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0);
    Should have used GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN0);

**Attention** This is a public forum