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.

CC2531 API function HalUARTRead failed



I am using Z-Stack Mesh 1.0.0 Generaic Application with CC2531. Hardware in use is CC2530ZDK.

HalUARTWrite(....) successfully send message to e.g., hyper-terminal. But HalUARTRead(...) function does not read any keystroke from hyper-terminal. This problem apparently seem to be a port issue (port parameter for HalUARTRead function may be wrong ). The function HalUARTRead does not make any difference to the message buffer passed as parameter.

I tried following ports,

MT_UART_DEFAULT_PORT

HAL_UART_PORT

HAL_UART_PORT1


If HalUARTRead(..) calls with the sequence of API functions, then mention the names and sequence of functions used to read from the UART.

  • To receive UART data from terminal application, you should do the following steps

    1. You can put the UART init code in GenericApp_Init().

    halUARTCfg_t uartConfig;
     uartConfig.configured = TRUE;
     uartConfig.baudRate = HAL_UART_BR_115200; //HAL_UART_BR_1M;
     uartConfig.flowControl = HAL_UART_FLOW_OFF;
     uartConfig.flowControlThreshold = 48;
     uartConfig.rx.maxBufSize = 128; //max if DMA gets enabled, don't think it is, but just in case
     uartConfig.tx.maxBufSize = 128;
     uartConfig.idleTimeout = 6;
     uartConfig.intEnable = TRUE;
     uartConfig.callBackFunc = UartProcessData;

    HalUARTOpen (HAL_UART_PORT_1, &uartConfig);

    2. Add the following UART RX callback function into your GenericApp.c to receive UART characters.

    void UartProcessData ( uint8 port, uint8 event )
    {
      uint8  ch;
      uint8  bytesInRxBuffer;
      

      //Read bytes from UART RX buffer
      while (Hal_UART_RxBufLen(port))
      {
        HalUARTRead (port, &ch, 1);
      }
    }