how to write UART Interrupt handler

Hi 

I am trying to use UART from the peripheral UART example from zephyr SDK nRF connect and It is working,

But the UART is initialized in main, How do I re write the code using an interrupt handler as in when ever I give a text in my standard input (terminal) I should get the uart initialized, and the entered text from the terminal should be given to UART RX.

Thanks,

Gotak

Parents
  • Hi,

    The UART implementation in the Peripheral UART sample does exactly what you're describing as your needs. 

    It creates a write thread where it sends data that has been put into a FIFO in the uart_cb (callback) function which is triggered by an interrupt.

    Kind regards,
    Andreas

  • Hi Andreas,

    I see,...the peripheral UART example I have integrated other functions in the code so as I am initializing the UART in main function I am calling other custom functions after uart_init().

    So in this case.....the uart is initializing and REQUESTING for UART RX and immediately implementing other function I have written after the uart_init() and not giving enough time for me to give input, so I have tried giving 10 seconds delay then it is working properly. 

    But! I have limit the UART input functionality only for that 10 seconds so I wanted to use UART interrupt handler.

    If the peripheral UART example could work for the context I have described above how do I do it without giving any delay?

    If you could make this ticket private I can share you the code, it would be easy for you to understand.

    Thanks,

    Gotak

  • Hi,

    Just wanted to check if there is any insight regarding my query:)

    Thanks, 

    Gotak

Reply Children
Related