2010-03-18 03:45 AM
How to count execution cycles
2011-05-17 04:43 AM
I found a way searching the net. The ARM Cortex has a Cycle counter register. Below is C code to initialize it and read it. Using the Memory View to look at the value of the register at memory location 0xE0001004 let you see the counter updating as you step through the code.
int count = 0; volatile unsigned int *DWT_CYCCNT = (int *)0xE0001004; //address of the register volatile unsigned int *DWT_CONTROL = (int *)0xE0001000; //address of the register volatile unsigned int *SCB_DEMCR = (int *)0xE000EDFC; //address of the register *SCB_DEMCR = *SCB_DEMCR | 0x01000000; *DWT_CYCCNT = 0; // reset the counter *DWT_CONTROL = *DWT_CONTROL | 1 ; // enable the counter ....... ...... count = *DWT_CYCCNT;2011-05-17 04:43 AM
http://forums.arm.com/index.php?showtopic=13949
https://my.st.com/public/STe2ecommunities/mcu/Lists/ARM%20CortexM3%20STM32/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fARM%20CortexM3%20STM32%2fconfigure%20a%20general%20purpose%20TIMx%20%28x%3d2%2c3%2c4%29%20same%20as%20Systick%20on%20STM32F103B&FolderCTID=0x01200200770978C69A...