Skip to content

How to print out the current CPU clock in Zephyr OS? #84633

Answered by ldomaigne
MasterKeyxda asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

If I understand your question correctly, you could get the CPU clock speed in Hz, KHz or MHz using the function k_xxx_to_cyc_floor32 from time_unit.h (or the floor64 variant if you prefer 64 bits integer):

#include <kernel/sys/time_units.h>
k_sec_to_cyc_floor32(1); // 1sec to #cycle => Hz
k_ms_to_cyc_floor32(1);  // 1ms to # cycle => kHz
k_us_to_cyc_floor32(1);  // 1us to # cycle => MHz 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MasterKeyxda
Comment options

Answer selected by MasterKeyxda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants