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.

CCS/PROCESSOR-SDK-AM437X: Building Starterware projects

Part Number: PROCESSOR-SDK-AM437X
Other Parts Discussed in Thread: SYSBIOS

Tool/software: Code Composer Studio

My current environment details:

- HW: AM437x_idk

- OS: Linux, v.4.2.0-35-generic, x86_64 / gtk 2.24.23

- Code Composer Studio (CCS) version: 8.1.0.00011 

- PDK Version: pdk_am437x_1_0_12

I was able to setup the PDK and run the "pdkProjectCreate.sh" for the AM437x_idk board. I could see all the projects (missing the Starterware examples for modules like DMtimer etc) that were built and ready for CCS.

Since I wanted to benchmark the interrupt latency (in my case using a Timer) on the AM437X_IDK, I imported and updated the "UART_BasicExample_idkAM437x_armExampleProject" inside CCS to make use of the Timer functionality. Here's a code snippet for the timer config:

Timer_Params_init(&timerParams);

timerParams.period = 1000; //100usec timer
timerParams.runMode = Timer_RunMode_ONESHOT; //Timer_RunMode_CONTINUOUS; //Timer_RunMode_ONESHOT;
timerParams.periodType = Timer_PeriodType_MICROSECS;
timerParams.startMode = Timer_StartMode_USER;
timerParams.arg = 0;
//timerParams.extFreq.lo = 1000000;
//timerParams.extFreq.hi = 0;

myTimer = Timer_create(Timer_ANY, myIsr, &timerParams, &eb); //Timer_ANY
if (myTimer == NULL) {
System_abort("Timer create failed");
}

In my case, As you can see I am using Timer_ANY, so each timer it defaults to DMTimer0 or sometimes DMtimer2, both of which run at 32768 Hz.

For my Interrupt latency benchmarking I would like to use The other DMTimers which run at 24000000 Hz for better resolution. But each timer I manually try to use any Timer ID other than 0 and 2 my code crashes throwing exceptions. After looking at some forum questions (mentioned below) it became apparent that I need to either add DMTimer3ModuleClkConfig(); function or I need to use the DMTimer library/example from the Starterware and manually configure the clock for other DMTimers.

https://e2e.ti.com/support/legacy_forums/embedded/tirtos/f/355/t/272744?DMTimer-periphery-clock-enabling-DMTimer3ModuleClkConfig-

So my 2 question are:

- How can I make use of the DMTimers 1, 3 through 11 while still using the SYSBIOS/HAL API. If this works the below question is moot.

- How do I create a CCS project for the Starterware/Example/DMTimer ?  I have tried to find documentation for over a week but no luck. So any help is appreciated. 

Thanks,
Virendra

  • Hi Virendra,

    Virendra Kate said:
    - OS: Linux, v.4.2.0-35-generic, x86_64 / gtk 2.24.23

    Note that the supported Linux OS distributions are Ubuntu 14.04 64-bit and Ubuntu 16.04 64-bit

    Virendra Kate said:
    - How can I make use of the DMTimers 1, 3 through 11 while still using the SYSBIOS/HAL API. If this works the below question is moot.

    Please refer to the below e2e threads:

    Virendra Kate said:
    How do I create a CCS project for the Starterware/Example/DMTimer ?  I have tried to find documentation for over a week but no luck. So any help is appreciated. 

    Please note that the support for starterware package that is include in Processor SDK RTOS is limited to bootloaders and board package.

    Regards,
    Pavel

  • Hi Pavel,

    Thank for your pointers. Sorry for the delay in replying.The DMtimer-3 issue is now resolved after I referred to the pdk_am437x/packages/ti/drv/usb/example/common/timer.c file.

    Here's the solution for reference. I added the following to my code:

    #define CM_PER_TIMER3_CLKCTRL (0x44DF8800 + 0x538) // PRCM_CM_PER_TIMER3_CLKCTRL
    #define CM_DPLL_CLKSEL_TIMER3_CLK (0x44DF4200 + 0x8)

    // clock source to CLK_M_OSC: 0x1 - high frequency input clock (24MHz)
    // CLK_32KHz: 0x2
    // TCLKIN : 0x0 - external clock pin - not used.

    *(unsigned int*)CM_DPLL_CLKSEL_TIMER3_CLK = 0x1;

    // enable the TIMER
    *(unsigned int*)CM_PER_TIMER3_CLKCTRL = 0x2;

    I have a follow-up question. I am trying to benchmark the interrupt latency using DMTimer3 on this processor but the latency seems to be too high - around 40usec.

    Here's the relevant snippet:

    Void myIsr(UArg arg0)
    {

    time2 = Timestamp_get32();

    Semaphore_post(semaphore0);

    }

    //inside the TASK :-

    Timestamp_getFreq(&freq);
    BIOS_getCpuFreq(&freq2);
    System_printf("\nTimeStamp Frequency = %lu Hz!\n", freq.lo ); //This comes out to be 1GHZ = 1ns resolution
    System_printf("\nBIOS Frequency = %lu Hz!\n", freq2.lo ); //This comes out to be 1GHZ = 1ns resolution

    Timer_Params_init(&timerParams);

    timerParams.period = 100; //100usec timer
    timerParams.runMode = Timer_RunMode_ONESHOT;
    timerParams.periodType = Timer_PeriodType_MICROSECS;
    timerParams.startMode = Timer_StartMode_USER; //User starts the timer


    myTimer = Timer_create(3, (TimerP_Fxn) myIsr, &timerParams, &eb); //Timer_ANY
    if (myTimer == NULL) {
    System_abort("Timer create failed");
    }

    Timer_setPeriodMicroSecs(myTimer, (uint32_t)100); //Double check the period


    Timer_getFreq(myTimer, &freq);
    System_printf("\nTimer Frequency = %lu Hz!\n", freq.lo ); // Comes out to be 24 MHz

    System_printf("\nTimer Period = %lu ns!\n", ( Timer_getPeriod(myTimer)*40) ); //*40ns @ 24MHz DMtimer freq; --> Comes out to be ~100usec

    for(i = 0; i < 100000; i++){


    time1 = Timestamp_get32();
    Timer_start(myTimer);
    Semaphore_pend(semaphore0, BIOS_WAIT_FOREVER); //Wait for the DMTimer3 ISR to "Post" the semaphore
    time2 = Timestamp_get32();

    delta = time2 - (time1+100000); //add t1+100,000nsec = expected time the DmTimer3 should ideally fire
    if(delta < min_delta){
    min_delta = delta;
    }
    else if(delta > max_delta){
    max_delta = delta;
    }

    }

    System_printf("Timer_start min_delta = %ld \n", min);
    System_printf("Timer_start max_delta = %ld \n", max);

    Could you help me find the cause that is introducing such high latencies?

    Thanks,

    Virendra 

  • Hello Pavel,

    Looks like there is a negative 40 usec latency, meaning the timer fires 40 usec earlier than required instead of the earlier mentioned positive latency.

    Please could you have a look at the above code and let me know why this might be happening? A timer parameter, timerParams.period = 100 & timerParams.periodType = Timer_PeriodType_MICROSECS, should in-fact correspond to 100 usec.  

    Thanks,

    Virendra

  • Virendra,

    Virendra Kate said:

    Looks like there is a negative 40 usec latency, meaning the timer fires 40 usec earlier than required instead of the earlier mentioned positive latency.

    Please could you have a look at the above code and let me know why this might be happening? A timer parameter, timerParams.period = 100 & timerParams.periodType = Timer_PeriodType_MICROSECS, should in-fact correspond to 100 usec.  

    I would suggest you to dump DMTIMER3 registers values and check if these correspond to 100us resolution.

    You can also explore the timer diagnostic test. The Timer is configured for 1msec interrupt.

    pdk_am437x_x/packages/ti/board/diag/timer/

    Regarding timer resolution hints, you can also refer the below e2e threads:

    Regards,
    Pavel