Other Parts Discussed in Thread: MSP430WARE,
Dear,
I am a beginner user of the MSP430 (FR6989). For a project I am working on, I need the MSP430 to send data to my PC (so the backchannel seems like the way to go). I wanted to start by useing some example code given by TI themselves, mainly: msp430fr69xx_euscia0_uart_01.c. Which is the following code:
#include <msp430.h> int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop Watchdog // Configure GPIO P2SEL0 |= BIT0 | BIT1; // USCI_A0 UART operation P2SEL1 &= ~(BIT0 | BIT1); // Disable the GPIO power-on default high-impedance mode to activate // previously configured port settings PM5CTL0 &= ~LOCKLPM5; // Startup clock system with max DCO setting ~8MHz CSCTL0_H = CSKEY >> 8; // Unlock clock registers CSCTL1 = DCOFSEL_3 | DCORSEL; // Set DCO to 8MHz CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK; CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers CSCTL0_H = 0; // Lock CS registers // Configure USCI_A0 for UART mode UCA0CTLW0 = UCSWRST; // Put eUSCI in reset UCA0CTLW0 |= UCSSEL__SMCLK; // CLK = SMCLK // Baud Rate calculation // 8000000/(16*9600) = 52.083 // Fractional portion = 0.083 // User's Guide Table 21-4: UCBRSx = 0x04 // UCBRFx = int ( (52.083-52)*16) = 1 UCA0BR0 = 52; // 8000000/16/9600 UCA0BR1 = 0x00; UCA0MCTLW |= UCOS16 | UCBRF_1 | 0x4900; UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt __bis_SR_register(LPM3_bits | GIE); // Enter LPM3, interrupts enabled __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: while(!(UCA0IFG&UCTXIFG)); UCA0TXBUF = UCA0RXBUF; __no_operation(); break; case USCI_UART_UCTXIFG: break; case USCI_UART_UCSTTIFG: break; case USCI_UART_UCTXCPTIFG: break; } }
Of which I have changed nothing. I uploaded the code using Code Composer Studio (compiled using gcc). The of this code says:
Description: This demo echoes back characters received via a PC serial port.
SMCLK/ DCO is used as a clock source and the device is put in LPM3
The auto-clock enable feature is used by the eUSCI and SMCLK is turned off
when the UART is idle and turned on when a receive edge is detected.
Note that level shifter hardware is needed to shift between RS232 and MSP
voltage levels.
However, when I then use Putty on the Port (for me COM11 MPS Application UART1), Putty show an empty terminal in which I am unable to type anything (and nothing is received). I put the Baud Rate of Putty at 9600 (which the code alse seems to do).
How come I cannot echo anything, or read anything? I am probably missing something very basic, but I have no clue what it is.
Thanks!