You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#![no_std]#![no_main]externcrate panic_halt;use cortex_m::asm;use cortex_m_rt::entry;use cortex_m::peripheral::syst::SystClkSource;use cortex_m::peripheral::SYST;use cortex_m_semihosting::{debug, hprintln};#[entry]fnmain() -> ! {let p = cortex_m::Peripherals::take().unwrap();letmut syst = p.SYST;
syst.set_clock_source(SystClkSource::Core);
syst.set_reload(SYST::get_ticks_per_10ms()*1000);// Works strange in QEMU?
syst.enable_counter();hprintln!("{} ticks = 10 millisecond",SYST::get_ticks_per_10ms()).unwrap();letmut seconds:usize = 0;loop{// busy wait until the timer wraps aroundwhile !syst.has_wrapped(){}
seconds += 1;hprintln!("{} seconds passed", seconds).unwrap();// prints every second!}}
I checked that fn get_ticks_per_10ms always returns 10_000 in my program.
Since I set called the set_reload function with an argument of get_ticks_per_10ms() * 1_000,
I expected the program to print out to the console every 10 seconds (since ticks_per_10ms * 1_000 == ticks_per_10seconds).
However, the program prints out to the console every 1 second.
I tried changing the argument fed to set_reload(), and it seems like the get_ticks_per_10ms() is behaving like get_ticks_per_1ms().
Unfortunately, I do not have an actual cortex-m device to test this behavior.
I'm currently not sure whether this is an issue with the api of the cortex-m crate, or QEMU.
If this is an issue with the cortex-m crate, maybe the function name of fn get_ticks_per_10ms should be changed to fn get_ticks_per_1ms.
Thank you for reading 😄
The text was updated successfully, but these errors were encountered:
My bet is the qemu model has just implemented the calib register wrong. Could you check is_precise? perhaps qemu agrees that the value returned by calib is wrong
Hello,
Using the Cargo config as below,
I tested running the below program using QEMU.
I checked that
fn get_ticks_per_10ms
always returns 10_000 in my program.Since I set called the
set_reload
function with an argument ofget_ticks_per_10ms() * 1_000
,I expected the program to print out to the console every 10 seconds (since ticks_per_10ms * 1_000 == ticks_per_10seconds).
However, the program prints out to the console every 1 second.
I tried changing the argument fed to
set_reload()
, and it seems like theget_ticks_per_10ms()
is behaving likeget_ticks_per_1ms()
.Unfortunately, I do not have an actual cortex-m device to test this behavior.
I'm currently not sure whether this is an issue with the api of the
cortex-m
crate, or QEMU.If this is an issue with the
cortex-m
crate, maybe the function name offn get_ticks_per_10ms
should be changed tofn get_ticks_per_1ms
.Thank you for reading 😄
The text was updated successfully, but these errors were encountered: