Tool/software: Code Composer Studio
Hello,
I am trying to print a string on Teraterm terminal via P4.4 & P4.5 UART of MSP430F5529LP. I am printing the string only once and just to test it I have not put my code in infinite loop. The issue is I am receiving garbage values continuously after I have received the string once on Teraterm.
These are the garbage values I am receiving after the string:
The baudrate on the terminal and configuration code is the same(i.e., 115200). When I am putting the breakpoint in the function and checking the main code using step in debugging, the code works fine and I do not receive any garbage value except the string. It is when I run the code without the breakpoint I am receiving garbage values after the string. I also checked the last value in UCA1TXBUF register, which is the last value of the string character transmitted.
The below "printstring" function is what I have written for passing the string:
void printstring(char *buff,char length)
{
int i;
for(i=0;i<length;i++,buff++)
{
while (!(UCA1IFG&UCTXIFG));
UCA1TXBUF = *buff;
}
}
The following is the initialization code of UART I am using:
void initUART()
{
P4SEL |= BIT5+BIT4; // P3.3,4 = USCI_A0 TXD/RXD
UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL1 |= UCSSEL_2; // SMCLK
UCA1BR0 = 9; // 1MHz 115200 (see User's Guide)
UCA1BR1 = 0; // 1MHz 115200
UCA1MCTL |= UCBRS_1 + UCBRF_0; // Modulation UCBRSx=1, UCBRFx=0
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
}
The below is the main code I am testing:
#include <msp430f5529.h> #include "UART.h"
int main(void) { initUART(); __asm("NOP"); printstring("Hello",5); }
Would be great if someone can help me on this.
Thanks
