Module imxrt_hal::pit

source ·
Expand description

Periodic interrupt timers.

PITs are countdown timers that run on the PERCLK clock root. When the timer elapses, it automatically restarts from the load value. There are four PIT channels for independent time tracking. The four channels share an interrupt.

You can chain channels together by using Chained. This doubles the width of the timer.

Example

Note that these examples do not demonstrate how to configure the PIT clock gates, or PERCLK. For more information, see the CCM peripheral clock module.

Acquire the four PIT timer channels:

use imxrt_hal::pit;
use imxrt_ral::pit::PIT;

let (mut pit0, mut pit1, _, _) = pit::new(unsafe { PIT::instance() });

Use pit0 to implement a blocking delay:

pit0.set_load_timer_value(DELAY_MS);
pit0.enable();

loop {
    while !pit0.is_elapsed() {}
    pit0.clear_elapsed();
    // Do work...
}

Chain the channels together to form a larger timer:


let chained = pit::Chained01::new(pit0, pit1);

Structs

  • Two chained PIT timer channels.
  • A periodic interrupt timer (PIT) channel.

Enums

  • Type-level constant for PIT channels.

Traits

  • Describes a valid PIT channel.

Functions

  • Convert the PIT peripheral instances into four timer channels.

Type Aliases