Other Parts Discussed in Thread: MSP430FR6877
Greetings,
I am attempting to establish communication between the MSP430FR4133 and MSP430FR6877 MCUs using UART. The MSP430FR4133 uses a 32.768 KHz external crystal for its operation. Below is a snippet of my code for UART initialization:
void initUART()
{
P1SEL0 |= (BIT0 | BIT1);
UCA0CTLW0 &= ~(UCSYNC);
UCA0CTLW0 |= UCSWRST; // Put eUSCI in reset
UCA0CTLW0 |= UCSSEL__UCLK; // CLK = UCLK
UCA0BR0 = 3; // 32000/9600
UCA0BR1 = 0x00;
UCA0MCTLW &= ~(UCOS16);
UCA0CTLW0 &= ~(UCSWRST); // Initialize eUSCI
UCA0IE |= UCRXIE;
}
the string i am sending is as follows
guckfactor_array[8] = '\0';
guckfactor_array[7] = (((int) digit8) + 0x30);
guckfactor_array[6] = (((int) digit7) + 0x30);
guckfactor_array[5] = (((int) digit6) + 0x30);
guckfactor_array[4] = (((int) digit5) + 0x30);
guckfactor_array[3] = (((int) digit4) + 0x30);
guckfactor_array[2] = (((int) digit3) + 0x30);
guckfactor_array[1] = (((int) digit2) + 0x30);
guckfactor_array[0] = (((int) digit1) + 0x30);
initUART();
UARTPutString(guckfactor_array);
In the code, the string is constructed by assigning each digit to the array element and converting it to ASCII.
the snippet for sending data to the uart is as follows
void UARTPutString(char *str)
{
unsigned int i=0;
while(str[i]!='\0') //check for NULL character to terminate loop
{
while(!(UCA0IFG & UCTXIFG));
UCA0TXBUF = str[i];
__delay_cycles(10);
i++;
}
}
However, when the first byte is written to UCA0TXBUF
, the UCTXIFG
flag is reset, but the UCTXCPTIFG
flag remains unset. Consequently, the program enters an infinite loop at the while condition. It seems that the data is not being successfully transferred to the shift register by TXBUF
.how do i know if the data is being put into the shift register by TXBUF? i dont see anything on PuTTY.what do i infer from this?.Please Review the code and suggest a solution.CCS version is 12.0.0
Thanks and Regards.
Pratik.