Skip to content

Commit

Permalink
boards: fixed STM systick frequency
Browse files Browse the repository at this point in the history
Initialized the systick with the correct frequency. The default one
provided by the SYST_CALIB register is fixed for the STM chips and does
not reflect the actual systick frequency.
  • Loading branch information
GabrielPavaloiu committed Sep 30, 2024
1 parent e2128ba commit a45c6e7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
5 changes: 4 additions & 1 deletion boards/nucleo_f429zi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use kernel::scheduler::round_robin::RoundRobinSched;
use kernel::{create_capability, debug, static_init};

use stm32f429zi::chip_specs::Stm32f429Specs;
use stm32f429zi::clocks::hsi::HSI_FREQUENCY_MHZ;
use stm32f429zi::gpio::{AlternateFunction, Mode, PinId, PortId};
use stm32f429zi::interrupt_service::Stm32f429ziDefaultPeripherals;

Expand Down Expand Up @@ -663,7 +664,9 @@ unsafe fn start() -> (
rng,

scheduler,
systick: cortexm4::systick::SysTick::new(),
systick: cortexm4::systick::SysTick::new_with_calibration(
(HSI_FREQUENCY_MHZ * 1_000_000) as u32,
),
can,
date_time,
};
Expand Down
5 changes: 4 additions & 1 deletion boards/nucleo_f446re/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use kernel::platform::{KernelResources, SyscallDriverLookup};
use kernel::scheduler::round_robin::RoundRobinSched;
use kernel::{create_capability, debug, static_init};
use stm32f446re::chip_specs::Stm32f446Specs;
use stm32f446re::clocks::hsi::HSI_FREQUENCY_MHZ;
use stm32f446re::gpio::{AlternateFunction, Mode, PinId, PortId};
use stm32f446re::interrupt_service::Stm32f446reDefaultPeripherals;

Expand Down Expand Up @@ -507,7 +508,9 @@ unsafe fn start() -> (
gpio,

scheduler,
systick: cortexm4::systick::SysTick::new(),
systick: cortexm4::systick::SysTick::new_with_calibration(
(HSI_FREQUENCY_MHZ * 1_000_000) as u32,
),
};

// // Optional kernel tests
Expand Down
3 changes: 2 additions & 1 deletion boards/stm32f3discovery/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,8 @@ unsafe fn start() -> (
nonvolatile_storage,

scheduler,
systick: cortexm4::systick::SysTick::new(),
// Systick uses the HSI, which runs at 8MHz
systick: cortexm4::systick::SysTick::new_with_calibration(8_000_000),
watchdog: &peripherals.watchdog,
};

Expand Down
5 changes: 4 additions & 1 deletion boards/stm32f412gdiscovery/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use kernel::platform::{KernelResources, SyscallDriverLookup};
use kernel::scheduler::round_robin::RoundRobinSched;
use kernel::{create_capability, debug, static_init};
use stm32f412g::chip_specs::Stm32f412Specs;
use stm32f412g::clocks::hsi::HSI_FREQUENCY_MHZ;
use stm32f412g::interrupt_service::Stm32f412gDefaultPeripherals;

/// Support routines for debugging I/O.
Expand Down Expand Up @@ -766,7 +767,9 @@ unsafe fn start() -> (
rng,

scheduler,
systick: cortexm4::systick::SysTick::new(),
systick: cortexm4::systick::SysTick::new_with_calibration(
(HSI_FREQUENCY_MHZ * 1_000_000) as u32,
),
};

// // Optional kernel tests
Expand Down
5 changes: 4 additions & 1 deletion boards/stm32f429idiscovery/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use kernel::scheduler::round_robin::RoundRobinSched;
use kernel::{create_capability, debug, static_init};

use stm32f429zi::chip_specs::Stm32f429Specs;
use stm32f429zi::clocks::hsi::HSI_FREQUENCY_MHZ;
use stm32f429zi::gpio::{AlternateFunction, Mode, PinId, PortId};
use stm32f429zi::interrupt_service::Stm32f429ziDefaultPeripherals;

Expand Down Expand Up @@ -591,7 +592,9 @@ unsafe fn start() -> (
gpio,

scheduler,
systick: cortexm4::systick::SysTick::new(),
systick: cortexm4::systick::SysTick::new_with_calibration(
(HSI_FREQUENCY_MHZ * 1_000_000) as u32,
),
};

// // Optional kernel tests
Expand Down
5 changes: 4 additions & 1 deletion boards/weact_f401ccu6/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use kernel::scheduler::round_robin::RoundRobinSched;
use kernel::{create_capability, debug, static_init};

use stm32f401cc::chip_specs::Stm32f401Specs;
use stm32f401cc::clocks::hsi::HSI_FREQUENCY_MHZ;
use stm32f401cc::interrupt_service::Stm32f401ccDefaultPeripherals;

/// Support routines for debugging I/O.
Expand Down Expand Up @@ -448,7 +449,9 @@ unsafe fn start() -> (
alarm,
gpio,
scheduler,
systick: cortexm4::systick::SysTick::new(),
systick: cortexm4::systick::SysTick::new_with_calibration(
(HSI_FREQUENCY_MHZ * 1_000_000) as u32,
),
};

debug!("Initialization complete. Entering main loop");
Expand Down

0 comments on commit a45c6e7

Please sign in to comment.