This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I am currently working with CC2520DK kit.I have a stand-alone application,that activates UART A1 module of MSP4302618.The application writes data to PC and receives data from PC.
The UART A0 of MSP430 works well,while UART A1 has only right TX functionality (Tx to PC,i am successufully write the information to PC).When i trying to receive data from PC,the UART A1 RX BUF is always 0 and flag isn't activated.
I check the serial cable with scope and it works well on both directions....,so the cable isn't a problem,espacially it works on UART A0.
Please help me.
I work with TI example file for UART A1: MSP430x261x_uscia0_uart_01.c and change the configuration to UART A1.
I wrote that my HW is
1) CC2520DK evaluation board(SmartRF05 EB1.3) with CCMSP-EM430F2618 1.0.
2) I am starting with MSP430x261x_uscia1_uart_02.c and continue with my modifications of MSP430x261x_uscia0_uart_01.c.See the file below.
#include
"msp430x26x.h"
#include
"stdio.h"
#include
"string.h"
unsigned
short Uart_Write(const unsigned char* buf, unsigned short length);
#pragma
inline
void
printStr(char *sz )
{
char lineFeed = '\r';
Uart_Write((
unsigned char*)sz, (unsigned short) strlen(sz));
// if last character is newline, add carriage return
if(*(sz+(strlen(sz)-1)) == '\n')
Uart_Write((
unsigned char*)&lineFeed,1);
}
#pragma
optimize=none
void
write_log(const char *format, ...)
{
char s[200];
va_list args;
va_start(args, format);
/* Variable argument begin */
vsprintf(s,format,args);
va_end(ap);
/* Variable argument end */
printStr(s);
}
unsigned
short Uart_Write(const unsigned char* buf, unsigned short length)
{
unsigned char i;
for(i = 0; i < length; i++)
{
while(!(UC1IFG & UCA1TXIFG)); // Wait for TX buffer ready to receive new byte
UCA1TXBUF = buf[i];
// Output character
}
return (i+1);
}
void
main(void)
{
WDTCTL = WDTPW + WDTHOLD;
// Stop WDT
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
{
while(1); // If calibration constants erased
// do not load, trap CPU!!
}
BCSCTL1 = CALBC1_1MHZ;
// Set DCO
DCOCTL = CALDCO_1MHZ;
P3SEL = 0xC0;
// P3.6,7 = USCI_A1 TXD/RXD
UCA1CTL1 |= UCSSEL_2;
// SMCLK
UCA1BR0 = 8;
// 1MHz 115200
UCA1BR1 = 0;
// 1MHz 115200
UCA1MCTL = UCBRS2 + UCBRS0;
// Modulation UCBRSx = 5
UCA1CTL1 &= ~UCSWRST;
// **Initialize USCI state machine**
UC1IE |= UCA1RXIE;
// Enable USCI_A1 RX interrupt
__bis_SR_register(GIE);
// interrupts enabled
volatile unsigned char index = 0,index2 = 13,data = 250;
while (1)
{
if (index == 0)
write_log(
"index = %d,index2 = %d\n",index++,index2++); //once out Tx UART1 to PC
__delay_cycles(800000);
//without any RX UART,enter on PC chars and receive it back on Rx UART1
//by writre_log(),you can read it on PC screen.I am using by TeraTerm
//application on PC.
//if ((UC1IFG & UCA1RXIFG))
{
data = UCA1RXBUF;
write_log(
"data = %d\n",data);
}
}
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma
vector=USCIAB1RX_VECTOR
__interrupt
void USCI1RX_ISR(void)
{
while (!(UC1IFG&UCA1TXIFG)); // USCI_A1 TX buffer ready?
UCA1TXBUF = UCA1RXBUF;
// TX -> RXed character
}
On the CC2520DK there are 2 resistors (zero ohm) that shorts between the UART1 and the CC2520 GPIOs. I think they are colliding. Should we remove them? (see the schematics of CC2520DK)
**Attention** This is a public forum