Device reset happening and i can't able to upload the code

Hello,

In my project i am using  nrf52840 with my custom board and to upload the code through NRF_CONNECT application with soft device its uploading properly but with  segger emmbedded its giving some error like this .please have look and let me know what is the problem.

after this i have add DEBUG in preprocessor definition and i got this

thank you.

Parents
  • Hi

    The instances are split into UARTE0 and UARTE1, and should be accessed through the UARTE driver, see the documentation here. First you'll have to set NRFX_UARTE0_ENABLED and NRFX_UARTE1_ENABLED to 1 in your sdk_config.h file, then you can use the UARTE driver to configure the second UARTE instance as you like.

    Best regards,

    Simon

  • Hello Simonr,

    I have gone through the UART driver and it's not easy as i thought in the driver they mentioned the implementation flow but i am not able to implement the exact. so i have seen some other ways in the forum it's self and i have got this but still  i couldn't 

    The app_uart libraries were developed when there only existed one UART on the nRF5 series. Now we have two, so it is pretty hardcoded to only use one. 

    If you look at uart_init() -> APP_UART_FIFO_INIT() -> app_uart_init() -> nrf_drv_uart_init(), you can see that the first input parameter in nrf_drv_uart_init() is the uart instance. 

    Depending on how you want your application to work, I suggest that you (either way) add an input parameter from APP_UART_FIFO_INIT() containing the instance, so that you can call it twice, once with each instance. Then, in addition, you may want to add another instance of the fifo buffers, m_rx_fifo and m_tx_fifo in app_uart_fifo.c.

    Whether you want a separate uart_event_handler() in app_uart_fifo.c is up to you. It may be easier to use two different handlers for each of the UART instances. The callback itself doesn't contain information on what UART instance that triggered. Another option is to add a custom pointer with a parameter in the context pointer used in nrf_drv_uart_init():

    uint32_t app_uart_init(const app_uart_comm_params_t * p_comm_params,
                                 app_uart_buffers_t *     p_buffers,
                                 app_uart_event_handler_t event_handler,
                                 app_irq_priority_t       irq_priority)
    {
        uint32_t err_code;
    
        m_event_handler = event_handler;
    
        if (p_buffers == NULL)
        {
            return NRF_ERROR_INVALID_PARAM;
        }
    
        // Configure buffer RX buffer.
        err_code = app_fifo_init(&m_rx_fifo, p_buffers->rx_buf, p_buffers->rx_buf_size);
        VERIFY_SUCCESS(err_code);
    
        // Configure buffer TX buffer.
        err_code = app_fifo_init(&m_tx_fifo, p_buffers->tx_buf, p_buffers->tx_buf_size);
        VERIFY_SUCCESS(err_code);
    
        nrf_drv_uart_config_t config = NRF_DRV_UART_DEFAULT_CONFIG;
        config.baudrate = (nrf_uart_baudrate_t)p_comm_params->baud_rate;
        config.hwfc = (p_comm_params->flow_control == APP_UART_FLOW_CONTROL_DISABLED) ?
                NRF_UART_HWFC_DISABLED : NRF_UART_HWFC_ENABLED;
        config.interrupt_priority = irq_priority;
        config.parity = p_comm_params->use_parity ? NRF_UART_PARITY_INCLUDED : NRF_UART_PARITY_EXCLUDED;
        config.pselcts = p_comm_params->cts_pin_no;
        config.pselrts = p_comm_params->rts_pin_no;
        config.pselrxd = p_comm_params->rx_pin_no;
        config.pseltxd = p_comm_params->tx_pin_no;
        config.p_context = custom_pointer;              // THIS ONE
    
        err_code = nrf_drv_uart_init(&app_uart_inst, &config, uart_event_handler);
        VERIFY_SUCCESS(err_code);

    Whatever you pass into this p_context pointer will be present in the callback (p_context)

    static void uart_event_handler(nrf_drv_uart_event_t * p_event, void* p_context)

    Alternatively, you can use the nrf_drv_uart_init directly from your application, and skip the app_uart_fifo library.

    so can you please try for 2 UART and send me the implementation code since i new to nordic so i need your help.

    thank you.

Reply
  • Hello Simonr,

    I have gone through the UART driver and it's not easy as i thought in the driver they mentioned the implementation flow but i am not able to implement the exact. so i have seen some other ways in the forum it's self and i have got this but still  i couldn't 

    The app_uart libraries were developed when there only existed one UART on the nRF5 series. Now we have two, so it is pretty hardcoded to only use one. 

    If you look at uart_init() -> APP_UART_FIFO_INIT() -> app_uart_init() -> nrf_drv_uart_init(), you can see that the first input parameter in nrf_drv_uart_init() is the uart instance. 

    Depending on how you want your application to work, I suggest that you (either way) add an input parameter from APP_UART_FIFO_INIT() containing the instance, so that you can call it twice, once with each instance. Then, in addition, you may want to add another instance of the fifo buffers, m_rx_fifo and m_tx_fifo in app_uart_fifo.c.

    Whether you want a separate uart_event_handler() in app_uart_fifo.c is up to you. It may be easier to use two different handlers for each of the UART instances. The callback itself doesn't contain information on what UART instance that triggered. Another option is to add a custom pointer with a parameter in the context pointer used in nrf_drv_uart_init():

    uint32_t app_uart_init(const app_uart_comm_params_t * p_comm_params,
                                 app_uart_buffers_t *     p_buffers,
                                 app_uart_event_handler_t event_handler,
                                 app_irq_priority_t       irq_priority)
    {
        uint32_t err_code;
    
        m_event_handler = event_handler;
    
        if (p_buffers == NULL)
        {
            return NRF_ERROR_INVALID_PARAM;
        }
    
        // Configure buffer RX buffer.
        err_code = app_fifo_init(&m_rx_fifo, p_buffers->rx_buf, p_buffers->rx_buf_size);
        VERIFY_SUCCESS(err_code);
    
        // Configure buffer TX buffer.
        err_code = app_fifo_init(&m_tx_fifo, p_buffers->tx_buf, p_buffers->tx_buf_size);
        VERIFY_SUCCESS(err_code);
    
        nrf_drv_uart_config_t config = NRF_DRV_UART_DEFAULT_CONFIG;
        config.baudrate = (nrf_uart_baudrate_t)p_comm_params->baud_rate;
        config.hwfc = (p_comm_params->flow_control == APP_UART_FLOW_CONTROL_DISABLED) ?
                NRF_UART_HWFC_DISABLED : NRF_UART_HWFC_ENABLED;
        config.interrupt_priority = irq_priority;
        config.parity = p_comm_params->use_parity ? NRF_UART_PARITY_INCLUDED : NRF_UART_PARITY_EXCLUDED;
        config.pselcts = p_comm_params->cts_pin_no;
        config.pselrts = p_comm_params->rts_pin_no;
        config.pselrxd = p_comm_params->rx_pin_no;
        config.pseltxd = p_comm_params->tx_pin_no;
        config.p_context = custom_pointer;              // THIS ONE
    
        err_code = nrf_drv_uart_init(&app_uart_inst, &config, uart_event_handler);
        VERIFY_SUCCESS(err_code);

    Whatever you pass into this p_context pointer will be present in the callback (p_context)

    static void uart_event_handler(nrf_drv_uart_event_t * p_event, void* p_context)

    Alternatively, you can use the nrf_drv_uart_init directly from your application, and skip the app_uart_fifo library.

    so can you please try for 2 UART and send me the implementation code since i new to nordic so i need your help.

    thank you.

Children
No Data
Related