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

serial_uartes stablity

HI

How stable is the serial_uartesexample in nRF5?  I'm running it on a PCA10056, the example works for about 5 seconds and then UART RX stops, i.e. nothing is received after that point.

Thank you.

Pete.

  • Also, some more info.  Long story short this came about from me adding serial_uartes to the FreeRTOS blinky and running into these issues there.  I have a GPS unit on 9600 baud connected to the problem UART.  So I changed over to the standard serial_uartes example, changed the baud rate and pins to what I am using (and on the same hardware) and see the same issue.

    So this is basically what I changed in the serial_uartes example:

    #define U2RX_PIN_NUMBER  NRF_GPIO_PIN_MAP(0,14)
    #define U2TX_PIN_NUMBER  NRF_GPIO_PIN_MAP(0,16)
    
    #define URX_PIN_NUMBER  NRF_GPIO_PIN_MAP(0,11)
    #define UTX_PIN_NUMBER  NRF_GPIO_PIN_MAP(0,13)
    
    NRF_SERIAL_DRV_UART_CONFIG_DEF(m_uarte0_drv_config,
                          URX_PIN_NUMBER, UTX_PIN_NUMBER,
                          RTS_PIN_NUMBER, CTS_PIN_NUMBER,
                          NRF_UART_HWFC_DISABLED, NRF_UART_PARITY_EXCLUDED,
                          NRF_UART_BAUDRATE_9600,
                          UART_DEFAULT_CONFIG_IRQ_PRIORITY);
    
    NRF_SERIAL_DRV_UART_CONFIG_DEF(m_uarte1_drv_config,
                          U2RX_PIN_NUMBER, U2TX_PIN_NUMBER,
                          RTS_PIN_NUMBER, CTS_PIN_NUMBER,
                          NRF_UART_HWFC_DISABLED, NRF_UART_PARITY_EXCLUDED,
                          NRF_UART_BAUDRATE_115200,
                          UART_DEFAULT_CONFIG_IRQ_PRIORITY);

    Also interestingly  nrf_serial_write(&serial0_uarte, &c, sizeof(c), NULL, 0); seems to only work if single characters are received, i.e. when changing to something like this it never receives anything: 

    char buffer[32];
    
    size_t count_read;
    
    nrf_serial_write(&serial0_uarte, buffer, sizeof(buffer), &count_read, 0);

    So I have 2 issues:

    1. After receiving a number of characters from the GPS (and echoing these on the TX of the same UART to a PC) receive stops completely and nothing more is received.

    2.  nrf_serial_write can only receive one character at a time, anything more and it doesn't work at all.

    Thank you...

  • Part of the problem here is that nrf_serial doesn't handle errors gracefully, e.g. you need to uninit() and init() again if there are any errors. Instead I recommend to check out:

    https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/lib_libuarte.html

    Best regards,
    Kenneth

  • HI Kenneth

    Thank you for your reply.  Does lib_libuarte support 2 UARTs?

    Best Regards

    Pete.

  • HI Kenneth

    I have tried the lib_libuarte example.  Seems if there is already data on the RX pin when it starts up, it crashes.  If the data (GPS) is connected later it works.

    I really like the nRF52840 and the Nordic range, but if it is this hard just to get a UART working, it will be a nightmare to use it on a real product with a deadline.  I'm finding it hard to move beyond anything that requires more than is in one of the examples.  I would love to use one of these devices in a product, but I can't see how.

    Best Regards

    Pete.

  • I am not aware of any issue with lib_libuarte, I tried pulling RXD pin low during init or random time, but the program kept on running when pin was released. Have you added some assert or similar in uart_event_handler() when there is an NRF_LIBUARTE_ASYNC_EVT_ERROR event?

    Best regards,
    Kenneth

Related