Part Number: MSP-EXP430FR2433
Other Parts Discussed in Thread: MSP430FR2433
Hi,
I am trying to configure the standard transceiver example on TI Resource Explorer to work on the P2.5/P2.6 instead of P1.4/P1.5. I got it to work with Port 1 Configurations but am having trouble using P2. Here is the code i'm using.
#include "driverlib.h"
#include <msp430fr2433.h>
//******************************************************************************
// UART Initialization *********************************************************
//******************************************************************************
#define LED_OUT P1OUT
#define LED_DIR P1DIR
#define LED_PIN BIT0
#define SMCLK_115200 0
#define SMCLK_9600 1
#define UART_MODE SMCLK_9600//
void initUART()
{
// Configure USCI_A0 for UART mode
UCA1CTLW0 |= UCSWRST; // Put eUSCI in reset
#if UART_MODE == SMCLK_115200
UCA1CTLW0 |= UCSSEL__SMCLK; // CLK = SMCLK
// Baud Rate Setting
// Use Table 21-5
UCA1BRW = 8;
UCA1MCTLW |= UCOS16 | UCBRF_10 | 0xF700; //0xF700 is UCBRSx = 0xF7
#elif UART_MODE == SMCLK_9600
UCA1CTLW0 |= UCSSEL__SMCLK; // CLK = SMCLK
// Baud Rate Setting
// Use Table 21-5
UCA1BRW = 104;
UCA1MCTLW |= UCOS16 | UCBRF_2 | 0xD600; //0xD600 is UCBRSx = 0xD6
#else
# error "Please specify baud rate to 115200 or 9600"
#endif
UCA1CTLW0 &= ~UCSWRST; // Initialize eUSCI
UCA1IE |= UCRXIE; // Enable USCI_A1 RX interrupt
}
//******************************************************************************
// Device Initialization *******************************************************
//******************************************************************************
void initGPIO()
{
LED_DIR |= LED_PIN;
LED_OUT &= ~LED_PIN;
// Configure GPIO
P2SEL1 &= ~(BIT6 | BIT5); // USCI_A1 UART operation
P2SEL0 |= BIT6 | BIT5;
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
}
void initClockTo16MHz()
{
// Configure one FRAM waitstate as required by the device datasheet for MCLK
// operation beyond 8MHz _before_ configuring the clock system.
FRCTL0 = FRCTLPW | NWAITS_1;
__bis_SR_register(SCG0); // disable FLL
CSCTL3 |= SELREF__REFOCLK; // Set REFO as FLL reference source
CSCTL0 = 0; // clear DCO and MOD registers
CSCTL1 &= ~(DCORSEL_7); // Clear DCO frequency select bits first
CSCTL1 |= DCORSEL_5; // Set DCO = 16MHz
CSCTL2 = FLLD_0 + 487; // set to fDCOCLKDIV = (FLLN + 1)*(fFLLREFCLK/n)
// = (487 + 1)*(32.768 kHz/1)
// = 16 MHz
__delay_cycles(3);
__bic_SR_register(SCG0); // enable FLL
while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)); // FLL locked
CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK;
}
//******************************************************************************
// Main ************************************************************************
// Enters LPM0 if SMCLK is used and waits for UART interrupts. If ACLK is used *
// then the device will enter LPM3 mode instead. The UART RX interrupt handles *
// the received character and echoes it. *
//******************************************************************************
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop Watchdog
initGPIO();
initClockTo16MHz();
initUART();
#if UART_MODE == SMCLK_9600
__bis_SR_register(LPM3_bits + GIE); // Since ACLK is source, enter LPM3, interrupts enabled
#else
__bis_SR_register(LPM0_bits + GIE); // Since SMCLK is source, enter LPM0, interrupts enabled
#endif
__no_operation(); // For debugger
}
//******************************************************************************
// UART Interrupt ***********************************************************
//******************************************************************************
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A1_VECTOR))) USCI_A1_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(UCA1IV, USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
while(!(UCA1IFG&UCTXIFG));
UCA1TXBUF = UCA1RXBUF;
__no_operation();
break;
case USCI_UART_UCTXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
}
}