Hello,
I have looked through the MSP430 forum but failed to find a solution to my problem. Using RealTerm to send RS322 to the MSPG2413, only sometimes the uController catches a byte, loads it into the UCA0RXBUF and sets an interrupt. The problem is, likely, in how the clock is set up, or how the baud rate is set up.
For my set up, I use the "RealTerm: Serial Capture Program 2.0.0.0.70" connecting to my MSP430G2413. here is the code morphed from the samples.
i = 0; //
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR = 0xBD; // P1.1,6 are input, p1.7 is I/O set to output
P1SEL = BIT1 + BIT2 ; // P1.1 = Serial RXD, P1.2 = Serial TXD. Setting both corresponding bits
P1SEL2 = BIT1 + BIT2 ; // selects the Serial peripheral logic
P1SEL |= BIT6 + BIT7; // P1.6 = I2C SCL, P1.7 I2C SDA. Setting both corresponding bits selects
P1SEL2|= BIT6 + BIT7; // the I2C peripheral logic
P1IE = 0x41; //
P1IFG = 0x00; //
P1OUT = 0x00; // All P1.x reset
//
P2DIR = 0x42; // P2.1,6 are outputs. These control the Serial bus switch
P2SEL = 0x00; //
P2SEL2 = 0x00; //
P2IE = 0x00; //
P2IFG = 0x00; //
P2OUT = 0x00; // All P2.x reset
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ; //
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 17; // 1MHz/17 = 58,800 or ~57,600
UCA0BR1 = 0; // 1MHz
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
//---------------debug---------------
while (1);
//---------------debug---------------
IE2 |= UCA0RXIE; // . . . . Enable USCI_A0 RX interrupt
__bis_SR_register(GIE); //use (LPM3 +GIE) l8tr to turn off the CPU waiting for a Serial Rx int
The code loops at the while so that the UCA0RXBUF register and the IFG2.UCA0RXIFG bit can be manually verified.
Your comment on the possible errors will be appreciated.