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
I tried using a MonoTimer to measure time between two events (in my case, some button pushes). I noticed the time-based code was never firing, and dug into the code until I discovered that DWT::get_cycle_count always returns 1073741824 (2^30)
In order for clock cycles to be successfully reported from DWT, I have to call cp.DCB.enable_trace();
Here is a minimal reproduction of the issue, printing the clock cycle counts over a serial interface. My hardware is a "black pill" stm32f103c8t6, specifically this dev board. I flash and monitor output via a CP2102 serial-usb adapter. I'm not currently using a debugger probe of any sort.
Huh, I didn't know you could enable the DWT without a debugger attached, we probably should do that then... Though it still feels a bit odd to use the debug peripheral for timekeeping
I just tested this on a bluepill, and withoutcp.DCB.enable_trace(), DWT::get_cycle_count() always returns 1073741824 (same as @bschwind ). However, when I enable trace, it always returns 0.
I haven't been able to get it to actually count cycles yet.
Ah, spoke too soon. If I enable trace before I create the MonoTimer everything is working fine on my bluepill. Enabling it after makes it always return 0.
I tried using a
MonoTimer
to measure time between two events (in my case, some button pushes). I noticed the time-based code was never firing, and dug into the code until I discovered thatDWT::get_cycle_count
always returns1073741824
(2^30)In order for clock cycles to be successfully reported from
DWT
, I have to callcp.DCB.enable_trace();
Here is a minimal reproduction of the issue, printing the clock cycle counts over a serial interface. My hardware is a "black pill"
stm32f103c8t6
, specifically this dev board. I flash and monitor output via a CP2102 serial-usb adapter. I'm not currently using a debugger probe of any sort.I found a few older issues in earlier repositories about this:
The text was updated successfully, but these errors were encountered: