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

implementation UART to examples from SDK

Hello, 

I have problem with implementing UART to simple_coap_client example, but there is too much problems. Some issues have been solved, but it still is not all. 

defines in sdk_config.h  -solved 

uart0 - used by openthread lib -solved

Can you help me with best way to use COAP and UART in same project?  

 

nRF5_SDK_for_Thread_and_Zigbee_2.0.0_29775ac

Linux ubuntu 18.04

Segger studio

Parents
  • defines in sdk_config.h  -solved 

    uart0 - used by openthread lib -solved

     

    Can you please describe what the issue is? What is your progress?

    Best regards,

    Edvin

  • I think should be exist guide how to add UART to example project because  it is important but so complicated

  • Your compiler output should also tell you something like:

    previous definition here: <path to other place it is defined>.

    How did you "Disable uart 0 enable uart 1"?

    It looks like you still have enabled uart 0 somewhere in your project. Maybe in sdk_config.h?

  • this defines was copied from sdk_config of project peripherals/serial_uartes and I disable uart0 

    #ifndef NRFX_UARTE_ENABLED
    #define NRFX_UARTE_ENABLED 1
    #endif
    // <o> NRFX_UARTE0_ENABLED - Enable UARTE0 instance
    #ifndef NRFX_UARTE0_ENABLED
    #define NRFX_UARTE0_ENABLED 0
    #endif

    // <o> NRFX_UARTE1_ENABLED - Enable UARTE1 instance
    #ifndef NRFX_UARTE1_ENABLED
    #define NRFX_UARTE1_ENABLED 0
    #endif

    ...

    #ifndef NRFX_UART_ENABLED
    #define NRFX_UART_ENABLED 1
    #endif
    // <o> NRFX_UART0_ENABLED - Enable UART0 instance
    #ifndef NRFX_UART0_ENABLED
    #define NRFX_UART0_ENABLED 0
    #endif

    ...

    #ifndef UART_ENABLED
    #define UART_ENABLED 1
    #endif

    ...

    #ifndef UART_EASY_DMA_SUPPORT
    #define UART_EASY_DMA_SUPPORT 1
    #endif

    // <q> UART_LEGACY_SUPPORT - Driver supporting Legacy mode

    #ifndef UART_LEGACY_SUPPORT
    #define UART_LEGACY_SUPPORT 1
    #endif

    ....

    #ifndef UART0_ENABLED
    #define UART0_ENABLED 0
    #endif

    #ifndef UART1_ENABLED
    #define UART1_ENABLED 1
    #endif

Reply
  • this defines was copied from sdk_config of project peripherals/serial_uartes and I disable uart0 

    #ifndef NRFX_UARTE_ENABLED
    #define NRFX_UARTE_ENABLED 1
    #endif
    // <o> NRFX_UARTE0_ENABLED - Enable UARTE0 instance
    #ifndef NRFX_UARTE0_ENABLED
    #define NRFX_UARTE0_ENABLED 0
    #endif

    // <o> NRFX_UARTE1_ENABLED - Enable UARTE1 instance
    #ifndef NRFX_UARTE1_ENABLED
    #define NRFX_UARTE1_ENABLED 0
    #endif

    ...

    #ifndef NRFX_UART_ENABLED
    #define NRFX_UART_ENABLED 1
    #endif
    // <o> NRFX_UART0_ENABLED - Enable UART0 instance
    #ifndef NRFX_UART0_ENABLED
    #define NRFX_UART0_ENABLED 0
    #endif

    ...

    #ifndef UART_ENABLED
    #define UART_ENABLED 1
    #endif

    ...

    #ifndef UART_EASY_DMA_SUPPORT
    #define UART_EASY_DMA_SUPPORT 1
    #endif

    // <q> UART_LEGACY_SUPPORT - Driver supporting Legacy mode

    #ifndef UART_LEGACY_SUPPORT
    #define UART_LEGACY_SUPPORT 1
    #endif

    ....

    #ifndef UART0_ENABLED
    #define UART0_ENABLED 0
    #endif

    #ifndef UART1_ENABLED
    #define UART1_ENABLED 1
    #endif

Children
  • What compiler/IDE are you using? 

    Can you send the project in a .zip folder? (ps: it may be too large to upload here. Just delete the build files, and zip it).

    Best regards,

    Edvin

  • this is link to google drive zip file of SDK 

    project is simple_coap_client

    drive.google.com/open

  • Hello,

    Can you try to change the define in sdk_config.h:

    #define NRFX_PRS_ENABLED 1

    to

    #define NRFX_PRS_ENABLED 0.

    On my end, this makes the project compile, and I can still use the CLI. I don't know what you intend to use the other UART for, but can you try this and see if it works?

    Best regards,

    Edvin

  • OK thanks it works, but i comment one line but its not correct fix 

    in file nrf_serial.c

    #if defined(UARTE_PRESENT) && defined(UART_PRESENT)
        drv_config.use_easy_dma = (p_config->mode == NRF_SERIAL_MODE_DMA);
    #endif

    ‘nrf_drv_uart_config_t {aka struct <anonymous>}’ has no member named ‘use_easy_dma’

  • Hello,

    I see. It seems like these drivers were written mainly for UART0. 

    If you look at nrf_drv_uart.h line 200 and up, the bool use_easy_dma is only declared if:

    NRF_DRV_UART_WITH_UARTE is defined and NRF_DRV_UART_WITH_UART is defined.

    NRF_DRV_UART_WITH_UARTE is defined, so that is fine.

    NRF_DRV_UART_WITH_UART is only defined if:

    UART_PRESENT is defined and NRFX_UART_ENABLED is 1.

    UART_PRESENT is defined, so that is fine.

    NRFX_UART_ENABLED is defined in sdk_config.h, so it should be fine, BUT:

    there is a file called apply_old_config.h. Look in this file on line 1278, it says:

    #define NRFX_UART_ENABLED   (UART_ENABLED && NRFX_UART0_ENABLED)

    So NRFX_UART_ENABLED is first defined in sdk_config.h, then undefined in apply_old_config.h on line 1277, then defined as UART_ENABLED && NRFX_UART0_ENABLED.

    (This is why I said that this driver was written mainly for UART0). Try to change line 1278 in apply_old_config.h as:

    #define NRFX_UART_ENABLED   (UART_ENABLED && (NRFX_UART0_ENABLED || NRFX_UART1_ENABLED))

    This passes this compiler error, but there is more:

    in nrfx_uart.c on line 45-47:

    #if !NRFX_CHECK(NRFX_UART0_ENABLED)
    #error "No enabled UART instances. Check <nrfx_config.h>."
    #endif

    Change the check to:

    #if (!NRFX_CHECK(NRFX_UART0_ENABLED) && !NRFX_CHECK(NRFX_UART1_ENABLED))

    I have reported these bugs regarding only checking NRFX_UART0_ENABLED internally.

    Best regards,

    Edvin

Related