Other Parts Discussed in Thread: MSP430F6736
I'm trying to send commands from PC to EVM430F6736 via the onboard RS232 port, which is connected to UART1 on the MSP430F6736. For testing, I'm doing a loopback test but the command I'm sending is not being echoed back to the PC. Here are my codes:
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// Setup LFXT1
UCSCTL6 &= ~(XT1OFF); // XT1 On
UCSCTL6 |= XCAP_3; // Internal load cap
// Loop until XT1 fault flag is cleared
do
{
UCSCTL7 &= ~(XT2OFFG | XT1LFOFFG | DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
} while (SFRIFG1 & OFIFG); // Test oscillator fault flag
// Setup P1.4 UCA1RXD, P1.5 UCA1TXD
P1SEL = BIT4 | BIT5;
P1DIR = BIT4 | BIT5 | BIT7;
P1OUT = BIT7;
// Setup eUSCI_A1
UCA1CTL0 = 0; //8 bits, 1 stop bit, no parity, LSB
UCA1CTL1 = UCSSEL__ACLK; //CLK = ACLK
UCA1BR1 = 0x0; // baudrate 9600
UCA1BR0 = 0x3;
UCA1MCTLW_H = 0x92;
UCA1CTL1 &= ~UCSWRST;
UCA1IE |= UCRXIE;
__bis_SR_register(LPM3_bits | GIE); // Enter LPM3, interrupts enabled
__no_operation();
}
// USCI_A1 interrupt service routine
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
switch (__even_in_range(UCA1IV, 4))
{
case USCI_NONE: break; // No interrupt
case USCI_UART_UCRXIFG: // RXIFG
while (!(UCA1IFG & UCTXIFG)) ; // USCI_A1 TX buffer ready?
UCA1TXBUF = UCA1RXBUF; // TX -> RXed character
P1OUT ^= BIT7; // toggle green LED
break;
case USCI_UART_UCTXIFG: break; // TXIFG
case USCI_UART_UCSTTIFG: break; // TTIFG
case USCI_UART_UCTXCPTIFG: break; // TXCPTIFG
default: break;
}
}
For every character I send from Terminal in PC, I toggle the onboard green LED. This works which means receive is ok and the ISR is invoked. However, transmit does not seem to work because I am not receiving anything in the Terminal. Am I missing something?