Not applicable
Oct 16, 2015
06:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 16, 2015
06:14 AM
Hello,
I'm working with a Tricore 1767 on a Infineon Hybridkit2.
I want to measure the execution time of my implemented code.
I found this file:
http://www.infineon.com/dgdl/ap3216810_TriCore_Performace_Optimization.pdf?folderId=db3a304313719f4f...
In Chap. 2.2 they refere to the CPU Clock Counter CCNT.
It's def in regtc1767.sfr :
#define CCTRL 0xfc00 /* Counter Control Register */
In Fig.1 is an example:
// Start Measure
t1a=__mfcr(CCNT);
t1b=__mfcr(ICNT);
Benchmark();
// Stop Measure
t2a=__mfcr(CCNT);
t2b=__mfcr(ICNT);
cpu_clk = t2a-t1a;
instr_cnt = t2b-t1b;
Note: Performance Counters need be enabled before can be used. To enable all the counters set the CCTRL.CE bit to 1.
My questions are:
-How to read CCNT in my code?
-Where to set CCTRL.CE bit?
-Whats the Datatype of t1a=__mfcr(CCNT)?
My first idea was to Measure the execution time via Analog Output Port toggeling.
But I didn't find the functions to set the Analog I/O to Output and set the values.
Can someone help me with one of those two methods, or is there a better way to measure execution time?
Thanks,
Max
I'm working with a Tricore 1767 on a Infineon Hybridkit2.
I want to measure the execution time of my implemented code.
I found this file:
http://www.infineon.com/dgdl/ap3216810_TriCore_Performace_Optimization.pdf?folderId=db3a304313719f4f...
In Chap. 2.2 they refere to the CPU Clock Counter CCNT.
It's def in regtc1767.sfr :
#define CCTRL 0xfc00 /* Counter Control Register */
In Fig.1 is an example:
// Start Measure
t1a=__mfcr(CCNT);
t1b=__mfcr(ICNT);
Benchmark();
// Stop Measure
t2a=__mfcr(CCNT);
t2b=__mfcr(ICNT);
cpu_clk = t2a-t1a;
instr_cnt = t2b-t1b;
Note: Performance Counters need be enabled before can be used. To enable all the counters set the CCTRL.CE bit to 1.
My questions are:
-How to read CCNT in my code?
-Where to set CCTRL.CE bit?
-Whats the Datatype of t1a=__mfcr(CCNT)?
My first idea was to Measure the execution time via Analog Output Port toggeling.
But I didn't find the functions to set the Analog I/O to Output and set the values.
Can someone help me with one of those two methods, or is there a better way to measure execution time?
Thanks,
Max
Labels
- Tags:
- IFX
4 Replies
Feb 25, 2016
09:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 25, 2016
09:44 AM
Hey,
I know this is old but I think many people will have similar problems. I finally solved it like this:
if you don't use the framework, this is what the framework basically does (copied from Infineon SW Framework version iLLD_1_0_0_8_0):
Good luck,
Matthias
I know this is old but I think many people will have similar problems. I finally solved it like this:
void benchmark_start()
{
IfxCpu_resetAndStartCounters(IfxCpu_CounterMode_normal);
}
IfxCpu_Perf benchmark_end()
{
return IfxCpu_stopCounters();
}
void benchmark_output(IfxCpu_Perf benchmark_result)
{
uart_send_int(benchmark_result.clock.counter); /* uart_send_int is my own function */
uart_send_int(benchmark_result.instruction.counter);
}
if you don't use the framework, this is what the framework basically does (copied from Infineon SW Framework version iLLD_1_0_0_8_0):
IFX_INLINE void IfxCpu_resetAndStartCounters(IfxCpu_CounterMode mode)
{
Ifx_CPU_CCTRL cctrl;
cctrl.U = __mfcr(CPU_CCTRL);
/*Disable the counters */
cctrl.B.CE = 0;
__mtcr(CPU_CCTRL, cctrl.U);
/* reset the counters */
__mtcr(CPU_CCNT, 0);
__mtcr(CPU_ICNT, 0);
__mtcr(CPU_M1CNT, 0);
__mtcr(CPU_M2CNT, 0);
__mtcr(CPU_M3CNT, 0);
/*Enable the counters, set the counter mode */
cctrl.B.CE = 1;
cctrl.B.CM = mode;
__mtcr(CPU_CCTRL, cctrl.U);
}
IFX_INLINE IfxCpu_Perf IfxCpu_stopCounters(void)
{
IfxCpu_Perf result;
/*Disable the counters, reset the control reg */
/* Use inline assembly to ensure constant implementation, and execution of the measurement routines */
__stopPerfCounters();
Ifx_CPU_CCNT ccnt;
ccnt.U = __mfcr(CPU_CCNT);
result.clock.counter = ccnt.B.CountValue;
result.clock.overlfow = ccnt.B.SOvf;
Ifx_CPU_ICNT icnt;
icnt.U = __mfcr(CPU_ICNT);
result.instruction.counter = icnt.B.CountValue;
result.instruction.overlfow = icnt.B.SOvf;
Ifx_CPU_M1CNT m1cnt;
m1cnt.U = __mfcr(CPU_M1CNT);
result.counter1.counter = m1cnt.B.CountValue;
result.counter1.overlfow = m1cnt.B.SOvf;
Ifx_CPU_M2CNT m2cnt;
m2cnt.U = __mfcr(CPU_M2CNT);
result.counter2.counter = m2cnt.B.CountValue;
result.counter2.overlfow = m2cnt.B.SOvf;
Ifx_CPU_M3CNT m3cnt;
m3cnt.U = __mfcr(CPU_M3CNT);
result.counter3.counter = m3cnt.B.CountValue;
result.counter3.overlfow = m3cnt.B.SOvf;
return result;
}
Good luck,
Matthias
Jun 27, 2019
02:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 27, 2019
02:46 AM
Hello Matthias,
I'm trying to get performance data from my Tricore TC275 using the free toolchain tricore Hightec. Basically I have my function that I run several times with a for loop and I want to return the average time of execution of my program.
---------------------------------------
// beginning of the counter, void benchmark_start ()
for (i = 0; i <10000; i ++) {
myfunction ();
}
// end of the counter, IfxCpu_Perf benchmark_end () (IfxCpu_Perf is not recognized)
// final result: (end-start) / 10000
------------------------------------------------------
Maybe it's a lybrary that I have to include?
The problem is that I do not understand how to include your "benchmark" functions in my code, could you help me please?
I'm trying to get performance data from my Tricore TC275 using the free toolchain tricore Hightec. Basically I have my function that I run several times with a for loop and I want to return the average time of execution of my program.
---------------------------------------
// beginning of the counter, void benchmark_start ()
for (i = 0; i <10000; i ++) {
myfunction ();
}
// end of the counter, IfxCpu_Perf benchmark_end () (IfxCpu_Perf is not recognized)
// final result: (end-start) / 10000
------------------------------------------------------
Maybe it's a lybrary that I have to include?
The problem is that I do not understand how to include your "benchmark" functions in my code, could you help me please?
Jul 02, 2019
08:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 02, 2019
08:32 AM
Hi Pirate02. The IfxCpu_Perf functions are part of Infineon's Low Level Device (iLLD) driver library. Add those to your project and then try something like this:
The CPU debug system is activated by default when a debugger is connected. If you need this code to work even when a debugger is not connected, add this to turn on the debug system:
Note: this is for the AURIX family, not the TC17xx.
#include "IfxCpu.h"
void main( void )
{
IfxCpu_Perf perf;
IfxCpu_resetAndStartCounters(IfxCpu_CounterMode_normal);
for (i = 0; i <10000; i ++) {
myfunction ();
}
perf = IfxCpu_stopCounters();
printf( "clocks: %d instructions: %d", perf.clock.counter, perf.instruction.counter );
}
The CPU debug system is activated by default when a debugger is connected. If you need this code to work even when a debugger is not connected, add this to turn on the debug system:
#include "IfxCbs_reg.h"
// Unlock debug system if it's not already unlocked
if( !(__mfcr(CPU_DBGSR) & 0x1) )
{
CBS_OEC.U = 0xA1;
CBS_OEC.U = 0x5E;
CBS_OEC.U = 0xA1;
CBS_OEC.U = 0x5E;
}
_mtcr( CPU_DBGSR, 1 ); // enable the Core Debug Controller
Note: this is for the AURIX family, not the TC17xx.
Jul 09, 2019
02:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 09, 2019
02:01 AM
Hello Thank you for your return,
I'm working on the sample file "TimeDemo_ApplicationKitTC275C-Step" (on HighTec). When I try to add the # include "IfxCpu.h", he can not recognize the lybrary in my project (I do not know if it's different on DAVE). Would you have a way to find this file because I have the impression that it does not exist on the IDE "HighTec Free tool chain".
Thank you in advance.
I'm working on the sample file "TimeDemo_ApplicationKitTC275C-Step" (on HighTec). When I try to add the # include "IfxCpu.h", he can not recognize the lybrary in my project (I do not know if it's different on DAVE). Would you have a way to find this file because I have the impression that it does not exist on the IDE "HighTec Free tool chain".
Thank you in advance.