Part Number: MSP430FR5994
Dear Sirs:
Have not been able to make the uart operate using this launch pad. I've tried two simple programs from the post.
The following is the code for a uart echo program for the MSP430FR5994 launch pad:
This Version, Version A, uses P2 and UCA0 uart. It will receive a character correctly and a receive interrupt is generated. But it will not transmit anything (a scoped): Testing with the launch pad uart.
#include <msp430.h>
/*
* main.c
*/
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
// 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;
UCA0CTLW0 |= UCSSEL__SMCLK; // CLK = SMCLK
// Baud Rate calculation
// 8000000/(16*9600) = 52.083
// Fractional portion = 0.083
// 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
UCA3TXBUF =0x41; //test send 'a' this does nothing!
__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; //program gets here on received char but nothing comes out the tx pin
__no_operation();
break;
case USCI_UART_UCTXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
}
}
---------------------------------------------------------------------------------------------------------------------------------------
This version, version B, uses P6 and UCA3. It can transmit out P6.0 but does not receive on P6.1. Also no interrupts are generated:
#include <msp430.h>
int TempStat;
/*****************************************************************************************************************************
* main.c
*
*****************************************************************************************************************************/
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
// Configure GPIO
P6SEL0 |= BIT0 | BIT1; // USCI_A0 UART operation
P6SEL1 &= ~(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 (int flags 30.3.15.4) for UART mode:
UCA3CTLW0 = UCSWRST; //soft rst enable
UCA3CTLW0 |= UCSSEL__SMCLK; // CLK = SMCLK
// Baud Rate calculation
// 8000000/(16*9600) = 52.083
// Fractional portion = 0.083
// UCBRFx = int ( (52.083-52)*16) = 1
UCA3BR0 = 52; // 8000000/16/9600
UCA3BR1 = 0x00;
UCA3MCTLW |= UCOS16 | UCBRF_1 | 0x4900;
UCA3CTLW0 &= ~UCSWRST; // Initialize eUSCI
UCA3IE |= UCRXIE; // Enable USCI_A0 RX interrupt (int flag reg 30.4.10)
TempStat=UCA3CTLW0 ; //read ctl word 0
TempStat=UCA3IFG ; //read int flags
UCA3TXBUF =0x41; //test send 'a'
__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(UCA3IV, USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG: //2
TempStat=UCA3IFG ; //read int flags
while(!(UCA3IFG & ~UCTXIFG)); //30.4.11
UCA3TXBUF = UCA3RXBUF; //echo
TempStat= UCA3TXBUF; //see what's in there
__no_operation();
break;
case USCI_UART_UCTXIFG:
TempStat=UCA3IFG ; //read int flags
UCA3TXBUF =0x42; //test send 'b'
break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
}
}