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,¶);
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--);
}