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);
}

Parents
  • 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

  • Yes, I am using the Softdevice 140. 

    The code stops at either of these functions, nrf_drv_uart_tx and nrf_drv_uart_rx. I tried them individually. 

    This is the code I am using.

    uint8_t rx_buffer[1];
    uint8_t tx_buffer[1];
    
    nrf_drv_uart_t app_uart_inst = NRF_DRV_UART_INSTANCE(0);
    
    
    void rm_uart_put(uint8_t c);
    uint8_t rm_uart_get();
    
    void rm_uart_init() 
    {
        nrf_drv_uart_config_t cfg = 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;
        
        ret_code_t ret;
        nrf_drv_uart_init(&app_uart_inst, &cfg, NULL);
    }
    
    void rm_uart_handle() 
    {
        uint32_t err_code;
        uint8_t send = 0;
        uint8_t recive = 1;
    
        bsp_board_led_on(ADVERTISING_LED);
        rm_uart_put(send);
        nrf_delay_ms(1000);
        bsp_board_led_off(ADVERTISING_LED);
        nrf_delay_ms(1000);
    
        bsp_board_led_on(ADVERTISING_LED);
        recive = rm_uart_get();
        nrf_delay_ms(1000);
        bsp_board_led_off(ADVERTISING_LED);
    }
    
    
    void rm_uart_put(uint8_t c) 
    {
        uint32_t err_code;
        tx_buffer[0] = c;
    
        nrf_drv_uart_tx(&app_uart_inst, tx_buffer, 1); 
    }
    
    uint8_t rm_uart_get(void) 
    {
        ret_code_t err_code;
    
        nrf_drv_uart_rx(&app_uart_inst, rx_buffer, 1);
        
    
        return *rx_buffer;
    }
     

    I connected two things to the UART.

    1) Rx and Tx to computer. send/recvice in PuTTY.

    2) The Rx and Tx Pins on the Dongle connected. So I would receive on the Dongle, what I sent from the Dongle. 

    However, both did not work.

  • lucaN said:

    I connected two things to the UART.

    1) Rx and Tx to computer. send/recvice in PuTTY.

    2) The Rx and Tx Pins on the Dongle connected. So I would receive on the Dongle, what I sent from the Dongle. 

    1) How? Do you have some external UART->USB bridge? Can you show me a picture of how these are connected?

    2) I am not sure that would work the way you are using it, with a blocking rx call. 

    You need to debug this. To do so, you need either an external debugger, or a DK.

  • This is the set up. Voltage is provided by USB.

  • Ok, I just wanted to make 100% sure that you didn't think the pins were routed through the USB port (like it is on the DK). Then I am afraid you need to debug.

  • Alright. I ordered one. Thank you for your help!

Reply Children
No Data
Related