Skip to content

[Question] Timers are not working on RP235xB #6079

Description

@Conaclos

I am trying to measure times in a program using embassy on a RP235xB.
Unfortunately, .elapsed().as_micros() always returns 0.
Here is my code:

#[embassy_executor::main]
async fn main(_spawner: embassy_executor::Spawner) {
    let p = embassy_rp::init(Default::default());

    let config = embassy_rp::aon_timer::Config {
        clock_source: embassy_rp::aon_timer::ClockSource::Xosc,
        clock_freq_khz: 1000,
        alarm_wake_mode: embassy_rp::aon_timer::AlarmWakeMode::WfiOnly,
    };
    let mut timer = AonTimer::new(p.POWMAN, Irqs, config);
    timer.set_counter(0);

    let start = timer.elapsed().as_micros();
    embassy_time::Timer::after_secs(1).await;
    let end = timer.elapsed().as_micros();
    defmt::info!("time: {}", end - start); // prints `0` because `start` and `end` are `0`.
}

In my Cargo.toml I have the following dependencies / cargo features:

embassy-embedded-hal = { version = "0.6.0", features = ["defmt"] }
embassy-sync = { version = "0.8.0", features = ["defmt"] }
embassy-executor = { version = "0.10.0", features = ["platform-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
embassy-time = { version = "0.5.1", features = ["defmt", "defmt-timestamp-uptime"] }
embassy-rp = { version = "0.10.0", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl", "rp235xb"] }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions