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

NRF52840 UART1 not working in SDK 14

I'm trying to run two UARTs out of my NRF52840. Do you have an example in which both SoftDevice UARTs are used? The Nordic Infocenter SDK 14.0.0 documentation lists one of the advantages of the new serial port library as multi-instance capability, but there is no example demonstrating such usage.

I started in SDK 12 and wrote my own alternative to app_uart that would allow multiple UART instances. After enabling UART0 and UART1 in the SDK config, I was unable to get both working at the same time. When I initialized a single UART using the board's default TX/RX pins (6 & 8 for pca10056) and NRF_UARTE0 (0x0002000) I was able to see all my serial data come through fine. However, switching to use NRF_UARTE1 (0x40028000) causes the app to crash and restart on attempting to read or write data, despite my using the same pins and configuration parameters as with UART0.

I've seen other questions regarding similar issues, and the general response was that the SDK 14 serial class would resolve this issue. However, I have since downloaded SDK 14 and am seeing the same behavior. I can initialize one UART port with nrf_serial_init, provided the serial port instance uses NRF_UARTE0/NRF_UART0, but again the same parameters do not work with NRF_UARTE1.

Parents
  • Update 06.09.2018 :

    Below example is available in SDK15.1 and following under location: sdk\nrf5\examples\peripheral\serial_uartes

    I tested it on my NRF52840 DK (PCA10056).

    There is following concept: PC -> UARTE0 -> UARTE1 -> PC image description

    Simply open nrf_serial example: nRF5_SDK_14.0.0_3bcc1f7\examples\peripheral\serial for pca10056.

    Replace main.c with attached main.c.

    In SDK config set both UARTs to use EASY DMA:

    image description

    Now run terminal like PuTTY with baud rate == 115200 and start typing text. You shall be able to see echo on the screen.

    IMPORTANT! Connect PINs P0.27 with P0.26 (UARTE0 TX with UARTE1 RX).

    -------------------

    UPDATE for SDK15 users:

    In order to make it work you need to replace:

    • main.c
    • sdk_config
    • nrf_serial.c
    • nrf_serial.h

    with attached files: 

    example_SDK15_fixed.zip

  • Broken with SDK15?

    ----------------------------

    Hi,

    Thanks - excellent starting point for using both UARTs, however, the example nolonger compiles with SDK 15 (works with SDK14)

    One needs to fix the bsp init:

    bsp_board_leds_init();
    bsp_board_buttons_init();

    to

    bsp_board_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS);

    but UART1 causes issues:

    Compiling file: main.c
    In file included from ../../../../../../modules/nrfx/nrfx.h:45:0,
                     from ../../../../../../modules/nrfx/drivers/include/nrfx_clock.h:44,
                     from ../../../../../../integration/nrfx/legacy/nrf_drv_clock.h:43,
                     from ../../../main.c:7:
    ../../../../../../modules/nrfx/drivers/include/nrfx_uart.h:79:35: error: 'NRF_UART1' undeclared here (not in a function); did you mean 'NRF_UARTE1'?
         .p_reg        = NRFX_CONCAT_2(NRF_UART, id),             \
                                       ^

    It seems there's  new NRF_UARTEx driver? But disabling this in sdk_config.h and enabling the old one causes above error, as does disabling this and enabling the new UARTE. Also the easyDMA option is gone for UART1 ?

  • Hi,

    There is no UART1 in nrf52840! There is only UARTE1 and only UARTE1 is supported by NRFX.

  • Hi Jakub,

    Can you please elaborate and explain how one should go about using both uarts with SDK 15? with SDK 14 I can enable both uarts using the legacy driver. The config tool in SDK14 (with a configuration that I can build the dual serial example)

    How would I go about using UARTE0 and UARTE1? Do I have to use the NRFX driver?

    With SDK 15 if I disable UART0 and UART1 and enable UARTE1 and UARTE0 under NRFX in the config tool, I get:

    Compiling file: nrf_drv_uart.c
    In file included from ../../../../../../integration/nrfx/legacy/nrf_drv_uart.c:41:0:
    ../../../../../../integration/nrfx/legacy/nrf_drv_uart.h:116:13: error: unknown type name 'nrf_uarte_baudrate_t'
         typedef nrf_uarte_baudrate_t        nrf_uart_baudrate_t;

    Thanks

  • Hi,

    You are right, this example will nott work on SDK15. You need to fully switch to NRFX.

    Please use attached files: main.c, sdk_config and new nrf_serial.c and nrf_serial.h (\sdk\nrf5\components\libraries\serial) refactored to use NRFX.

    pack_fixed.7z

  • When I using pack.7z file to compile the project that would show error in the below:

    Error[Pe167]: argument of type "void (*)(struct <unnamed> *, void *)" is incompatible with parameter of type "nrfx_uarte_event_handler_t" D:\Workspace\Data\BLE\Nordic\nRF52840\nRF5_SDK_15.0.0_a53641a\components\libraries\serial\nrf_serial.c 176

  • My bad,

    Please modify line 89 of nrf_serial.c from pack.7z:

    static void uart_event_handler(nrfx_uarte_event_t * p_event, void * p_context)

    to

    static void uart_event_handler(nrfx_uarte_event_t const * p_event, void * p_context).

    I will update pack as well.

Reply Children
Related