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.

CC2642R: Event lost is calling UART_close

Part Number: CC2642R

SDK: simplelink_cc13x2_26x2_sdk_5_10_00_48

Example: simple_peripheral

Compiler: IAR

Hardware:  CC26X2R1_LAUNCHXL

Hi,

In my code, I see the following weird phenomenon:

In one task, after I return from function UART_read(), I process the incoming string, and then post an event.

In the second task, there’s an “event_pend” waiting for this event, and the event is accepted and the task moves on.

In some cases, I consider the input I received as an error. In this case, I call UART_Close() on the uart handle, and then post the event.

But in weird way, if I call UART_close() before posting the event, then the event is never accepted in the second task.

Can you suggest, what might be the problem?

Best regards

Posted in behalf of a customer

  • Hi,

    - Have you verified if the call to UART_close() returns properly?

    - Could you specify if calling UART_close() also lead the task to be terminated? If yes, then this could be the source of the issue.

    It possible, could you please provide a code snippet showing how you call UART_close() ?

    Best regards,

  • Hi,

    Thank you for the provided information. I have assigned an expert to comment.

    Best Regards,

    Jan

  • Clément,

    The call to UART_close() should not preempt the event from happening, therefore I am not entirely sure what may be happening and therefore the snippet of code could help.

    However I have a question: why is your customer not calling UART_readCancel()/UART_writeCancel() instead of closing it entirely? That could help keep things in control.

    Reference:

    https://dev.ti.com/tirex/explore/content/simplelink_cc13x2_26x2_sdk_5_10_00_48/docs/drivers/doxygen/html/_u_a_r_t_8h.html#a6b49b65f3db709c408dc4db23a68895d

    Best regards,

    Rafael

  • This is the code that I'm calling:
    UART_close(uart_m);
    Event_post(writeEvent, Event_Id_03);
    The purpose of this call is because in the handle of the sent event I wish to call functionality that restarts the modem, to which I'm connnected with the UART. SO first I wish to close the connection.
    Regarding calling UART_readCancel(), I also tried it and it didn't help, but it shouldn't be relevant, because right now I call both UART_read and UART_write in blocking mode, not in callback. 
  • Yan,

    Please apologize for the delay; I missed your reply. Are you still having this issue?

    Thanks for sending the function calls; although lacking some surrounding context, the initial behaviour should not be happening with these specific calls. One question, though: does the sending thread copy the contents of the UART Rx buffer into a variable before closing it? I imagine so, but need to ask.

    Also, the UART itself does not have a protocol that requires the connection to be fully alive (not like USB, Ethernet, etc.). Therefore I ask: did you test restarting the modem without closing the UART? This could potentially keep this behaviour under control.

    Hope this helps,

    Rafael