Hi everyone,
I am using UART to send lots of data from 1 MSP to another. I am running a 4MHz clock, and the baud rate is 115200. But after the first byte is sent, when I check if the Txbuf is ready, UART gets stuck. i,e,
TXBUF0 = 0x00; // Random data while (!(IFG1 & UTXIFG0)); // Code gets stuck here
This is because the UTXIFG0 is never set after data transmission OR it is set and immediately cleared by the empty UART0 ISR.
#pragma vector=USART0TX_VECTOR
__interrupt void usart0_tx (void)
{
__no_operation();
}
MSP430 forces me to provide this ISR even though it contains no instructions. If no ISR is provided, it raises an NMI.
As a workaround, I use __delay_cycles(1200) instead. Here anything less than 1200 results in missing bits and these number of cycles remains constant irrespective of the baud rate (I would expect lesser no of cycles for lower baud rates). Since I am sending lots of data, this is becoming a bottleneck for me.
This is how I configure UART:
UCTL0 |= CHAR; UTCTL0 |= SSEL1; UBR00 = 0x22; // 115200 Baud rate UBR10 = 0x00; UMCTL0 = 0xDD; ME1 |= URXE0 + UTXE0; // Enable USART0 TXD/RXD P3SEL |= 0x30; P3DIR |= BIT4; P3DIR &= ~BIT5; UCTL0 &= ~SWRST; // Initialize USART state machine IE1 |= UTXIE0 + URXIE0; // Enable USART0 RX interrupt
Why does something like this happen and how do i overcome this?
Best Regards,