hard20 pts · first answer countsmicrocontrollersdebuggingcortex-m
Timing an ISR in CPU cycles
You want the exact cycle count of a function on a Cortex-M4. Which approach is precise and cheap?
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; DWT->CYCCNT = 0; DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; uint32_t t0 = DWT->CYCCNT; filter_step(); uint32_t cycles = DWT->CYCCNT - t0;
Discussion 0
Join free to post in the discussion.
Related questions
- What an open-drain output can doEmbedded Systems Engineer
- Button wired to ground with pull-upEmbedded Systems Engineer
- Meaning of an NRST pinEmbedded Systems Engineer
- Setting bit 5 of a registerEmbedded Systems Engineer
- GPIO alternate function modeEmbedded Systems Engineer
- Polling versus interruptsEmbedded Systems Engineer
- Hooking an ISR in CMSIS startup codeEmbedded Systems Engineer
- 16-bit timer overflow timeEmbedded Systems Engineer