SPRAC21A June 2016 – June 2019 OMAP-L132 , OMAP-L138 , TDA2E , TDA2EG-17 , TDA2HF , TDA2HG , TDA2HV , TDA2LF , TDA2P-ABZ , TDA2P-ACD , TDA2SA , TDA2SG , TDA2SX , TDA3LA , TDA3LX , TDA3MA , TDA3MD , TDA3MV
Following are APIs that are used to configure statistics collector, setup timer, and get statistics on regular interval of 100 µs.
Initialize Statcoll: statCollectorInit();
void statCollectorInit()
{
gStatColState.stat0_filter_cnt = 0;
gStatColState.stat1_filter_cnt = 0;
gStatColState.stat2_filter_cnt = 0;
gStatColState.stat3_filter_cnt = 0;
}
Enable Statcoll and Read Statcoll registers:
/** \brief statCollectorControl
* Description: API to enable statcoll. Same API can be used to read the
* statcoll register values as well.
* Inputs:
* inst_name : Statcoll Instance Name. eg: STATCOL_EMIF_SYS,
* STATCOL_DSP1_MDMA etc. defined in STATCOL_ID enumeration.
* cur_stat_filter_cnt : This value is ignored when calling this function
* to enable the statcoll. When trying to read the statcoll
* this value is used to determine the filter number used.
* mode: Used to indicate whether the function is being called for reading
* or enabling the statcoll as defined by :
* #define ENABLE_MODE 0x0
* #define READ_STATUS_MODE 0x1
* Return : In the enable mode the function returns the filter number
* assigned. In the read mode the function * returns the value
* read (BW/Latency etc) from the statcoll registers.
*/
UInt32 statCollectorControl(UInt32 inst_name, UInt32 cur_stat_filter_cnt, UInt32 mode)
{
switch (inst_name)
{
case STATCOL_EMIF_SYS: cur_base_address = stat_coll0_base_address;
cur_event_mux_req = 0;
cur_event_mux_resp = 1;
if(mode == ENABLE_MODE) {gStatColState.stat0_filter_cnt = gStatColState.stat0_filter_cnt + 1;}
if(mode == ENABLE_MODE) {cur_stat_filter_cnt = gStatColState.stat0_filter_cnt;}
break;
case <NEXT_STATCOLL> :
...
}
if(mode == ENABLE_MODE)
{
if ( cur_stat_filter_cnt > 4 )
{
printf("We have exhausted filters/counters.....\n");
}
// Global Enable Stat Collector
wr_stat_reg(cur_base_address+0x8,0x1);
// Soft Enable Stat Collector
wr_stat_reg(cur_base_address+0xC,0x1);
wr_stat_reg(cur_base_address+0x18,0x5);
// Operation of Stat Collector / RespEvt => Packet
wr_stat_reg(cur_base_address+0x1C,0x5);
// Event Sel
wr_stat_reg(cur_base_address+0x20+4*(cur_stat_filter_cnt-1),cur_event_mux_req);
// Op is EventInfo
wr_stat_reg(cur_base_address+0x1FC+(0x158*(cur_stat_filter_cnt-1)),2);
// Event Info Sel Op -> packet length
wr_stat_reg(cur_base_address+0x1F8+(0x158*(cur_stat_filter_cnt-1)),0);
// Filter Global Enable
wr_stat_reg(cur_base_address+0xAC+(0x158*(cur_stat_filter_cnt-1)),0x1);
// Filter Enable
wr_stat_reg(cur_base_address+0xBC+(0x158*(cur_stat_filter_cnt-1)),0x1);
// Manual dump
wr_stat_reg(cur_base_address+0x54,0x1);
// use send register to reset counters
}
else
{
wr_stat_reg(cur_base_address+0xC,0x0);
cur_stat_filter_cnt = rd_stat_reg(cur_base_address+0x8C+((cur_stat_filter_cnt-1)*4));
wr_stat_reg(cur_base_address+0xC,0x1);
}
return cur_stat_filter_cnt;
}
Usage (Dummy code):
void main()
{
statCollectorInit();
counterIdISSNTR1 = statCollectorControl(STATCOL_ISS_NRT1, 0, ENABLE_MODE);
DMTIMER_prcmenable(TIMER_NUM);
DMTIMER_Start(TIMER_NUM);
// Dummy Read
statCollectorControl(STATCOL_ISS_NRT1, counterIdISSNTR2, READ_STATUS_MODE);
while(statCountIdx < TOTAL_COUNT)
{
while (DMTIMER_Read(TIMER_NUM) <= SYS_CLK_FREQ/10000) // for 100 us {;}
statCountISSNRT1[statCountIdx++] = statCollectorControl(STATCOL_ISS_NRT1, counterIdISSNTR1, READ_STATUS_MODE);
DMTIMER_Stop(TIMER_NUM);
DMTIMER_Start(TIMER_NUM);
}
}
Timer APIs:
ReturnCode_t DMTIMER_Start (UWORD8 timer_num)
{
ReturnCode_t checkReturn = RET_OK;
/* Counter clear and auto reload enable */
if (timer_num < 1 || timer_num > 16)
return RET_FAIL;
switch(timer_num) {
case 1:
/* Clear the counter value */
WR_REG_32(TIMER1, DMTIMER__TCRR, 0x0);
/* Triggering the timer load */
WR_REG_32(TIMER1, DMTIMER__TTGR, 0x1);
/* Start timer and reload enable: bit[0] start,
bit[1] autoreload enable */
WR_REG_32(TIMER1, DMTIMER__TCLR, 0x1);
break;
case 2:
...
default:
checkReturn = RET_FAIL;
break;
}
return checkReturn;
}
ReturnCode_t DMTIMER_Stop(UWORD8 timer_num)
{
ReturnCode_t checkReturn = RET_OK;
/* Counter clear and auto reload enable */
if (timer_num < 1 || timer_num > 16)
return RET_FAIL;
switch(timer_num) {
case 1:
/* Bit[0]: 0, counter is frozen */
WR_REG_32(TIMER1, DMTIMER__TCLR, 0x0);
break;
case 2:
...
default:
checkReturn = RET_FAIL;
break;
}
return checkReturn;
}
UWORD32 DMTIMER_Read(UWORD8 timer_num)
{
volatile UWORD32 read_value = 0;
if (timer_num < 1 || timer_num > 16)
return RET_FAIL;
switch(timer_num) {
case 1:
read_value = RD_REG_32(TIMER1, DMTIMER__TCRR);
break;
case 2:
...
default:
read_value = 0;
break;
}
return read_value;
}
ReturnCode_t DMTIMER_prcmenable(UWORD8 timer_num)
{
ReturnCode_t checkReturn = RET_OK;
if (timer_num < 1 || timer_num > 16)
return RET_FAIL;
switch(timer_num) {
case 1:
checkReturn = (ReturnCode_t )prcm_enable_module(prcm_timer1);
break;
case 2:
...
default:
checkReturn = RET_FAIL;
break;
}
return checkReturn;
}