This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to get Cycle Count in FVP Corstone SSE-300 Ethos-U55?

HI, It seems that FVP Corstone SSE-300 Ethos-U55 does no longer has the parameter "Cpu0.has_pmu" which is used to get cycle count (I Used --list-params to see all available parameter and this parameter is not there). Is there any other parameter that can be used to get cycle count? or is there another way to get cycle count? Need Help.

  • Hi Archith,

    I have been using DWT->CYCCNT to get the counter value. It is not perfect, but that is we have.

    #include "core_cm55.h"

    uint32_t start_cycles, end_cycles, elapsed_cycles;

    start_cycles = DWT->CYCCNT; // Read cycle counter before function call
    // Call your function here
    end_cycles = DWT->CYCCNT; // Read cycle counter after function call
    elapsed_cycles = end_cycles - start_cycles;

  • I tried the above method,  Now I am getting error 

    CMSIS_5-develop/CMSIS/Core/Include/core_cm55.h:128:8: error: #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
    128 | #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"

    CMSIS_5-develop/CMSIS/Core/Include/core_cm55.h:139:8: error: #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)"
    139 | #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)"

    CMSIS_5-develop/CMSIS/Core/Include/core_cm55.h:3940:46: error: unknown type name 'IRQn_Type'; did you mean 'ITM_Type'?
    3940 | __STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn)

    CMSIS_5-develop/CMSIS/Core/Include/core_cm55.h:4171:64: error: '__NVIC_PRIO_BITS' undeclared (first use in this function)
    4171 | PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp);

    How to define IRQn_Type and __NVIC_PRIO_BITS ?Need help.

  • Archith, try to remove #include "core_cm55.h" and if there DWT will be not found, find out another header containing that.

  • Likely something of that helps

    #include "os_tick.h" // CMSIS OS Tick API
    #include "cmsis_os2.h" // CMSIS RTOS API
    #include "rtx_os.h" // RTX OS definitions
    #include "rtx_evr.h" // RTX Event Recorder definitions

    #include "RTE_Components.h"
    #include CMSIS_device_header

  • I remove #include "core_cm55.h", did not get any error like DWT will be not found. But DWT->CYCCNT returns only zero. Even after including another headers. is there any other solution?

  • // Enable DWT cycle counter
    CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
    DWT->CYCCNT = 0;
    DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
    cyccnt = DWT->CYCCNT;

  • I added this to my code but still its value is Zero.

        uint32_t start_cycles, end_cycles;
        // Enable DWT cycle counter
        CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
        DWT->CYCCNT = 0;
        DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
       
        start_cycles = DWT->CYCCNT;
        printf("start_cycles = %lu\n", start_cycles);
       
        int num_iterations = 50000000;
        int value=0;
        for (int i = 0; i < num_iterations; i++) {          
                value = i*i;
            }
            end_cycles = DWT->CYCCNT;
            printf("end_cycles = %lu\n", end_cycles);

    Is there anything else to consider?