![]() Since the SysTick is a decrement counter, the value of the “start_time” is greater than that for the “stop_time”. Stop_time = SysTick->VAL // Obtains the stop timeĬycle_count = start_time – stop_time // Calculates the time taken Start_time = SysTick->VAL // Obtains the start timeįunction() // Executes the function to be measured While(SysTick->VAL != 0) // Waits until the SysTick is reloaded SysTick->CTRL = 0x5 // Enables the SysTick, uses the processor clock SysTick->VAL = 0 // Clears the current value to 0 SysTick->LOAD = 0xFFFFFFFF // Sets the Reload value to maximum Unsigned int start_time, stop_time, cycle_count For example, you can measure the duration of a short function using the following code: The SysTick timer can be used for timing measurements.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |