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.

cc2530 and uart

Other Parts Discussed in Thread: CC2530, TIMAC, Z-STACK

Dear all:

void InitUart(void)
{
PERCFG = 0x00;
P0SEL |= 0x30; //P0_4,P0_5 as uart1
P2DIR &= ~0xC0; 

U1CSR |= 0x80; 
U1GCR |= 11;
U1BAUD |= 216; //115200

UTX1IF = 0; 
U1CSR |= 0x40;
IEN0 |= 0x88;
}

#pragma vector = URX1_VECTOR
__interrupt void UART1_ISR(void)
{
URX1IF = 0;
RxBuf = U1DBUF;
}

void UartSendString(char *Data, int len)
{
uint i;

  for(i=0; i<len; i++)
  { 
    U1DBUF = *Data++;
    while(UTX1IF == 0); 
    UTX1IF = 0;
  }
}

void main(void)
{
char RxData[TX_SIZE];
unsigned char count=0;

CLKCONCMD &= ~0x40; 
while(CLKCONSTA & 0x40);  
CLKCONCMD &= ~0x47;  

InitUart();  
memset(RxData, 0, TX_SIZE);  
memset(TxData, 0, TX_SIZE);  
memcpy(TxData, TX_STRING, sizeof(TX_STRING));  

UartSendString("hello ", 6);
while(1)
{

if(RxBuf != 0)
{
if((RxBuf != '#')&&(count < 10))
RxData[count++] = RxBuf;
else
{
UartSendString(RxData, count); //send msg back to PC
count = 0;
}
RxBuf = 0;
}
}
}

 the uart1 can send message and the   PC serial port assistant can print messge :hello

but  the cc2530 can't recv any message from PC serial port.

Best Regards & thanks

JKing

  • Hi JKing,

    Which software package are you using? If you install TIMAC or Z-Stack, you will find hal_uart.c, hal_uart.h, _hal_uart_dma.c, and _hal_uart_isr.c. I would encourage you to use those functions since they have been verified.

    - Cetri

  • Hi Cetri,

       Thank u for your help, i have solved tha problem.

        But now i am trying to use uart1 (PINT58,PINT59), configured it like this(just same as uart0):

    uart0 setting:(works OK)

    MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);

    MAP_PinTypeUART(PIN_55, PIN_MODE_3);

    MAP_PinTypeUART(PIN_55, PIN_MODE_3);

    uart1 setting:(didn't work)

    MAP_PRCMPeripheralClkEnable(PRCM_UARTA1, PRCM_RUN_MODE_CLK);

    MAP_PinTypeUART(PIN_58, PIN_MODE_6);

    MAP_PinTypeUART(PIN_59, PIN_MODE_6);

    example:

    MAP_UARTCharPutNonBlocking(UART1_BASE,c); //didn't work

    Does it have any question wrong? How could i configure uart1 and use it ?

    Thanks

    JKing