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.

CC2650DK receive data via UART

Other Parts Discussed in Thread: CC2640, OPT3001

Hello:

If I want to receive data from UART , Does Ti have any Sample code reference ?

I want to revise SimpleBLEPeripheral.c .

I get data is SimpleBLEPeripheral_processCharValueChangeEvt(uint8_t paramID) 

but it's only receiver BLE protocol , I want to  receiver command from UART.

Thank you.

  • Hello Tzuyu,

    Please see the article on the BLE Wiki on how to add serial (UART / SPI) to your project. There are a few examples listed.

    You can also reference the TI CC2640 BLE to UART TI Design, which is also listed on the TI BLE Wiki.

    Best wishes
  • You can refer to section 6.3.2 UART in SWRU393_CC2640_BLE_Software_Developer's_Guide
  • In fact , I have already let UART receive data , but I still don't know , How does let data
    send to SimpleBLEPeripheral_processCharValueChangeEvt{...} ?
  • The easiest way is to use a global array to store the received UART data and you can access it in SimpleBLEPeripheral_processCharValueChangeEvt.
  • Can you tell me how exactly to do ?

    my main.c receiver data via UART function:

    char   rx_buffer[20];

    char   *ptr;

    Uint32 seconds;

    char   sec_str[20];

    /* Create a UART with data processing off. */

    ..

    ..

    ..

    ptr = rx_buffer;

    memset(rx_buffer, '\0', sizeof(rx_buffer));

    while (1) {

           UART_read(uart, (void *)ptr, 1); //read UART data

           if (isdigit(*ptr)){

            ++ptr;

           } else if (*ptr == '!'){

                *ptr = '\0';

                 ptr = rx_buffer;

                 seconds = atoi(rx_buffer);

                 sprintf(sec_str,"%u",seconds);

                 System_printf("receive: %u\n",seconds);

                LCD_WRITE_STRING(sec_str,LCD_PAGE3);

                 Seconds_set(seconds + 8 * 60 * 60);

                 ptr = rx_buffer;

                memset(rx_buffer, '\0', sizeof(rx_buffer));

    }

    and SimpleBLEPeripheral.c function SimpleBLEPeripheral_processCharValueChangeEvt{...}

    uint8_t newValue;

    case SIMPLEPROFILE_CHAR3:
    SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, &newValue);

    if (newValue & 0x10)  //receive 0x10 from UART ?
    {
               PIN_setOutputValue(hLedPins, Board_LED1, 1);
               OPT3001();   // sensor read 
    }

  • I am refer

    according to svendbt's sample code , I get some messages:

    and I also find this function seems not to working:

    void UART_enqueueMsg(uint16_t data){
              uartEvt_t *pMsg;

             // Create dynamic pointer to message
              if (pMsg = ICall_malloc(sizeof(uartEvt_t))){
                       pMsg->event = UART_EVT;
                       pMsg->data = data;

            // Enqueue the message.
               Util_enqueueMsg(appMsgQueue, sem, (uint8*)pMsg);
          }
    }

    does someone knows what's happen , Thank you.