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.

RTI for software configurable timers

Other Parts Discussed in Thread: RM48L952, HALCOGEN

Hello,


I am looking to implement 4 timers in my software. I am looking to use the RTI module for this. Our processor is the RM48L952 PGE package.


The first 2 timers I would operate off a 1sec timebase

The other 2 I would operate off a 100ms timebase

Is it possible to counter0 and counter1 of the RTI module to deliver these timebases such that when I set the compareX period it becomes a multiple of 1sec or 100ms?

My hope is that from some timer driver functions I can simply call rtiSetPeriod() for one of the available counters with my desired period and then wait on the interrupt clearing a flag to indicate timer expiry.

Any advice here is appreciated. My alternative will be to simply generate ticks and manage timers and their expiry in the application driver software.


Thanks


Jamie

  • Jamie,

    How will you use those four timers? I am attaching a code snip for setting up RTI. You can also TI HALCoGen tool.

    5554.rti_cfg.c

    Thanks and regards,

    Zhaohong

  • The timers will be used similar to a wait() command...but I don't want to have a wait(), while() or any similar construct that hangs up the code.


    I've got something working where I have a timeout and expiry flag set up in my own rti routine. The timeout is the decremented in the rtiCompareXInterrupt and the expiry flag set when it reaches zero. My application can then simply poll the expiry flag to learn when the timeout has elapsed.

    Here is the code:

    Main Loop

    		if(UNI_rtiCompare0_expire)
    		{
    			start_timer();
    		}

    Local Function

    void start_timer(void)
    {
    	/* rtiDisableTimer()*/
    	rtiDisableNotification(rtiNOTIFICATION_COMPARE3);
    	UNI_rtiSetTimeout(timeout);
    	rtiEnableNotification(rtiNOTIFICATION_COMPARE3);
    }

    RTI Routine

    void UNI_rtiSetTimeout(uint32 timeout)
    {
    	UNI_rtiCompare0_TOUT = timeout;
    	UNI_rtiCompare0_expire = FALSE;
    /* USER CODE END */
    }
    void rtiCompare3Interrupt(void)
    {
    /* USER CODE BEGIN (83) */
    	/* 1 SEC */
    	UNI_rtiCompare0_TOUT--;
    	if(UNI_rtiCompare0_TOUT > 0)
    	{
    		rtiREG1->INTFLAG = 8U;
    	    rtiNotification(rtiNOTIFICATION_COMPARE3);
    	}
    	else
    	{
    		UNI_rtiCompare0_expire = TRUE;
    		gioSetBit(hetPORT1,28,gioGetBit(hetPORT1,28)^1);
    	}
    

    This is working, the expiry flag correctly toggles for the required 'timeout'. Using this method I can run up to 4 timers of a specified resolution.

    It would be nicer if I didn't need to decrement UNI_rtiCompare0_TOUT though and just configure the compare period appropriately, checking the interrupt status to know if the timer had expired. Is this possible?

    Also, is it possible to know if the RTI has hung up? Is there a built-in error detection on RTI interrupt lock-up on the RM48?


    Jamie

    void rtiCompare3Interrupt(void)
    {
    /* USER CODE BEGIN (83) */
        /* 1 SEC */
        UNI_rtiCompare0_TOUT--;
        if(UNI_rtiCompare0_TOUT > 0)
        {
            rtiREG1->INTFLAG = 8U;
            rtiNotification(rtiNOTIFICATION_COMPARE3);
        }
        else
        {
            UNI_rtiCompare0_expire = TRUE;
            gioSetBit(hetPORT1,28,gioGetBit(hetPORT1,28)^1);
        }

  • Jamie,

    In the code snip I sent earlier, the compare value is automatically updated after compare event. See if it is what you need. There is feature for RTI to tell if it is stuck by RTI itself.

    Thanks and regards,

    Zhaohong