This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

The problem of using UART to communicate between nRF160 and nRF2833 on nRF Connect SDK.

Hello, All,

When using UART on nRF Connect SDK to communicate between nrf9160DK and nRF2833DK, I found that the data length of a packet sent by the UART on both sides is different.

When using nRF9160 to send, a data packet can reach more than 1K; but when using nRF2833 to send, it is found that a data packet can only send about 250 bytes.

WHY?

Are there any restrictions?

Is it restricted by DMA?

Where is the explanation about this part?

The sending function I use is: "uart_tx()".

Even if I change the value of the macro CONFIG_UART_0_NRF_TX_BUFFER_SIZE, it has no effect.

  • Sorry, I was wrong. What I tested was not nRF52833DK but nRF52840DK, because currently nRF52833 will report an error "Not able to allocate UART receive buffer".

    And why does nRF52833 report this problem while nRF52840 is normal?

  • Hi

    Are you saying the nRF52833 will fail even if it uses exactly the same code and the same project configuration?

    How large is the buffer that the nRF52833 fails to allocate?

    Could you try to increase the CONFIG_HEAP_MEM_POOL_SIZE setting in prj.conf and see if the problem goes away?

    Best regards
    Torbjørn

  • Yes, nRF52840 and nRF52833 use the same project and configuration.

    The following is the relevant configuration:

    in prj.conf

    # LOG.
    CONFIG_LOG=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    
    # DK library.
    CONFIG_DK_LIBRARY=y
    
    # UART.
    CONFIG_SERIAL=y
    CONFIG_UART_ASYNC_API=y
    CONFIG_UART_0_NRF_TX_BUFFER_SIZE=1024
    
    CONFIG_CONSOLE=n
    CONFIG_UART_CONSOLE=n
    
    # Main thread.
    CONFIG_MAIN_STACK_SIZE=8192
    
    CONFIG_HEAP_MEM_POOL_SIZE=16384
    
    CONFIG_NEWLIB_LIBC=y
    

    And Uart buff settings:

    #define UART_RX_BUF_SIZE 200
    #define UART_TX_BUF_SIZE 1024
  • Hi 

    How long does it take for the "Not able to allocate UART receive buffer" error to appear? 

    Does it happen after a certain number of UART packets, or does it happen right away?

    To be honest this example is not designed very well, and using dynamic memory allocation for buffers like this is a very risky practice. It would be much safer to use a queue of buffers or a ring buffer to handle the UART buffers, to avoid problems like memory fragmentation, and to avoid having to use the heap for UART data. 

    I would strongly recommend changing the way these buffers are handled. I am planning to make an example for this myself, but unfortunately I don't know when I will be able to do this since I also have a lot of other cases to handle. 

    Best regards
    Torbjørn

Related