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.

TMS570LC4357: RTI Minimum Interrupt Interval

Part Number: TMS570LC4357

Tool/software:

Hello gundavarapu 

I tested with your code and found that the RTI delay is not as accurate as it should be.

1. delayus(1);

2. The actual value tested by the oscilloscope

3. What is the minimum interval between interrupts that RTI can generate, and can it reach 100ns to generate an interrupt?

4. I've actually tried to test this with the compare notification function and got up to 450ns will generate an interrupt.

5. Another question, why is there no way for me to trigger the overflow interrupt for rti compare 0?

6. I will attach my project below.

TMS_57_Rti_Delay.rar

  • Hi Sam,

    My shared code might not work for small delays like 1us,

    Because as you can see these function involves lot of other function callings, and also here i used interrupt-based delay. These are all affect the configured delay, so if it is a small delay then definitely accuracy will get affect.

    As mentioned in TRM the interrupt flags will also get set without depending on the interrupt enable status bits, so my suggestion would be directly monitoring the flag without enabling interrupts and instead of just poll the flags directly that will reduce the delay some extent.

    And also, i am suggesting you keep your GPIO toggling's above and below of the below highlighted line and see the how much delay you are getting.

    And also remember to change above "RTI_TIMEOUT" flag which is using interrupt method to directly poll the interrupt flag.

    --

    Thanks & regards,
    Jagadish.

  • Is that what I'm doing, please?

    /* USER CODE BEGIN (0) */
    #include "HL_rti.h"
    #include "HL_gio.h"
    /* USER CODE END */
    
    /* Include Files */
    
    #include "HL_sys_common.h"
    
    /* USER CODE BEGIN (1) */
    void delayus(uint16 us);
    int io_state = 0;
    /* USER CODE END */
    
    /** @fn void main(void)
    *   @brief Application main function
    *   @note This function is empty by default.
    *
    *   This function is called after startup.
    *   The user can use this function to implement the application.
    */
    
    /* USER CODE BEGIN (2) */
    volatile uint8_t RTI_TIMEOUT = 0;
    /* USER CODE END */
    
    int main(void)
    {
    /* USER CODE BEGIN (3) */
        gioInit();
        rtiInit();
        gioSetDirection(gioPORTB, 0xFFFFFFFF);
        _enable_IRQ();
    
        while(1)
        {
            delayus(5);
            io_state == 0 ? (gioPORTB->DSET = (uint32)1U << 1) : (gioPORTB->DCLR = (uint32)1U << 1);
            io_state = !io_state;
    //        gioToggleBit(gioPORTB, 1);
    //        gioPORTB->DCLR = (uint32)1U << 1;
    //        delayus(1);
    //        gioPORTB->DSET = (uint32)1U << 1;
    //        delayus(1);
    //        gioToggleBit(gioPORTB, 7);
        }
    /* USER CODE END */
    
        return 0;
    }
    
    
    /* USER CODE BEGIN (4) */
    void delayus(uint16 us)
    {
    if (us == 0)
    return;
    
    
    else
    {
    //CHANGE THE INTERRUPT COMPARE VALUES (PERIOD OF INTERRUPT)
    //Setup compare 1 value.
    rtiREG1->CMP[1U].COMPx = 10*us; //10 ticks of clock per microsecond, so multiply by 10
    //Setup update compare 1 value.
    rtiREG1->CMP[1U].UDCPx = 10*us;
    
    //ENABLE THE NOTIFICATION FOR THE PERIOD WE SET
    //rtiEnableNotification(rtiREG1, rtiNOTIFICATION_COMPARE1);
    
    //START THE COUNTER
    rtiStartCounter(rtiREG1, rtiCOUNTER_BLOCK0);
    
    //WAIT IN LOOP UNTIL THE INTERRUPT HAPPENS (HAPPENS AFTER THE PERIOD WE SET)
    //WHEN INTERRUPT HAPPENS, RTI_NOTIFICATION GETS SET TO 1 IN THAT INTERRUPT
    //GO TO notification.c -> rtiNotification() to see where RTI_TIMEOUT is set to 1
    //while(RTI_TIMEOUT==0);
    while(!((rtiREG1->INTFLAG >> 1) & 0x1));
    //io_state == 0 ? (gioPORTB->DSET = (uint32)1U << 1) : (gioPORTB->DCLR = (uint32)1U << 1);
    //io_state = !io_state;
    //RESET THE VARIABLE TO 0, FOR THE NEXT TIME WE DO A DELAY
    //RTI_TIMEOUT = 0;
    
    //DISABLE THE INTERRUPT NOTIFICATION
    //rtiDisableNotification(rtiREG1, rtiNOTIFICATION_COMPARE1);
    
    //STOP THE COUNTER
    rtiStopCounter(rtiREG1, rtiCOUNTER_BLOCK0);
    
    //RESET COUNTER FOR THE NEXT TIME WE DO A DELAY
    rtiResetCounter(rtiREG1, rtiCOUNTER_BLOCK0);
    }
    
    }
    
    //void rtiNotification(rtiBASE_t *rtiREG, uint32 notification)
    //{
    //    if(notification == rtiNOTIFICATION_COMPARE1)
    //    {
    //        RTI_TIMEOUT = 1;
    //    }
    //}
    
    /* USER CODE END */

    Part of the rtiInit function is as follows:

    The waveform of the call to delayus(5) is shown below:

    The procedure is shown below.

    My_Delay_using_RTI_LC4357.rar

    Can you help me see where I'm going wrong?

  • Hi Gundavarapu

    As shown below, I set the clock frequency to 50MHz.

    CPUCx set to 1

    Use the overflow interrupt flag bit of counter 0 in main.

    The measured waveform is 2.6MHz.

    This should be considered a minimum interval interrupt, right?

  • Hi Sam,

    Apologies for the delayed response,

    This should be considered a minimum interval interrupt, right?

    Yes, this should be considered as minimum interval.

    Please consider from Pulse width only not entire period because you are toggling the bit after every timeout.

    So, in your case the minimum width is 378/2 = 189ns.

    --
    Thanks & regards,
    Jagadish.