Hi,
I'm using RT1060 and MCUXpresso IDE. Is there any function or SDK sample that I can measured the elapsed time of a function? Or the time since the system has started? Thanks!
Solved! Go to Solution.
The easiest thing is that you simply read the ARM Cortex cycle counter:
https://mcuoneclipse.com/2017/01/30/cycle-counting-on-arm-cortex-m-with-dwt/
With the SystemCoreClock variable you know the clock frequency, with this you have a time information. Just keep in mind that this would not reflect any clock speed changes.
With the above you can measure the time elapsed for a function too.
Otherwise you can use the RTC registers too for a system time.
I hope this helps,
Erich
The easiest thing is that you simply read the ARM Cortex cycle counter:
https://mcuoneclipse.com/2017/01/30/cycle-counting-on-arm-cortex-m-with-dwt/
With the SystemCoreClock variable you know the clock frequency, with this you have a time information. Just keep in mind that this would not reflect any clock speed changes.
With the above you can measure the time elapsed for a function too.
Otherwise you can use the RTC registers too for a system time.
I hope this helps,
Erich
Hi @ErichStyger ,
The link mentioned about MCU with DWT feature. What about MCU without DWT?
How to obtain the elapsed time from system startup in iMX RT1064 - to be precise if asked so?
An alternative approach might be to get the execution time with semihosting and
McuSemihost_Op_SYS_CLOCK
See https://mcuoneclipse.com/2023/03/09/using-semihosting-the-direct-way/ and the implementation in McuSemihost.c
I hope this helps,
Erich