Skip to content

Commit 079941f

Browse files
committed
Kind of fix pktgen example
1 parent 900536c commit 079941f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

examples/pktgen.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn main() -> ! {
3737

3838
let (clocks, gpio, ethernet) = common::setup_peripherals(p);
3939

40-
setup_systick(&mut cp.SYST);
40+
setup_systick(&mut cp.SYST, clocks.hclk().to_Hz());
4141

4242
defmt::info!("Enabling ethernet...");
4343
let (eth_pins, mdio, mdc, _) = common::setup_pins(gpio);
@@ -68,6 +68,7 @@ fn main() -> ! {
6868
// print stats every 30 seconds
6969
if time >= last_stats_time + 30 {
7070
let t = time - last_stats_time;
71+
7172
defmt::info!(
7273
"T={}\tRx:\t{} KB/s\t{} pps\tTx:\t{} KB/s\t{} pps",
7374
time,
@@ -142,8 +143,8 @@ fn main() -> ! {
142143
}
143144
}
144145

145-
fn setup_systick(syst: &mut SYST) {
146-
syst.set_reload(100 * SYST::get_ticks_per_10ms());
146+
fn setup_systick(syst: &mut SYST, hclk: u32) {
147+
syst.set_reload(hclk.min(0x00FF_FFFF));
147148
syst.enable_counter();
148149
syst.enable_interrupt();
149150

0 commit comments

Comments
 (0)