4

I'm connecting 2 MSP430F5529-based boards (running at 1 MHz) using UART and MAX3232 (MSP430F5529 -> MAX3232 -> cable, a few cm long - will be longer in our final application -> MAX3232 -> MSP430F5529).

It works as long as the bit rate of the UART is under 9600 bps. If this is raised, I start getting many errors (usually the MSB is flipped).

If I remove the MAX3232 and connect the boards directly, the problem goes away. It doesn't happen if I loopback, too.

I am running the MAX3232 at 3 V, which the datasheet says is enough:

Transmitter outputs will meet EIA/TIA-562 levels of ±3.7V with supply voltages as low as 2.7V.

What am I doing wrong?

My code on the TX side is:

void UART_Initialize() {

    UCA1CTL1 |= UCSWRST;
    UCA1CTL0 = UCMODE_0; // UART
    UCA1CTL0 &= ~UC7BIT ; // 8 bits, no parity, 1 stop bit
    UCA1CTL1 |= UCSSEL_2; // Source 1 MHz


    UCA1BR0 = 104; // 104 ~= 9600 bps 
    UCA1BR1 = 0;  

    UCA1MCTL |= UCBRS_0 + UCBRF_0; // Modulation
    P4SEL |= BIT4 + BIT5;
    UCA1CTL1 &= ~UCSWRST;
    UCA1IE |= UCRXIE;
}


void UART_send_data(unsigned char character) {
    while (!(UCA1IFG & UCTXIFG));
    UCA1TXBUF = character;
}

unsigned char UART_get_char() {
    while (!(UCA1IFG & UCRXIFG));
    return UCA1RXBUF;
}

void UART_shutdown() {
    UCA1IE &= ~(UCRXIE|UCTXIE);
    UCA1CTL1 = UCSWRST;
}


int main() {
    unsigned char received_data;

    P4OUT = 0x00;
    // Disables the watchdog
    WDTCTL = WDTPW + WDTHOLD;

    // CPU clock to 1 MHz

    UCSCTL0 = 0x00;
    UCSCTL1 = DCORSEL_3;  
    UCSCTL2 = FLLN5_L;

    __enable_interrupt();
    UART_Initialize();

    while(1) UART_send_data(0x55);

}

On the RX side the code is similar except for main() (which just receives the value and compares to 0x55).

Renan
  • 5,090
  • 2
  • 27
  • 45

1 Answers1

1

Definitely sounds like a timing issue. I think your clock is running too fast and instead of bit 7 being sampled, the following stop bit (HIGH) is shifted into the shift register.

jippie
  • 33,033
  • 16
  • 93
  • 160