This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RM48L952: execution time calculation

Part Number: RM48L952
Other Parts Discussed in Thread: HALCOGEN

How to calculate time taken to execute the below function  - RM48 kit. I know the clock frequency is 220Mhz and the period is around 4ns. execution time = period * number of cycle

how the number of cycles can be calculated

void expitr()
{
float k;

if(vte > 40)
{
vte = 20;
}

o = vte; //instentaneous flow rate value during inspiration

sciSend(scilinREG,1,(unsigned char*)"-");
y[0]=((int)o/100)%10 + 0x30;
y[1]=((int)o/10)%10 + 0x30;
y[2]=((int)o)%10 + 0x30;
y[3]=',';
sciSend(scilinREG,4,(unsigned char*)&y);
//sciSend(scilinREG,2,(unsigned char*)"\n\r");


//k = vte*1000*(((float)40-l12)/(float)60);
//k = k/8;
k =vte*10*(((float)40-l12)/(float)60);
k = k*2;

o = k; //Last
y[0]=((int)o/100)%10 + 0x30;
y[1]=((int)o/10)%10 + 0x30;
y[2]=((int)o)%10 + 0x30;
y[3]=',';
sciSend(scilinREG,4,(unsigned char*)&y);

if (f2 < 4)
{
o = LP_AW;
}
else
{
o = qqtot;
}

//o = LP_AW; //instentaneous presure value in airway during inspiration
y[0]=((int)o/100)%10 + 0x30;
y[1]=((int)o/10)%10 + 0x30;
y[2]=((int)o)%10 + 0x30;
y[3]=',';
sciSend(scilinREG,4,(unsigned char*)&y);
//sciSend(scilinREG,2,(unsigned char*)"\n\r");
}

  • Hi Manjunathan,

    There is a module called PMU in Hercules Micro controller, which can be used for calculating the CPU cycles. HALCoGen generates sys_pmu.asm file, which can be used by including sys_pmu.h file in your main file...

    I wrote a simple Psuedo code to illustrate the useage..

    #include "sys_pmu.h"
    ....
    ....
    ....

    // This is One Time Initilization and reset of PMU
    _pmuDisableCountersGlobal_();
    _pmuResetCounters_();
    _pmuResetCycleCounter_();
    _pmuSetCountEvent_(pmuCOUNTER0,PMU_CYCLE_COUNT);
    while(_pmuGetCycleCount_()!=0);
    _pmuEnableCountersGlobal_();

    ....
    ....
    ....

    _pmuResetCounters_();
    _pmuStartCounters_(pmuCYCLE_COUNTER);

    Can_Init( Can_ConfigPtr ); --> Function or portion of code to measure Cycle count...

    _pmuStopCounters_(pmuCYCLE_COUNTER);
    Can_ExecutionTicks = _pmuGetCycleCount_();
    Can_ExecutimeTime = (Can_ExecutionTicks/GCLK_FREQ); Get Time in micro sec of Can_Init function...

    ....
    ....
    ....

    _pmuResetCounters_();
    _pmuStartCounters_(pmuCYCLE_COUNTER);

    Spi_Init( Spi_ConfigPtr ); --> Function or portion of code to measure Cycle count...

    _pmuStopCounters_(pmuCYCLE_COUNTER);
    Spi_ExecutionTicks = _pmuGetCycleCount_();
    Spi_ExecutimeTime = (Spi_ExecutionTicks/GCLK_FREQ); Get Time in micro sec of Spi_Init function...
    ....
    ....
    ....

    Note :

    1) GCLK_FREQ = CPU Clock Frequencey = 220 in your case
    2) The value should be good enough, but if more accurate values can be measured we must subtract the time the _pmuStopCounters_ takes from the total execution time

  • Thank you very much. will come back if i have any struggle