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.

RTOS/CC2640R2F: How to enable uart interrupt and receive Data

Part Number: CC2640R2F


Tool/software: TI-RTOS

Hi,

I need to receive data via uart using interrupt( uart hardware interrupt) Can anyone suggest me how enable interrupt and receive data with an example.

Thanking you,

Vijay Rakesh

  • Hi David,

    I referred to that example but it's using uart blocking method. I need in interrupt method such as while my program is running when ever a serial event occurs it should receive the data. If I use uart_read(); it's block my program until data is received or if use want use uart_readPolling I don't know when serial data is coming and I'm missing my data, So if it is an interrupt mechanism when ever there is a incoming data it will automatically jump to function and Receive data in to a buffer. Please give me an example using a interrupt control.
  • Hi,

    I changed the uartecho example to use callback (for the read).

       Hopefully this helps.

         David

  • Hi David,

    Thanks for the reply, Now I'm able receive data upon interrupt but in ReadCallback function i'm try to send a notification but my program is hanging (code is below) when i comment  the notification service its working perfectly. I couldn't understand the reason why it was hanging.

    static void readCallback(UART_Handle uart, void *rxBuf, size_t size)
    {
    uint8_t  Data[5];
    UART_write( uart, rxBuf, 5 );
    memcpy( Data , rxBuf ,5 );
    BleNewService_SetParameter(BNS_BLE_NEW_SERVICE_NEW_CHARACTERISTIC_ID ,5 , Data );
    UART_read( uart, rxBuf , 5 );
    return;
    }

    Regards,

    Vijay Rakesh

  • Hi David

    Do I need to call every time UART_read() before I receive some data? If I call once at initialization I'm able to receive data through interrupt for once and from second time I'm not able to receive any data. If keep in uart_read() call after receiving a data I'm able to receive data for few times and then my program stops running. Please give me any solution for this problem.

    Regards

    Vijay Rakesh

  • Hi Vijay,

    Take note from the BLE SW User's Guide that you cannot make ICall API calls (i.e., protocol stack API) from a SWI or HWI context which is likely readCallback is executing as. Try setting an event to your app task and make your BleNewService_SetParameter call from your task.

    Please give this a try and let me know if you have more questions.

    David
  • Hi David,

    Thanks for reply, I have two questions

    1. Uart_read is not receiving data when it receives less than size which passed as an argument. My Other device will send uart data with different lengths without a new line. I commented uartParams.readReturnMode = UART_RETURN_FULL even though its not working. so how can i receive different length of data?

    2.As per your suggestion i made a ICALL API call from task function then its working but some times it is hanging after receiving uart data (received uart matches to the length of the data). what could be the reason? I increased stack size even though its hanging 

    regards,

    Vijay Rakesh