infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 5 of 5

Thread: Tricore 1767 Execution Time Measurement

  1. #1
    rckr is on a distinguished road
    Join Date
    Dec 2014
    Posts
    4
    Points
    48.75

    Tricore 1767 Execution Time Measurement

    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/ap32168...cf343b05&ack=t

    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

  2. #2
    New Member New Member matthiasluh is on a distinguished road
    Join Date
    Jan 2016
    Posts
    2
    Points
    25

    using the Software Framework

    Hey,
    I know this is old but I think many people will have similar problems. I finally solved it like this:

    Code:
    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):
    Code:
    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

  3. #3
    Intermediate Intermediate Pirate02 is on a distinguished road
    Join Date
    Jun 2019
    Posts
    11
    Points
    250

    Execution time measurement TC275 Application kit

    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?

  4. #4
    Intermediate Intermediate UC_wrangler is on a distinguished road
    Join Date
    Jun 2019
    Posts
    20
    Points
    425
    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:

    Code:
    #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:

    Code:
       #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.
    Last edited by UC_wrangler; Jul 8th, 2019 at 06:30 PM.

  5. #5
    Intermediate Intermediate Pirate02 is on a distinguished road
    Join Date
    Jun 2019
    Posts
    11
    Points
    250

    Execution time measurement TC275 Application kit

    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.Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	3.2 KB
ID:	4023Click image for larger version

Name:	Capture1.PNG
Views:	1
Size:	2.7 KB
ID:	4024

+ Reply to Thread
Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.