Module imxrt_hal::ccm::uart_clk

source ·
Expand description

UART clock root.

uart_clk provides the clock source for all LPUART peripherals. You must disable LPUART clock gates before selecting the clock and divider.

§Example

Select a 24MHz clock for the LPUART peripherals. This would affect how baud rate is computed. Since we’re only using the second LPUART peripheral, we only disable and enable its clock gates.

use imxrt_hal as hal;
use hal::ccm::{uart_clk, clock_gate};

use imxrt_ral as ral;

const UART_CLK_DIVIDER: u32 = 1;
const UART_CLK_HZ: u32 = hal::ccm::XTAL_OSCILLATOR_HZ / UART_CLK_DIVIDER;

let mut ccm = unsafe { ral::ccm::CCM::instance() };
clock_gate::lpuart::<2>().set(&mut ccm, clock_gate::OFF);
uart_clk::set_selection(&mut ccm, uart_clk::Selection::Oscillator);
uart_clk::set_divider(&mut ccm, UART_CLK_DIVIDER);

clock_gate::lpuart::<2>().set(&mut ccm, clock_gate::ON);

Enums§

Constants§

Functions§