Q) How to get timer value or current time to measure a execution time of a function.

Dear,

Can I get a timer value or current time to measure a execution time of a function?

I would like to get micro second resolution.

Thank you.

Hi there

Are you using Arduino or the SDK by itself?

If you are using Arduino you can use the ‘micros()’ function to return the system time since startup in microseconds.

If you are using the AmbiqSuite HAL directly you can configure the STimer (system timer) peripheral to keep track of system time for you. You can then use any number of function calls to manipulate that value. The api is located in AmbiqSuiteSDK/mcu/apollo3/hal/am_hal_stimer.h (and it is what the Arduino functions are built on top of)

If you have more questions feel free to reach out!