Tool/software:
Hello,
I'm currently rewriting some code for an old product. It has a MSP430F microcontroller and uses a ISL83077E RS422 transceiver. The default implementation uses a 115200 baudrate with RTS/CTS hardware flow control.
With 9600 everything seems to function great; RX interrupt fires, I pop the received character into a circular buffer and exit:
#pragma vector=USART0RX_VECTOR __interrupt void USART0RX_ISR(void) { rx_buf[rx_buf_write_idx++] = (uint8_t)U0RXBUF; if (rx_buf_write_idx == 32) { rx_buf_write_idx = 0; } }
However, when I up the baud rate to 115200 I lose data. By the time the RX interrupt fires and I load the first byte it's already missed the first 5 or so bytes, it then continues to miss the majority of the data with the odd byte getting through. I've played around with code optimisation and compiler optimisation levels but nothing changes. I've also tried different baud rates (higher than 9600) but all have the same problem.
Clock source is 8 MHz crystal /4 for 4 MHz on SMCLK:
BCSCTL1 = 0; // Enable XTAL2 (no ACLK) BCSCTL2 = SELM_2 + SELS + DIVM_1 + DIVS_1; // Main X2 clock for SM, /2 from 8M to 4M IFG1 &= ~OFIFG;
UART init:
#define CLOCK_RATE (4000000L) #define BAUD_RATE (115200L) #define BAUD_MOD (0xDD) #define BAUD_RELOAD ((uint32_t)(CLOCK_RATE / BAUD_RATE)) UCTL0 = SWRST; UBR10 = (BAUD_RELOAD >> 8) & 0xFF; UBR00 = (BAUD_RELOAD & 0xFF); UMCTL0 = BAUD_MOD; P3DIR |= BIT2; // CTS output P3OUT |= BIT2; P3SEL |= BIT4 + BIT5; // Set UART function UCTL0 = CHAR + SWRST; UTCTL0 = SSEL1 + TXEPT; // 8 bit, no parity, 1 stop bit ME1 |= UTXE0 + URXE0; // Enable TX & RX UCTL0 = CHAR; IE1 |= URXIE0; // Enable RX interrupt P3OUT &= ~BIT2; // Ready to receive _EINT();
Any ideas or suggestions would be greatly appreciated.