From c4c537362e3c42fefd2b0ce848de95d14495c726 Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Tue, 25 Jul 2023 12:38:46 +0100 Subject: [PATCH 1/2] Switch to micros instead of millis --- esp-hal-common/src/systimer.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/esp-hal-common/src/systimer.rs b/esp-hal-common/src/systimer.rs index a297b41945e..7396ef063f7 100644 --- a/esp-hal-common/src/systimer.rs +++ b/esp-hal-common/src/systimer.rs @@ -2,7 +2,7 @@ use core::{intrinsics::transmute, marker::PhantomData}; -use fugit::MillisDurationU32; +use fugit::MicrosDurationU32; use crate::{ peripheral::{Peripheral, PeripheralRef}, @@ -202,14 +202,14 @@ impl Alarm { impl Alarm { pub fn set_period(&self, period: fugit::HertzU32) { - let time_period: MillisDurationU32 = period.into_duration(); - let cycles = time_period.ticks(); + let time_period: MicrosDurationU32 = period.into_duration(); + let us = time_period.ticks(); self.configure(|tconf, hi, lo| unsafe { tconf.write(|w| { w.target0_period_mode() .set_bit() .target0_period() - .bits(cycles * (SystemTimer::TICKS_PER_SECOND as u32 / 1000)) + .bits(us * (SystemTimer::TICKS_PER_SECOND as u32 / 1000_000)) }); hi.write(|w| w.timer_target0_hi().bits(0)); lo.write(|w| w.timer_target0_lo().bits(0)); From 058c9ed30031355a15c7f504686554a206a3e80c Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Tue, 25 Jul 2023 13:20:12 +0100 Subject: [PATCH 2/2] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa57a7dd1d5..b9a9c3ab23e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - USB device support is working again (#656) - Add missing interrupt status read for esp32s3, which fixes USB-SERIAL-JTAG interrupts (#664) - GPIO interrupt status bits are now properly cleared (#670) +- Increase frequency resolution in `set_periodic` (#686) ### Removed