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.

Problem using iTimer on Delfino C2000 with TI-RTOS

Other Parts Discussed in Thread: TMS320F28377D, CCSTUDIO

Hello all,

I have a problem by implementing a iTimer on my Delfino C2000 (TMS320F28377D) using TI-RTOS.

I have this task :

static struct PERT_t m_PERT_Cfg;

struct PERT_t {

T_ITIMER_ID timerSamplingId;
T_SEM_HANDLE samplingSem; }


void Pert_TaskBody(UArg lowAddr, UArg highAddr)

{
    T_OS_ERR osErr;
    struct PERT_t* pPert;

    pPert = &m_PERT_Cfg;


    OS_SEM_CREATE(pPert->samplingSem, 0LU, osErr);

    pPert->timerSamplingId = ITIMER_Register((T_ITIMER_CALLBACK)CbTimer, (UArg)pPert);

    ITIMER_Start(pPert->timerSamplingId, pPert->perSamplingMsOrNbTicksAppli);

    while (1)

    {
        OS_SEM_PEND(pPert->samplingSem, osErr);

        Sampling();;
    }
}

and this timer callback :

static void CbTimer(struct PERT_t* pPert)
{
    T_OS_ERR err;

    OS_SEM_POST(pPert->samplingSem, err);
}

The ITIMER_Register() finction is written like this :

T_ITIMER_ID ITIMER_Register (T_ITIMER_CALLBACK pFctNotify, UArg arg)
{
    T_OS_ERR err;
    T_ITIMER_ID id;
    T_TIMER_ELEM *pTimer;
	
    Clock_Params params;

    if (!bInit)
    {
        ITIMER_Init();
    }

    if (iTimer.registerTimersNb >= ITIMER_MAX_NB)
    {
        // No more timer available
        SRV_DBG(0);
        return -1;
    }

    // Init of critical section
    OS_CRITSECT_ENTER(hCritSect, err);
    id = iTimer.registerTimersNb;
    iTimer.registerTimersNb++;
    // Out a critical section
    OS_CRITSECT_LEAVE(hCritSect, err);

    // init of timer
    pTimer = &(iTimer.arrTimer[id]);
    Clock_Params_init(&pTimer->clockParams);
    pTimer->clockParams.arg = arg;
    pTimer->clockParams.startFlag = FALSE;
    Clock_construct(&(pTimer->clockStruct), pFctNotify, 1, &pTimer->clockParams);
    pTimer->clockHandle = Clock_handle(&(pTimer->clockStruct));

    return id;
}

My problem is that when the callback is called, at the end of the timer counting, the pointer pPert is not equal to &m_PERT_Cfg. I wonder what have done wrong in the creation of the iTimer and why I have not the right parameter pPert (the good pointing value). 

If you had any idea, I would be very interesting !

Thanks in advance.