Hello All,
I am evaluating my UART communication with MSP430F6779 device, which is mounted on customized board. I am currently can send the data on its UCA0TXBUF to send it to end device, but I am unable to Rx data continuously. I am expecting my device to receive continuous data over longer time.
Following are the Code which I have developed. Kindly go through it.
#include <msp430.h>
#include <string.h>
unsigned char uartrcv(unsigned char x,int y);
unsigned char b,v,w;
unsigned char rx[40];
int i,c,t;
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// Setup P3.0 UCA0RXD, P3.1 UCA0TXD
P3SEL0 |= BIT0 | BIT1; // Set P3.0, P3.1 to non-IO
P3DIR |= BIT0 | BIT1; // Enable UCA0RXD, UCA0TXD
// Setup LFXT1
UCSCTL6 &= ~(XT1OFF); // XT1 On
UCSCTL6 |= XCAP_3; // Internal load cap
// Loop until XT1 fault flag is cleared
/*
do
{
UCSCTL6 &= ~(XT2OFFG | XT1LFOFFG | DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
}
while (SFRIFG1 & OFIFG); // Test oscillator fault flag
*/
// Setup eUSCI_A0
UCA0CTLW0 |= UCSWRST; // **Put state machine in reset**
UCA0CTLW0 |= UCSSEL_1; // CLK = ACLK
UCA0BRW_L = 0x03; // 32kHz/9600=3.41 (see User's Guide)
UCA0BRW_H = 0x00; //
UCA0MCTLW = 0x5300; // Modulation UCBRSx=0x53, UCBRFx=0
UCA0CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCTXIE|UCRXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(GIE);
// Enter LPM3, interrupts enabled
__no_operation(); // For debugger
}
// USCI_A0 interrupt service routine
#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 USCI_NONE:
break; // No interrupt
case USCI_UART_UCRXIFG: // RXIFG
uartrcv(b,c);
break;
case USCI_UART_UCTXIFG:
break; // TXIFG
case USCI_UART_UCSTTIFG:
break; // TTIFG
case USCI_UART_UCTXCPTIFG:
break; // TXCPTIFG
default: break;
}
}
unsigned char uartrcv(unsigned char x,int y)
{
int t=0;
//while (!(UCRXIFG));
//{
for (t=0;t<8;t++)
{
__delay_cycles(2000000);
rx[t]= UCA0RXBUF;
}
//}
return(0);
}
In short, TX section is working with delay of 10000 count. But for the same delay_count i am unable to receive data, even i have increased the delay so that controller can read the data.
If anyone can resolve this issue?
Thank you.