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

nRF52840 UART queries

Hello,

 

I am using nRF52840, SDK_16.0.0, S140 SoftDevice and Segger 4.16 for flashing the image. I am using ‘ble_app_blinky’.

 

1) In Product specification, it says 2 UARTE supported. Whereas in section 6.33.10 I am seeing only one instance of UART0, but in section 6.34.9 there are two instance of UARTE0 and UARTE1.

a) Without EasyDMA, is it only one UART supported ?

 

2) I need uart in my ble_app_blinky application. I have gone through ble_app_uart. For this I enabled NRF_LOG_BACKEND_RTT_ENABLED and disabled NRF_LOG_BACKEND_UART_ENABLED. Is this fine ?

 

3) For UART rx, ble_app_uart has uart_event_handle() to receive data. For UART Tx whether can I use app_uart_put() ?

     a) To cross check I want to type on Terminal. Once received on uart, I want to transmit the same data back to terminal. But when I call app_uart_put(), I am not seeing any print on Terminal.

     b) Even I am getting event APP_UART_TX_EMPTY (3) in default case, indicating "UART has completed transmission of all available data in the TX FIFO". But not output on Terminal. (I configured Terminal properly).

      

/**@snippet [Handling the data received over UART] */
void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t data_array[UART_MAX_DATA_LEN];
    static uint8_t index = 0;
    uint32_t       err_code;

    switch (p_event->evt_type)
    {
        case APP_UART_DATA_READY:
        {
            UNUSED_VARIABLE(app_uart_get(&data_array[index]));
            index++;
            
            NRF_LOG_DEBUG("D ");
            //NRF_LOG_HEXDUMP_DEBUG(data_array, index);
            
            app_uart_put(data_array[index]);
            
            if ((data_array[index - 1] == '\n') ||
                (data_array[index - 1] == '\r') ||
                (index >= m_ble_nus_max_data_len))
            {

                index = 0;
            }
        }
        break;

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

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event->data.error_code);
            break;

        default:
            NRF_LOG_DEBUG("DF %d", p_event->evt_type);
            break;
    }
}
/**@snippet [Handling the data received over UART] */


/**@brief  Function for initializing the UART module.
 */
/**@snippet [UART Initialization] */
void uart_init(void)
{
    uint32_t                     err_code;
    app_uart_comm_params_t const comm_params =
    {
        #if CT40_ACTUAL_BOARD
        .rx_pin_no    = RX_PIN_NUMBER_CT40,
        .tx_pin_no    = TX_PIN_NUMBER_CT40,
        #else
        .rx_pin_no    = RX_PIN_NUMBER,
        .tx_pin_no    = TX_PIN_NUMBER,
        #endif

        .rts_pin_no   = RTS_PIN_NUMBER,
        .cts_pin_no   = CTS_PIN_NUMBER,
        .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
        .use_parity   = false,
#if defined (UART_PRESENT)
        .baud_rate    = NRF_UART_BAUDRATE_115200
#else
        .baud_rate    = NRF_UARTE_BAUDRATE_115200
#endif
    };

    APP_UART_FIFO_INIT(&comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_event_handle,
                       APP_IRQ_PRIORITY_LOWEST,
                       err_code);
    APP_ERROR_CHECK(err_code);
}
/**@snippet [UART Initialization] */

4) I am bit confused, whether can I use app_uart.c / app_uart_fifo.c or “Serial Port Library”. My requirements are:

a) I need both UART Tx & Rx

b) BLE should work simultaneously.

c) Device should go into low power mode.

 

 Thanks & Regards

Vishnu Beema

Parents
  • Hi,

    I my use case first Secure Serial bootloader is loaded and then my ble_app_blinky with UART application is loaded.

    1) Because of Secure serial bootloader whether serial uart is always enabled. Even I am not seeing calling nrfx_uarte_uninit().

    2) (Or) Can I assume when pin is pressed then only chip will enter into boot mode and once DFU done, device will reset, so no issue even if there is no initialization of uart.

    3) What will be the current with uart enabled. Whether it will be 3 to 4 mA of ideal current. Anyway I will test practically, but this is for my quick understanding.

    Thanks & Regards

    Vishnu Beema

Reply
  • Hi,

    I my use case first Secure Serial bootloader is loaded and then my ble_app_blinky with UART application is loaded.

    1) Because of Secure serial bootloader whether serial uart is always enabled. Even I am not seeing calling nrfx_uarte_uninit().

    2) (Or) Can I assume when pin is pressed then only chip will enter into boot mode and once DFU done, device will reset, so no issue even if there is no initialization of uart.

    3) What will be the current with uart enabled. Whether it will be 3 to 4 mA of ideal current. Anyway I will test practically, but this is for my quick understanding.

    Thanks & Regards

    Vishnu Beema

Children
No Data
Related