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.

CC2541: CC2541 Serial Communication

Part Number: CC2541

Hi,

I'm trying to communicate CC2541 with an Arduino via UART. I want to read some values from Arduino and send them to CC2541. 

I've been going through a lot of example codes you have in TIWiki but when I try to develop my own code it doesnt work.

I don't really know what I'm doing wrong cause the code, except I'm directly using hal_uart, is mostly the same:

void SerialInterface_Init( uint8 task_id )
{
  
  serialInterface_TaskID = task_id;
  
  //Configure UART And register callback function
  halUARTCfg_t uartConfig;

  // configure UART
  uartConfig.configured           = TRUE;
  uartConfig.baudRate             = HAL_UART_BR_9600;
  uartConfig.flowControl          = FALSE;
  uartConfig.flowControlThreshold = UART_FC_THRESHOLD;
  uartConfig.rx.maxBufSize        = UART_RX_BUF_SIZE;
  uartConfig.tx.maxBufSize        = UART_TX_BUF_SIZE;
  uartConfig.idleTimeout          = UART_IDLE_TIMEOUT;
  uartConfig.intEnable            = UART_INT_ENABLE;
  uartConfig.callBackFunc         = (halUARTCBack_t)cSerialPacketParser;

  // start UART
  // Note: Assumes no issue opening UART port.
  HalUARTOpen( UART_PORT, &uartConfig );
}


//callback function To proccess UART Data
void cSerialPacketParser( uint8 port, uint8 events )
{  
  uint8 bytesLeft= NPI_RxBufLen();
  uint8 totalBytes = bytesLeft;
  //Allocate te packet
  uint8 *temp_buf;
  temp_buf = osal_mem_alloc( totalBytes );
         
  //Get the buffer
  HalUARTRead( UART_PORT, temp_buf, totalBytes );
         
  for(int i=0;i< totalBytes;i++)
     printf(temp_buf[i]);
         
  osal_mem_free(temp_buf);
}

The result is that it doesn't read anything despite I double checked that Arduino is transmitting.

Cheers!