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

I want to change baudrate of uart at nRF52832

Hello,

I use the SDK15.3.0.

(nRF5_SDK_15.3.0_59ac345 -> example -> ble_peripheral -> ble_app_uart ->pca10040 -> s132 -> ses)

The default baudrate of uart is 115200bps.

I want to change baudrate to 38400bps.

I saw the following file. (sdk_config.h, nrf_uart.h, nrf52_bitfields.h, nrf52.h, etc.)

I did not understand which files need to be changed.

Please teach me how to change the boardrate of uart.

Best regards,

Toru

Parents Reply Children
  • Hi cbd-san,

    Thank you for your reply.

    I tried the solution from you.

    But the baudrate did not change.

    Can you advise me why it can not change the baudrate?

    Best regards,

    Toru

  • Okay.

    I suspect that you may have UART enabled as well as UARTE - it is confusing I know. I believe that UART is to be legacy code support and that UARTE is the way forward.

    Try checking NRFX_UART_DEFAULT_CONFIG_BAUDRATE

    If you wanted to change it directly then you could use the following within your own code where you define the values for RX_PIN_NUMBER, TX_PIN_NUMBER … etc.:

    static uint32_t com_UartInit(void)
    {
        uint32_t err_code;
        app_uart_comm_params_t const comm_params = {
            .rx_pin_no = RX_PIN_NUMBER,
            .tx_pin_no = TX_PIN_NUMBER,
            .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_38400
    #else
            .baud_rate = NRF_UARTE_BAUDRATE_38400
    #endif
        };
    
        APP_UART_FIFO_INIT(&comm_params, UART_BUF_SIZE, UART_BUF_SIZE,
                           com_UartEventHandler, /* Handler for UART events */
                           APP_IRQ_PRIORITY_LOWEST, err_code);
    
        return (err_code);
    }

  • Hi cbd-san,

    Sorry for my late reply.

    I checked the codes along with the advice from you.

    And I was able to find the wrong code.

    I was able to run uart at 38400 bps.

    Thank you for your support.

    Best regards,

    Toru

Related