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

Need UART driver for nrf52840 with DMA and Interrupt modes.

Hi Team,

One of my application needs the UART driver in both Interrupt and DMA mode for more data bytes transfer. No need of timeout operation or polling mode.

Can any body have an idea on which is the best driver for my requirement. I have some doubts on UART Layers.

1. Need the driver which will not interrupt the BLE Events and SD operation.

2. What is the difference between UART and UARTE as part of initialization.

3. Difference between UART driver and Serial driver.

4. If we are going to use the interrupt mode , we will get interrupt for every byte transfer or receive. In DMA mode we will only get interrupt after transfer of bulk data. on this point please correct me if i am wrong.

Regards,

Srinivas.V

Parents
  • Hi Srinivas,

    2. What is the difference between UART and UARTE as part of initialization.

    The UART peripheral does not have DMA. The UARTE peripheral has DMA.

    1. Need the driver which will not interrupt the BLE Events and SD operation.

    You probably want to use the UARTE peripheral. If using the legacy driver or one of the libraries based on it, you select between UART and UARTE based on if you configure DMA enabled or not in sdk_config.h. If you refer to the UART example, you can see that UART_EASY_DMA_SUPPORT is enabled by default in sdk_config.h, which in turn means that DMA is used.

    3. Difference between UART driver and Serial driver.

    The serial library is a library build on top of the UART driver. That has been deprecated in SDK 17 and is now replaced by the libUARTE library. Depending on your needs you may stick with the UART driver or the libUARTE library

    4. If we are going to use the interrupt mode , we will get interrupt for every byte transfer or receive. In DMA mode we will only get interrupt after transfer of bulk data. on this point please correct me if i am wrong.

    You can get interrupts in any case, so this is not related to DMA or not. Normally you separate between blocking and non-blocking, where with blocking modes you don't have interrupts, or at least the driver hides it from the user. But for a real product you typically always want non-blocking and interrupts, so that the CPU can sleep or do other tasks while waiting for the UART transaction to finish. Similarly, there are few good reasons for not using DMA, as that frees up more time for the CPU as it will get an interrupt once the transaction is completed (the specified number of bytes are transferred) instead of for every single byte.

    In general, the SoftDevice has some timing requirements meaning it normally needs to have the highest interrupt priority. Therefor it makes sense to use flow control for the UART even if you use DMA, as any delay in handling the UART will not cause loss of UART Rx data in that case.

    Br,

    Einar

  • Hi Einar,

    Thanks for your valuable reply.

    1. As per your mail the only difference between UART and UARTE is only the usage of DMA, if we want interrupt mode can UARTE support or we need to go back to legacy UART driver again.

    Can you please suggest which driver is best in terms of speed and time and memory consumption like DMA or with interrupt mode.

    Regards,

    Srinivas.V

Reply Children
  • Hi Srinivas,

    Srinivas V said:
    the only difference between UART and UARTE is only the usage of DMA

    It is not the only difference, but it is the most significant difference. I suggest you refer to the product specification if you need to know more details. In general, the UARTE peripheral and DMA is typically what you want to use unless you have some very specific needs.

    Srinivas V said:
    if we want interrupt mode can UARTE support or we need to go back to legacy UART driver again.

    You will use interrupts in any case, so I don't follow the jargon exactly. That said, if you use the nrf_drv_uart you can switch between UART and UARTE (DMA or not) by simply changing the value of UART_EASY_DMA_SUPPORT in sdk_config.h.

    Srinivas V said:
    Can you please suggest which driver is best in terms of speed and time and memory consumption like DMA or with interrupt mode.

    You save resources by using the UART driver instead of the libUARTE. There you have three options:

    • nrfx_uart (UART specific)
    • nrfx_uarte (UARTE specific)
    • nrf_drv_uart (common API for both of the above)

    You do not get any significant overhead using nrf_drv_uarte compared to nrfx as most of the abstraction is handled by the preprocessor. So I suggest you stick with nrf_drv_uart unless you have a good reason not to.

    Einar

  • Hi Einar,

    Once again thanks for your reply.

    Could you please let me know the example project which is using the "nrf_drv_uart" as a source file in any application layer, so that i will reuse the same project as a reference to my application and we will continue our implementation.

    Regards,

    Srinivas.V

  • Hi Srinivas,

    The UART example can be used as a reference. It does not use nrf_drv_direclty, but it used the UART module (often referred to as app_uart), which in turn use the nrf_drv_uart. If you want to use the UART module, then you can do exactly as in the example. And if you want to use the driver directly, then you can look at the implementation of the UART module.

    Einar

Related