How can I programmatically find the CPU frequency with C

后端 未结 5 1522

I\'m trying to find out if there is anyway to get an idea of the CPU frequency of the system my C code is running on.

To clarify, I\'m looking for an abstract soluti

5条回答
  •  执笔经年
    2020-12-08 09:06

    I guess one way to get clock frequency from software is by hard coding knowledge of Hardware Reference Manual(HRM) into software. You can read the clock configuration registers from the software. Assuming you know the source clock frequency, software can use the multiplier and divisor values from the clock registers and apply appropriate formulas as mentioned in HRM to derive clock frequency.

提交回复
热议问题