Higher baud rate support on nrf5340

Hi,

Just wanted to know if nrf5340dk supports for UART baud rates until 512kbps.?
And specific baud rates configuration like 122800.?

If yes, is it simply configured as in below.? or takes different configuration.?

#include <zephyr/kernel.h>
#include <zephyr/drivers/uart.h>

const struct device *uart_dev;

void main(void)
{
    uart_dev = device_get_binding("UART_0");
    if (!uart_dev) {
        printk("UART device not found!\n");
        return;
    }

    struct uart_config cfg = {
        .baudrate = 122800,
        .parity = UART_CFG_PARITY_NONE,
        .stop_bits = UART_CFG_STOP_BITS_1,
        .data_bits = UART_CFG_DATA_BITS_8,
        .flow_ctrl = UART_CFG_FLOW_CTRL_NONE,
    };

    if (uart_configure(uart_dev, &cfg) != 0) {
        printk("Failed to configure UART\n");
    } else {
        printk("UART configured to 122800 baud rate\n");
    }
}


Parents Reply
  • Mohammed Ubaid said:
    So i need to start HFCLK first and then configure my UART.

    Each time you want to send or receive UART data you need to start the HFCLK yes, you can stop it when there is no data ro send or receive. 

    Mohammed Ubaid said:
    Can you point me to any code sample or snippet wherein HFCLK is enabled for UART port.?

    To start the HFCLK you can for instance check out clock_init() in nrf\samples\peripheral\radio_test\.

    Kenneth

Children
Related