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.

sysbios timer usage.

Other Parts Discussed in Thread: OMAPL138, SYSBIOS

Hello,

I have a few questions regarding the timer interrupt usage..!

So, I have a critical link board mityDSP,  which has omapl138 and dsp C6748. I am using syslink to flash and run the DSP code on DSP core. So I have a few examples provieded with the syslink, I have modified one of them for my purpose, I did some research on the net for the timer usage in sysbios.

what I want is this:

main function will create a timer with .. one shot mode .. and user start mode .. Timer_RunMode_ONESHOT & Timer_StartMode_USER are set .. then in the timer parameter .. Timer_PeriodType_MICROSECS is also set to provide period in microseconds ..! and then Timer_create is callled in the main function itself .. along with this the main function will create a task .. and also a binary semaphore with initial value as 1 ..!


the task created by the main function will have a while loop ..  and in the loop

--> will call the semaphore_pend  .. as initial value is 1 it wont block on this

--> then will call a function

--> then will call the Timer_start to start the timer

then in the timer isr :

--> Timer_stop will be called to stop the timer (I think not needed as it's a one shot timer)

--> call to Semaphore_post

this is not achieved .. need some help !!

For this what I am doing is this, the code snippet:

=====main_dsp.c==========

Timer_Handle timer;
Timer_Params prms;
Semaphore_Handle mySem;

Void myIsr(Void)

{
        // disable interrupts if an interrupt could lead to
        // another call to Timer_start().
        //int key = Hwi_disable();
        //Timer_stop(timer);
        //Hwi_restore(key);

        Timer_stop(timer);

        count++;
        Semaphore_post(mySem);
}

int count = 0;

/*
*  ======== main ========
*/
Int main(Int argc, Char* argv[])
{
    Error_Block eb;
    Task_Params taskParams;

    Semaphore_Params sem_params;
    sem_params.mode = Semaphore_Mode_BINARY;

    mySem = Semaphore_create(1, &sem_params, NULL);

    Timer_Params_init(&prms);
    //prms.period = 1000*1000*2;
    prms.period = 300;
    prms.periodType = Timer_PeriodType_MICROSECS;
    //prms.runMode = Timer_RunMode_CONTINUOUS; //periodic timer
    prms.runMode = Timer_RunMode_ONESHOT; //one shot timer
    prms.startMode = Timer_StartMode_USER; //user started ..!
timer = Timer_create(Timer_ANY, (Timer_FuncPtr)myIsr, &prms, NULL);

  /* must initialize the error block before using it */
    Error_init(&eb);

    /* create main thread (interrupts not enabled in main on BIOS) */
    Task_Params_init(&taskParams);
    taskParams.instance->name = "smain";
    taskParams.stackSize = 0x1000;
    Task_create(smain, &taskParams, &eb);

    if (Error_check(&eb)) {
        System_abort("main: failed to create application startup thread");
    }

    /* start scheduler, this never returns */
    BIOS_start();

    return (0);
}

/*
*  ======== smain ========
*/
Void smain(UArg arg0, UArg arg1)
{
   Int             status          = 0;
    UInt16          remoteProcId;
    Bool            running         = TRUE;

    int my_exec = 5;//MY_EXEC;

 /* loop forever */
    while (running) {

        /* only one thread must call start */
        do {
            status = Ipc_start();
        } while (status == Ipc_E_NOTREADY);

        if (status < 0) {
            Log_error0("smain: Ipc_start() failed");
            goto leave;
        }

        /* attach to the remote processor */
        remoteProcId = MultiProc_getId("HOST");

        /* connect to remote processor */
        do {
            status = Ipc_attach(remoteProcId);

            if (status == Ipc_E_NOTREADY) {
                Task_sleep(100);
            }

        } while (status == Ipc_E_NOTREADY);

        if (status < 0) {
            Log_error0("smain: Ipc_attach() failed");
            goto leave;
        }

  while(my_exec--) {

        Semaphore_pend(mySem, BIOS_WAIT_FOREVER);


        status = Server_myExec(count);

       
        Timer_setPeriodMicroSecs(timer, 300);
        Timer_start(timer);

}

   do {
            status = Ipc_detach(remoteProcId);

            if (status == Ipc_E_NOTREADY) {
                Task_sleep(100);
            }

        } while (status == Ipc_E_NOTREADY);

        if (status < 0) {
            Log_error0("smain: Failed to disconnect from remote process");
            goto leave;
        }

        /* only one thread must call stop */
        Ipc_stop();
    }

leave:
    return;
}

========================================>>>>



So, this is the code.. here I'm creating a timer .. with 300 microseconds period, period type is set to Timer_PeriodType_MICROSECS and set to one shot mode .. and user start mode is also set .. the isr is not getting called so I think I'm not able to control the start and stop of the timer ..

  but this is getting hung ..


If I remove the Timer_create .. Timer_setPeriodMicroSecs & Timer_start(timer) the code works fine and as expected ..


thanks,

aniket

  • Aniket Jesu said:


            Semaphore_pend(mySem, BIOS_WAIT_FOREVER);


            status = Server_myExec(count);

           
            Timer_setPeriodMicroSecs(timer, 300);
            Timer_start(timer);

    Can you please confirm that you are reaching this code?  Either by setting break points or adding print statements?

    Steve

  • Thank you Steve for your kind reply, But I gave up with one shot timer interrupt and got it working with Clock one shot interrupt .. The continuous timer interrupt was working fine, Now I'm not using timer interrupt.

    I was needed one shot timer/clock interrupt with time-out of 300us .. so I changed the clock ticks from 1000us to 100us in .cfg file and giving time-out of 3 ticks.

    thanks,

    aniket