Part Number: MSP430I2041
Tool/software: Code Composer Studio
Dear all,
I want to send a string via UART, the issue is it only sends the first character, I would really appreciate some help in this regards. The code is attached below:
//Intialisation bit:
//UART
P1SEL0 |= BIT2 | BIT3; // P1.2/3 eUSCI_A Function
P1SEL1 &= ~(BIT2 | BIT3);
UCA0CTL1 |= UCSWRST; // Hold eUSCI in reset
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 0xAA; // 9600 baud
UCA0BR1 = 0x06;
UCA0MCTLW = 0xD600; // 16.384MHz/9600 = 1706.6667 (See UG)
UCA0CTL1 &= ~UCSWRST; // Release from reset
UCA0IE |= UCRXIE; // Enable RX interrupt
// Setting the DCO to use the internal resistor. DCO will be at 16.384MHz
CS_setupDCO(CS_INTERNAL_RESISTOR);
CS_initClockSignal(CS_SMCLK, CS_CLOCK_DIVIDER_1);
// Interrupt routine
void USCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV, USCI_UART_UCTXCPTIFG)) {
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
u = 0;
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
{
sprintf(randomstr, "%d", p_results_2);// convert p_result_2 to string
while (randomstr[u] != '\0')
{
UCA0TXBUF = randomstr[u];
u++;
//UCA0TXBUF = 0x0a;
}
UCA0TXBUF = 0x0a;
UCA0TXBUF = 0x0d;
u = 0;
}
break;
case USCI_UART_UCTXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
default: break;
}
}
Regards
Neal