Question:
Is there any Cycle-Counting Macros available for ARM core similar to SHARC/Blackfin?
Answer:
Yes, Cycle-counting macros, similar to those available for SHARC and Blackfin, have been added to the GNU ARM Bare Metal toolchain.
These are available in the header file cycle_count.h. These cycle counters differ from those on Blackfin and SHARC due to the way in which they are programmed.
There are two sets of macros defined in the header cycle_count.h. The core macros and the "with statistics" macros. The latter should be familiar to Blackfin and SHARC users.
Example Using Core Cycle-Counting Macros:
#include <cycle_count.h>
#include <stdio.h>
int main(void)
{
CCNTR_INIT;
CCNTR_START;
Some_Function_Or_Code_To_Measure();
CCNTR_STOP;
uint32_t x = CCNTR_READ;
printf("Cycles: %lu\n", x);
return 0;
}
Example Using Cycle Counting with Statistics Macros:
#include <cycle_count.h>
#include <stdio.h>
int main()
{
cycle_stats_t stats;
CYCLES_INIT(stats);
CYCLES_START(stats);
Some_Function_Or_Code_To_Measure();
CYCLES_STOP(stats) ;
CYCLES_PRINT(stats);
CYCLES_RESET(stats);
return 0;
}