This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to read data from UART RX interrupt? (SDK 17.0.2)

Hi

I want to receive data through UART RX interrupt.

--> An interruption occurs to notify me when one character(byte) is received, and i store it to my memory buffer

The example project I used is "examples/peripheral/uart/main.c"

But this example seems to have only polling mode way.

How can I use the interrupt method to receive data one character by character?

Can you give me some example? 

thanks!!

uart initi:

const app_uart_comm_params_t comm_params =
{
   RX_PIN_NUMBER,
   TX_PIN_NUMBER,
   RTS_PIN_NUMBER,
   CTS_PIN_NUMBER,
   UART_HWFC,
   false,
   #if defined (UART_PRESENT)
   NRF_UART_BAUDRATE_115200
   #else
   NRF_UARTE_BAUDRATE_115200
   #endif
};

APP_UART_FIFO_INIT(&comm_params,
   UART_RX_BUF_SIZE,
   UART_TX_BUF_SIZE,
   uart_error_handle,
   APP_IRQ_PRIORITY_LOWEST,
   err_code);

while loop

while (true)
{

   uint8_t cr;
   while (app_uart_get(&cr) != NRF_SUCCESS);
   while (app_uart_put(cr) != NRF_SUCCESS);

   if (cr == 'q' || cr == 'Q')
   {
   printf("tick1 = %d\r\n", nrf_drv_rtc_counter_get(&rtc));

   }
}

Parents Reply Children
Related