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.

MSP430F5529: UART Driverlib Initialize Proplem ???

Part Number: MSP430F5529


Hello, I am new programming with msp430. I have a MSP430 F5529 Lauchpad. To day I am using UART module base on example in DriverLib. This example is loop back data. After I download code into chip and debug, I connect P3.3 with P3.4 (wire Rx With Tx) but do not receive any thing. What is wrong ???

My code here:

#include "driverlib.h"
#include "string.h"

volatile uint8_t receive_data=0;
uint8_t transmit_data[]="Hello World. I'm UART Module of MSP430F5529 Microcontroller !!!\r\n";

void Uart_Init(void);
void delay(uint32_t time);


#pragma vector=USCI_A0_VECTOR
__interrupt void UART_Isr(void)
{
	if(USCI_A_UART_getInterruptStatus(USCI_A0_BASE,
			USCI_A_UART_RECEIVE_INTERRUPT_FLAG)
			==	USCI_A_UART_RECEIVE_INTERRUPT_FLAG)
	{
		receive_data=USCI_A_UART_receiveData(USCI_A0_BASE);
		USCI_A_UART_clearInterrupt(USCI_A0_BASE,USCI_A_UART_RECEIVE_INTERRUPT_FLAG);
	}
}

void main( void )
{
	/* Stop watchdog timer */
	WDT_A_hold(WDT_A_BASE);

	Uart_Init();

	__enable_interrupt();

	while(1)
	{
		for(uint8_t i=0;i<strlen((char const*)transmit_data);i++)
		{
			USCI_A_UART_transmitData(USCI_A0_BASE,*(transmit_data+i));

/* Wait transmission is completed */ while(USCI_A_UART_queryStatusFlags(USCI_A0_BASE,USCI_A_UART_BUSY)==USCI_A_UART_BUSY); } delay(2000000); } } void Uart_Init(void) { USCI_A_UART_initParam para; /* Baudrate = 9600, clock freq = 1.048MHz * UCBRx = 109, UCBRFx = 0, UCBRSx = 2, UCOS16 = 0 * * From: Table 39-5. Recommended Settings for Typical Crystals and Baud Rates at Page 1039/1189 User guide. * For more information about baudrate setting see 39.3.10 Setting a Baud Rate at page 1036 User Guide */ para.selectClockSource = USCI_A_UART_CLOCKSOURCE_SMCLK; para.clockPrescalar = 109; para.firstModReg = 0; para.secondModReg = 2; para.parity = USCI_A_UART_NO_PARITY; para.msborLsbFirst = USCI_A_UART_LSB_FIRST; para.numberofStopBits = USCI_A_UART_ONE_STOP_BIT; para.uartMode = USCI_A_UART_MODE; para.overSampling = USCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION; USCI_A_UART_init(USCI_A0_BASE,&para); USCI_A_UART_enable(USCI_A0_BASE); USCI_A_UART_clearInterrupt(USCI_A0_BASE,USCI_A_UART_RECEIVE_INTERRUPT); USCI_A_UART_enableInterrupt(USCI_A0_BASE,USCI_A_UART_RECEIVE_INTERRUPT); } void delay(uint32_t time) { while(time--); }

  • You have configured the UART itself, but not the P3.3/4 pins.
  • Hi! Thanks for your reply. what should I do ?
  • You should configure the pins.

    For example, the driverlib example usci_a_uart_ex1_loopbackAdvance.c has this:

        //P3.4,5 = USCI_A0 TXD/RXD
        GPIO_setAsPeripheralModuleFunctionInputPin(
            GPIO_PORT_P3,
            GPIO_PIN4 + GPIO_PIN5
            );

    (these pins would be wrong for your model)

  • Yes, i have check datasheet of MSP430F5529 MCU. Rx and Tx pin mapping at P3.4 and P3.3. But I see in "gpio.h", comments of brief said that "//! \brief This function configures the peripheral module function in the input direction for the selected pin. This function configures the peripheral module function in the input direction for the selected pin for either primary, secondary or ternary module function modes. Note that MSP430F5xx/6xx family doesn't support these function modes."  My MCU is MSP430F5529 :(

  • The primary/secondary/ternary function mode does not exist in the 5xx/6xx family, so you do not need to care about it. (That text is just for users of other families who wonder where the third parameter of GPIO_setAsPeripheralModuleFunctionInputPin() did go.)
  • Thanks for your help. But I have been add this code at the top of Uart_Init() function

    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P3,GPIO_PIN3 + GPIO_PIN4);

    or this code

    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P3, GPIO_PIN4); // Rx Pin
    GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P3,GPIO_PIN3); // Tx Pin
    
    

    I do not receive any thing :(

  • The code doesn't do anything with the received data. How do you check if it is receiving?
  • I have add Interrupt Service Rountie at the top of main.c. In this function I check the RECEIVE_INTERRUPT_FLAG then read data to receive_data variable. This code here:
    #pragma vector=USCI_A0_VECTOR
    __interrupt void UART_Isr(void)
    {
        if(USCI_A_UART_getInterruptStatus(USCI_A0_BASE,
                USCI_A_UART_RECEIVE_INTERRUPT_FLAG)
                ==  USCI_A_UART_RECEIVE_INTERRUPT_FLAG)
        {
            receive_data=USCI_A_UART_receiveData(USCI_A0_BASE);
            USCI_A_UART_clearInterrupt(USCI_A0_BASE,USCI_A_UART_RECEIVE_INTERRUPT_FLAG);
        }
    }

  • I have a same problem when i test with example in driverlib on msp430F55 , I hope i could get the answer from this post.
  • And what do you then do with the receive_data variable? What do you expect to happen, and what actually happens instead?

**Attention** This is a public forum