Part Number: MSP-EXP430FR2311
I am having trouble setting up for a baud rate of 9600 to communicate from my msp430 to a zigbee module, I am getting garbage data on the other module. I have my xbee module connected to pins 1.6 & 1.7, 3.3V and GND.
Any help on what the UCA0MCTL2 value should be set to, or anything else that maybe an issue?
Thanks
#include <msp430.h> unsigned char RXData = 0; unsigned char TXData = 1; int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode // to activate previously configured port settings P1DIR |= BIT0; P1OUT &= ~BIT0; // P1.0 out low // Configure UART pins P1SEL0 |= BIT6 | BIT7; // set 2-UART pin as second function // Configure UART UCA0CTLW0 |= UCSWRST; // Put eUSCI in reset UCA0CTLW0 |= UCSSEL__ACLK; // Baud Rate calculation UCA0BR0 = 3; // 32768/9600 = 3.41333 UCA0MCTLW = 0x06; // 3.41333 - INT(3.4133)=0.4133 // UCBRSx value = ? (not sure) UCA0BR1 = 0; UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt while (1) { while(!(UCA0IFG & UCTXIFG)); UCA0TXBUF = TXData; // Load data onto buffer __bis_SR_register(LPM0_bits|GIE); // Enter LPM0 __no_operation(); // For debugger } } #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=USCI_A0_VECTOR __interrupt void USCI_A0_ISR(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void) #else #error Compiler not supported! #endif { switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG)) { case USCI_NONE: break; case USCI_UART_UCRXIFG: UCA0IFG &=~ UCRXIFG; // Clear interrupt RXData = UCA0RXBUF; // Clear buffer if(RXData != TXData) // Check value { P1OUT |= BIT0; // If incorrect turn on P1.0 while(1); // trap CPU } TXData++; // increment data byte __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0 on reti break; case USCI_UART_UCTXIFG: break; case USCI_UART_UCSTTIFG: break; case USCI_UART_UCTXCPTIFG: break; } }