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.

Sys/Bios - create two timers

Guru 10750 points
Other Parts Discussed in Thread: SYSBIOS

Hi,

I want to create two timers for the C6678 platform, on creating the second timer I'm getting an error where the Hwi is already defined (below), how can I change the timer interrupt (I tried to change the Timer_Params Hwi_Params with no success)?

"ti.sysbios.family.c64p.Hwi: line 159: E_alreadyDefined: Hwi already defined: intr# 15 xdc.runtime.Error.raise: terminating execution"

What I'm doing is -

Timer_Params_init(&timerParams);    

timerParams.period = 1000;    

timerParams.arg = 8;    

timerParams.startMode = Timer_StartMode_AUTO;    

timer8Handle = Timer_create(8, (Timer_FuncPtr)timer8Fxn, &timerParams, NULL);    

if (timer8Handle == NULL) {        

System_abort("Timer create failed");    

}

Timer_Params_init(&timerParams);    

timerParams.period = 500;    

timerParams.arg = 10;    

timerParams.startMode = Timer_StartMode_AUTO;    

timer10Handle = Timer_create(10, (Timer_FuncPtr)timer10Fxn, &timerParams, NULL);    

if (timer10Handle == NULL) {        

System_abort("Timer create failed");    

}

Thanks,

HR

  • HR,

    Configuring the interrupt number in the Hwi_Params of the timerParams should have done the trick.

    Can you share the code you used for setting the Hwi_Params?

    Alan

  • Hi Alan,

    This is the Hwi_Params,

        Timer_Params timerParams;
        Hwi_Params timerHWIParams;

        Hwi_Params_init(&timerHWIParams);
        timerHWIParams.eventId = 8;
        Timer_Params_init(&timerParams);
        timerParams.period = 500;
        timerParams.arg = 10;
        timerParams.startMode = Timer_StartMode_AUTO;
        timerParams.hwiParams = &timerHWIParams;
        timer10Handle = Timer_create(10, (Timer_FuncPtr)timer8Fxn, &timerParams, NULL);
        if (timer10Handle == NULL) {
            System_abort("Timer create failed");
        }

    Thanks,

    HR

  • HR,

    The "Hwi already in use" error is due to an intNum (ie vector number) collision rather than an eventId collision.

    By default, the Timer module specifies interrupt number 15 for both timer 8 and timer 10.

    You'll need to specify a timerHWIParams.intNum not used by any other interrupt in your system to work around this problem.

        timerHWIParams.intNum = 13;   /* try using intNum 13 */

    Alan

  • Hi Alan,

    I can't find intNum in the Hwi_Params (or I'm not using the correct one), the bios_6_34_02_18\packages\ti\sysbios\hal\Hwi.h file includes

    /* Params */
    struct ti_sysbios_hal_Hwi_Params {
        size_t __size;
        const void* __self;
        void* __fxns;
        xdc_runtime_IInstance_Params* instance;
        ti_sysbios_interfaces_IHwi_MaskingOption maskSetting;
        xdc_UArg arg;
        xdc_Bool enableInt;
        xdc_Int eventId;
        xdc_Int priority;
        xdc_runtime_IInstance_Params __iprms;
    };

    Thanks,

    HR

  • HR,

    Oops. My bad!

    The intNum is part of the Timer_Params:

     timerParams.intNum = 13;

    Alan

  • Hi Alan,

    Great !! this solved the issue,

    Thanks,

    HR

  • HR,

    Good to hear that. Can you please mark this thread as answered?

    Thanks,

    Alan

  • Alan,

    Sure ! Thanks !

    HR