Other Parts Discussed in Thread: MSP430I2021, MSP430I2040
Tool/software: Code Composer Studio
I am using the MSP430F5342 chip on a set of boards and had previously written code that included UART communication. The board would receive a command from my computer via UART, which would tell the board to begin sending sensor data back to the computer. I had tested the code and it worked very well. I then rearranged some code and saved the project under a different name. I then did not touch the boards for a month or so.
When I recently downloaded the code, I noticed that the UART communication was no longer firing. After modifying the code to skip the UART receive check and jump straight into transmitting, I noticed that the transmit from the board worked perfectly fine. I then reverted my code back to the version that I had previously confirmed worked, and the receive still did not work. I then tried example code for a simple UART echo (posted below), and it still did not work..
I have tested these code versions on 4 different boards, using two different FET programmers and FTDI cables. I have also checked continuity on the cables, so I am pretty sure that it is not a hardware issue.. I'm wondering what could possibly stopping the UART Receive from functioning. I've tried debugging the code and setting breakpoints and stepping through the code/monitoring the registers, but the RX buffer and flags never register any data.
I had an issue with an MSP430i2021 board before that was not functioning properly, and it turned out that I needed to include a low_level_init.c to execute a _system_pre_init function. However, in the example code for the F5342, I do not see any additional files like this. I'm wondering if there's any code that I can run to reset whatever has stopped the UART from functioning properly. Any advice is greatly appreciated!
Thanks,
John
#include <msp430.h> int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P3SEL |= BIT3+BIT4; // P3.3,4 = USCI_A0 TXD/RXD UCA0CTL1 |= UCSWRST; // **Put state machine in reset** UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 = 9; // 1MHz 115200 (see User's Guide) UCA0BR1 = 0; // 1MHz 115200 UCA0MCTL |= UCBRS_1 + UCBRF_0; // Modulation UCBRSx=1, UCBRFx=0 UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt __bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled __no_operation(); // For debugger } // Echo back RXed character, confirm TX buffer is ready first #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,4)) { case 0:break; // Vector 0 - no interrupt case 2: // Vector 2 - RXIFG while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready? UCA0TXBUF = UCA0RXBUF; // TX -> RXed character break; case 4:break; // Vector 4 - TXIFG default: break; } }