Hi
I am using TMS 570 processor for cycles measurement of basic functions like FIR, FFT etc..
I am using MDK keil platform and using the following code to calculate cycles.
I am getting differant cycles(almost doubled) for same function when i run on cortex-R4( NXP FCC2) and cortex-R4(TMS 570).
Can you please where i am going wrong when calculation on TMS570. I am using following code for the cycles measurement.
/* initialisation */
Enable_Performance_Monitor(0);
Performance_Monitor_Start(0);
/* ----------------------------------------------------------------------
** Initialize the timer calculation.
** ------------------------------------------------------------------- */
startTime = Performance_Monitor_Read_CycleCount(0);
/* ----------------------------------------------------------------------
** Call the my_function
** ------------------------------------------------------------------- */
my_function();
/* ----------------------------------------------------------------------
** Calculate the execution time
** ------------------------------------------------------------------- */
endTime = Performance_Monitor_Read_CycleCount(0);
execTime = endTime - startTime;
where functions are defined as below
export Enable_Performance_Monitor
Enable_Performance_Monitor
MOV r0, #0
MCR p15, #0, r0, c9, c12, #5 ; Write PMNXSEL Register = select performance monitor counter #0
MOV r0, #0x01 ; select I$ miss
MCR p15, #0, r0, c9, c13, #1 ; Write EVTSELx Register
MOV r0, #1
MCR p15, #0, r0, c9, c12, #5 ; Write PMNXSEL Register = select performance monitor counter #1
MOV r0, #0x03 ; # D$ miss
MCR p15, #0, r0, c9, c13, #1 ; Write EVTSELx Register
MOV r0, #2
MCR p15, #0, r0, c9, c12, #5 ; Write PMNXSEL Register = select performance monitor counter #2"
MOV r0, #0x08 ; Instruction architecturally executed
MCR p15, #0, r0, c9, c13, #1 ; Write EVTSELx Register
MRC p15, #0, r0, c9, c12, #0 ; Read PMNC Register
ORR r0, r0, #7 ; reset cycle + performance counters and enable
MCR p15, #0, r0, c9, c12, #0 ; Write PMNC Register
BX LR
export Performance_Monitor_Start
Performance_Monitor_Start
MRC p15, #0, r0, c9, c12, #1 ; Read CNTENS Register
ORR r0, r0, #7 ; Enable counters 0,1,2
ORR r0, r0, #0x80000000 ; Enable cycle counter
MCR p15, #0, r0, c9, c12, #1 ; Write CNTENS Register
BX LR;
export Performance_Monitor_Stop
Performance_Monitor_Stop
MRC p15, #0, r0, c9, c12, #2 ; Read CNTENC Register
ORR r0, r0, #7 ; Disable counters 0,1,2
ORR r0, r0, #0x80000000 ; Disable cycle counter
MCR p15, #0, r0, c9, c12, #2 ; Write CNTENC Register");
BX LR
export Performance_Monitor_Read_CycleCount
Performance_Monitor_Read_CycleCount
MRC p15, #0, r0, c9, c13, #0 ; Read CCNT Register
BX LR
end
Thanks in advance ,
Kranti