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

nRF52840 Dongle UART

Hello,

I use the Blinky example from the SDK. Now I would like to implement an UART on the nRF52840 Dongle. But the program always stops at either nrf_drv_uart_rx or nrf_drv_uart_tx. Can anyone help me with that?

Thanks in advance!

nrf_drv_uart_t upp_uart_inst = NRF_DRV_UART_INSTANCE(0);

void rm_uart_init()
{
    nrf_drv_uart_config_t vfg = NRF_DRV_UART_DEFAULT_CONFIG;
    cfg.baudrate    = UART_BAUDRATE_BAUDRATE_Baud115200;
    cfg.hwfc        = NRF_UART_HWFC_DISABLED;
    cfg.pselrxd     = 29;
    cfg.pseltxd     = 31;
    cfg.use_easy_dma= 0;
        
    nrf_drv_init(&app_drv_uart_init, &cfg, NULL);
}

void fkt()
{
    uint8_t tx_buffer[0] = 1;
    uint8_t rx_buffer[0] = 0;
    nrf_drv_uart_tx(&app_uart_inst, tx_buffer, 1);
    nrf_drv_uart_rx (&app_uart_inst, rx_buffer, 1);
}

  • For development, please use an nRF52840 DK. 

    I guess the issue is that you receive a COMMUNICATION_ERROR event, because your UART pins are floating. But you need a programmer to verify this, so that you can debug. 

    The nRF52840 DK has an on board debugger, but the dongle does not. 

    The debugger will allow for debugging and logging.

    It will save you a lot of time. Perhaps it is worth the expense.

    Best regards,

    Edvin

  • Thanks for your answer. 

    The nRF52840 DK uses the pca10056 SDK right? I want to use the Dongle eventually, so even if I have a working programm for the DK, I can't use it on the Dongle. Am I mistaken?

    When the pins are floating, shoudn't I recive and send noise? Why would the code stop at:

    nrf_drv_uart_tx(&app_uart_inst, tx_buffer, 1);
    nrf_drv_uart_rx (&app_uart_inst, rx_buffer, 1);
     

    But could I try to pull TX and RX high, with external restistors?

    Best regards,

    Luca

  • luca brandt said:
    The nRF52840 DK uses the pca10056 SDK right? I want to use the Dongle eventually, so even if I have a working programm for the DK, I can't use it on the Dongle. Am I mistaken?

     That is correct. In that case, you need to port it to the dongle. 

     

    luca brandt said:

    When the pins are floating, shoudn't I recive and send noise? Why would the code stop at:

     Because if the RX pin is not connected to anything, and you receive some noise on the RX pin, the UART peripheral will try to make sense of it, and generate an event saying that something went wrong during the RX. 

    If you have something like this:

            case APP_UART_COMMUNICATION_ERROR:
                APP_ERROR_HANDLER(p_event->data.error_communication);

    Try to comment out the line containing APP_ERROR_HANDLER(...)

    So do you have anything connected to the UART pins on the dongle? NB: The UART pins are not the USB pins on the dongle. If nothing is connected, try to remove the uart from your project, or at least comment out the error handling from the UART.

  • What would the porting to the Dongle look like? 

    I connected the RX- and TX Pin to the serial port of my computer. (and voltage supply comes from the USB)

    I'm not using any kind of Error Handling. The code I posted is literally all I am using. 

    But even when I connect the RX and TX Pins (as a loop), the code stops at the first nrf_drv_uart_...().

    Is there anyting I need to do before I use these functions?

  • Like described in this blog:

    https://devzone.nordicsemi.com/nordic/short-range-guides/b/getting-started/posts/nrf52840-dongle-programming-tutorial

    If the UART is not the cause of your problem, then you need to debug your project to see what's going on. Why does it stop? How do you determine that it has stopped? 

     

    luca brandt said:
    I'm not using any kind of Error Handling. The code I posted is literally all I am using. 

     Obviously, you also have all the drivers and so on. Perhaps there is an APP_ERROR_CHECK() inside one of your function calls in nrf_drv_uart_...(). You will save yourself some time if you get hold of a debugger or a DK. NB: Read the part about the bootloader's UICR and external debugger if you decide to go with the external debugger on the dongle. 

Related