Multiple UART on NRF52833

Hello Everyone,

                   I am using NRF52833 in my project and I have my NRF module connected to 2 other microcontrollers on UART peripherals. The details are mentioned as below:-

1) NRF52833 connected to MCU A

   RX pin of nrf- P0.29

   TX pin of nrf- P0.28

2) NRF52833 connected to MCU B

   RX pin of nrf- P0.30

   TX pin of nrf- P0.31.

I have successfully configured connection to MCU and I am able to transmit data from NRF to MCU A and receive data on NRF from MCU A.

Now I have to add another UART in the code so as to communicate with MCU B. What will be the steps to add one more UART configuration?? What is the procedure to do so.

Thanks & Regards,

Snehal.

  • Hi,

    You can use the logger module with the RTT enabled as backend (see the ble_app_uart for reference). But the best approach would be to use the debugger and set a breakpoint in the event handler and see if the RX buffer is filled.

    regards

    Jared 

  • Hi,

         So this particular line ".p_data = p_evt->data.rxtx.p_data," has the received data right? 

    I also tried to debug the firmware. I am receiving the data from the other controller but after receiving the data I am getting this error in the logs:-

    <error> app: LIBUARTE ERROR
    <error> app: LIBUARTE ERROR
    <error> hardfault: HARD FAULT at 0x000287A8
    <error> hardfault: R0: 0x00000000 R1: 0x20006880 R2: 0x0A0D6466 R3: 0x20006878
    <error> hardfault: R12: 0x200067A4 LR: 0x00029C2D PSR: 0x61000038
    <error> hardfault: Cause: Data bus error (return address in the stack frame is not related to the instruction that caused the error).

    What could have caused this issue?

    Regards,

    Snehal

  • Hi,

    Can you start the program with the debugger and see what instruction is at 0x000287A8 in the Dissembler view? 

  • I have solved that issue. Can you help me with one thing. I am receiving lot of data from the other MCU via libuarte. I want to print that data on the RTT terminal... How can I do that using NRF_LOG_INFO?? 

    My libuarte handler is as follows:-

    void libuart_event_handler(void *context, nrf_libuarte_async_evt_t *p_evt) {
    static uint8_t index;

    nrf_libuarte_async_t *p_libuarte = (nrf_libuarte_async_t *)context;
    ret_code_t ret;

    switch (p_evt->type) {
    case NRF_LIBUARTE_ASYNC_EVT_ERROR: {
    NRF_LOG_ERROR("LIBUARTE ERROR");
    break;
    }
    case NRF_LIBUARTE_ASYNC_EVT_RX_DATA: {
    // Receive complete
    memset(buffer,'0',sizeof(buffer));
    memcpy(buffer, p_evt->data.rxtx.p_data, p_evt->data.rxtx.length);
    int data_length = p_evt->data.rxtx.length;

    nrf_libuarte_async_rx_free(p_libuarte, p_evt->data.rxtx.p_data, p_evt->data.rxtx.length);
    break;
    }
    case NRF_LIBUARTE_ASYNC_EVT_TX_DONE: {
    // Transmit complete

    break;
    }
    }
    }

    How can I print the buffer values on RTT?? Size of buffer is 256.

    Regards,

    Snehal

  • Hi ,

    You need to set the logger backend in the sdk_config.h file from UART to RTT.

    regards

    Jared

Related