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.

UART on cc2530

Other Parts Discussed in Thread: CC2530

Hi,

I have been trying to communicated with CC2530 over UART. I have been successful in communicating with the cc2530 chip. But the call back is called only once

In my init function I init the UART

SerialApp_RxSeq = 0xC3;
halUARTCfg_t uartConfig;
uartConfig.configured = TRUE; // 2x30 don't care - see uart driver.
uartConfig.baudRate = SERIAL_APP_BAUD;
uartConfig.flowControl = TRUE;
uartConfig.flowControlThreshold = SERIAL_APP_THRESH; // 2x30 don't care - see uart driver.
uartConfig.rx.maxBufSize = SERIAL_APP_RX_SZ; // 2x30 don't care - see uart driver.
uartConfig.tx.maxBufSize = SERIAL_APP_TX_SZ; // 2x30 don't care - see uart driver.
uartConfig.idleTimeout = SERIAL_APP_IDLE; // 2x30 don't care - see uart driver.
uartConfig.intEnable = TRUE; // 2x30 don't care - see uart driver.
uartConfig.callBackFunc = SerialApp_CallBack;
HalUARTOpen (SERIAL_APP_PORT, &uartConfig);

SerialAppCallBack is being called the first time. But there onwards its not being called. How do i ensure that i keep recieving the data that I send over UART ?

  • I Got somethign working under SERIAL_APP_LOOPBACK

    Looks like until you reply back with HalUARTWrite its not accepting any more callbacks. Is this the expected behaviour ?
  • I figured out. In the Serial APP SerialApp_TxLen is not being reset after HalUARTRead. Hence the condition in callback was failing. This is not an issue. THanks
  • Adding    SerialApp_TxLen = 0; marked in red in the below code worked.

    /*********************************************************************

    * @fn      SerialApp_Send

    *

    * @brief   Send data OTA.

    *

    * @param   none

    *

    * @return  none

    */

    static void SerialApp_Send(void)

    {

    #if SERIAL_APP_LOOPBACK

     if (SerialApp_TxLen < SERIAL_APP_TX_MAX)

     {

       SerialApp_TxLen += HalUARTRead(SERIAL_APP_PORT, SerialApp_TxBuf+SerialApp_TxLen+1,

                                                       SERIAL_APP_TX_MAX-SerialApp_TxLen);

     }

     if (SerialApp_TxLen)

     {

       (void)SerialApp_TxAddr;

       if (HalUARTWrite(SERIAL_APP_PORT, SerialApp_TxBuf+1, SerialApp_TxLen))

       {

        SerialApp_TxLen = 0;

       }

       else

       {

         osal_set_event(Atom8_TaskID, SERIALAPP_SEND_EVT);

       }

     }

    #else

     if (!SerialApp_TxLen &&

         (SerialApp_TxLen = HalUARTRead(SERIAL_APP_PORT, SerialApp_TxBuf+1, SERIAL_APP_TX_MAX)))

     {

       // Pre-pend sequence number to the Tx message.

       SerialApp_TxBuf[0] = ++SerialApp_TxSeq;

     }

     if (SerialApp_TxLen)

     {

       if (afStatus_SUCCESS != AF_DataRequest(&Atom8_DstAddr,

                                              (endPointDesc_t *)&Atom8_epDesc,

                                               ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT,

                                               SerialApp_TxLen+1, SerialApp_TxBuf,

                                               &SerialApp_MsgID, 0, AF_DEFAULT_RADIUS))

       {

         osal_set_event(Atom8_TaskID, SERIALAPP_SEND_EVT);

       }

       SerialApp_TxLen = 0;

     }

    #endif

    }

  • can u pls suggest me how to display the Zigbee Coordinator values to be printed in the system.
    where to write the UART code.
    Can u pls send me the UART code
  • You can refer to MT_UART.c in SampleLight example.