![]() I just wanted to use cycle count related information about execution time of tasks of FreeRTOS, so I check the overflows in vApplicationTickHook() and in getRunTimeCounterValue() I have just return get_cyccnt_ext() > 8 (I divide it because the runtime debugger values are only 32-bit).Rest 2nd Gen is the do-it-all sleep device that you can control from your phone. If (DWT->FUNCTION0 & DWT_FUNCTION_MATCHED_Msk) cyccnt_ext.u32++ So I just increment the 64-bit cycle counter variable by 2^32 whenever the bit is set, while checking it in external counter peripheral IRQHandler (updating it by calling get_cyccnt_ext() function): I also wanted it to produce a interrupt, however when I tried to use DebugMon_Handler, each overflow also paused the debug session which I don’t want. The bit 24 of DWT->FUNCTION0 (DWT_FUNCTION_MATCHED_Msk) is set when the overflow occurs, I tested it with the debugger. I initialize DWT as:ĬoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk ĭWT->FUNCTION0 |= DWT_FUNCTION_CYCMATCH_Msk | 0x01 Well I am using STM32CubeIDE with Nucleo-H745ZI-Q. With this, it shows the current cycle counter: To monitor the cycle counter during a debug session is easy: add the following expression tothe ‘Expressions’ view: (*((volatile uint32_t*)0圎0001004)) ![]() KIN1_DisableCycleCounter() /* disable counting if not used any more */ KIN1_EnableCycleCounter() /* start counting */įoo() /* call function and count cycles */Ĭycles = KIN1_GetCycleCounter() /* get cycle counter */ KIN1_ResetCycleCounter() /* reset cycle counter */ KIN1_InitCycleCounter() /* enable DWT hardware */ ![]() To make it work with no debug session active, I have to initialize it in the code first. If you are connecting to the target with a debugger, then this is usually already enabled by the debugger. To use the cycle counting feature, the DWT has to be configured and enabled. KIN1_DWT_CONTROL &= ~KIN1_DWT_CYCCNTENA_BIT KIN1_DWT_CONTROL |= KIN1_DWT_CYCCNTENA_BIT *!< TRCENA: Enable trace and debug block DEMCR (Debug Exception and Monitor Control Register */ To use the registers, I have defined a set of ‘function like’ macros I can use in my application code: ![]() ![]() *!< Trace enable bit in DEMCR register */ *!< DEMCR: Debug Exception and Monitor Control Register */ *!< CYCCNTENA bit in DWT_CONTROL register */ * DWT (Data Watchpoint and Trace) registers, only exists on ARM Cortex with a DWT unit */ You might use CMSIS-Core header files for this, but as there are very few registers in case CMSIS-Core is not used, here are the needed defines I’m going to use: To use the feature, I need to have access to several debug registers. The DWT is usually implemented in Cortex-M3 or higher, but not on Cortex-M0(+). This post is about how to use it directly from the application code or to enable cycle counting and inspect it during debugging. Execution profiling tools like the SEGGER SystemView are using it to measure the time used for code execution. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |