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.

AM3359 Timer Resolution Problem

Other Parts Discussed in Thread: AM3359, SYSBIOS

Hi members, 

We are using AM3359 ICE Board for our EtherCat based application. Here in our application, we require a timer of 1 us resolution.

We tried all the ways to implement the timer (Timer Module in sys-bios, HWI for timer etc.)

But we are not getting proper resolution. We are using timer6 on ICE board which is clocked by 24 MHz onboard crystal clock.

We are getting interrupt at every 2us instead of 1us even though we have set the timer reload count as

0xFFFFFFE7 (0xFFFFFFFF - 1us*24000000).

Can you help us to resolve this problem on priority. Here is the code snippets used for timer6 in sys-bios environment.

Void hwiTimer6Fxn(UArg arg)

{

GPIOPinWrite(SOC_GPIO_1_REGS, 9, GPIO_PIN_HIGH);

timestamp_count++;

GPIOPinWrite(SOC_GPIO_1_REGS, 9, GPIO_PIN_LOW);

}


void configureTimeStampTimer6(void)

{

Timer_Params timer6Params;

Error_Block eb;

DMTimer6ModuleClkConfig();

// Enable clock for DMtimer#6

Error_init(&eb);

Timer_Params_init(&timer6Params);

timer6Params.period = 1;

timer6Params.periodType = ti_sysbios_interfaces_ITimer_PeriodType_MICROSECS;

timer6Params.extFreq.lo = 24000000;

timer6Params.extFreq.hi = 0;

timer6Params.startMode = ti_sysbios_interfaces_ITimer_StartMode_USER;

timer6 = Timer_create(4, hwiTimer6Fxn, &timer6Params, &eb);

if (timer6 == NULL) {

System_abort("Timer 6 create failed");

}

}

void startTimeStampTimer6(void)

{

if(!timerStarted)

{

Timer_start(timer6);

timestamp_count = 0;

timerStarted = true;

}

}

  • Moving this to the RTOS forum.

  • Hi Sachin,

    In a bare-metal solution (no OS) you should not have any problem obtaining your interrupts.  However, when using an OS, there are scheduling and thread-safety mechanisms that need to execute along side your algorithm.  In SYS/BIOS hardware interrupts (Hwi) go to the Hwi dispatcher which then executes the Hwi function.  

    Assuming that your CPU frequency is set to 550 MHz, means you have 550 CPU cycles per 1 microsecond.  Published SYS/BIOS benchmarks state the Hwi dispatcher prolog is 553 cycles, meaning that your Hwi function will start to execute 553 cycles after it has been triggered (a full 1 us after).  Add in the cycles required to run the Hwi function and you can see that a 1 us period is not possible.  

    If you are still interested in getting as close to 1 us as possible, you can try to improve performance by fixing the Hwi function and any functions called within it in the cache.  Please see the Cache_lock API in SYS/BIOS cdoc (ti.sysbios.family.arm.a8.Cache).  Also keep in mind that having a Hwi trigger to frequently may prevent other tasks, Swis or Hwis from executing.

    Regards,

    -- Emmanuel