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.

TMS570LS1224: timer interrupt

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

Hi all,

I have to generate timer interrupt at every 1 sec using TMS570LS1224 

Actually I tried but I did not understand that where I have to write ISR.

Below is my code


int main(void)
{
/* USER CODE BEGIN (3) */

//INITIALIZE TMS570LS1224
systemInit();
gioInit();
sciInit();
rtiInit();
sciSetBaudrate(sciREG, 1000000);
vimInit();
// _enable_IRQ();
gioSetDirection(hetPORT1, 0x00000000);

rtiSetPeriod(rtiCOUNTER_BLOCK0, 100000);
rtiEnableNotification(rtiNOTIFICATION_COMPARE0);
rtiStopCounter(rtiCOUNTER_BLOCK0);
rtiResetCounter(rtiCOUNTER_BLOCK0);
rtiStartCounter(rtiCOUNTER_BLOCK0);
/* Enable IRQ - Clear I flag in CPS register */
/* Note: This is usually done by the OS or in an svc dispatcher */
_enable_interrupt_();

while(1);

/* USER CODE END */

return 0;
}


/* USER CODE BEGIN (4) */
void rtiNotification( rtiNOTIFICATION_COMPARE0)

{

}

(1) Will ISR be written in void rtiNotification( rtiNOTIFICATION_COMPARE0) I

if yes than how did we can clear interrupt flag in ISR so that new interrupt can be generate

when I try to write ISR in void rtiNotification( rtiNOTIFICATION_COMPARE0) function I am getting error 

"../source/sys_main.c", line 192: error #80: expected a type specifier
"../source/sys_main.c", line 192: error #142-D: unnamed prototyped parameters not allowed when body is present
2 errors detected in the compilation of "../source/sys_main.c".

 

Thanks

  • Hi Sudhir,

    You can refer rtiBlinky example present in the HALCoGen Help topics section.

    In this example we are toggling the LED for every 1Sec only. So just follow the code and configurations as per this example.

    And also want to mention that, you don't need to clear the RTI interrupt.

    Actually in RTI driver file, the notification function will get called only after clearing the present RTI interrupt. So, the notification function will get called for every 1Sec repeatedly.

    Also refer below FAQ for to find all the available examples for Hercules devices:

    (+) [FAQ] TMS570LC4357: Examples and Demos available for Hercules Controllers (E.g. TMS570x, RM57x and RM46x etc) - Arm-based microcontrollers forum - Arm-based microcontrollers - TI E2E support forums

    --
    Thanks & regards,
    Jagadish.

    --
    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    Thanks for reply 

    Tell me one thing how do i change period of generating interrupt suppose i want interrupt on every 500 mS than where did i change this value.

    Thanks

  • Hi Sudhir,

    If you are using HALCoGen then you should need to change at below box:

    --
    Thanks & regards,
    Jagadish.

  • Hello Jagadish,

    Thanks for reply 

    I am not using HALCoGen do you have idea how to change through code (timer period).

    I try to change from here but it's not work


    /** - Setup compare 0 value. This value is compared with selected free running counter. */
    rtiREG1->CMP[0U].COMPx = 10U;

    /** - Setup update compare 0 value. This value is added to the compare 0 value on each compare match. */
    rtiREG1->CMP[0U].UDCPx = 10U;

    Thanks

  • Hi Sudhir,

    You are changing the correct registers only.

    Here is the driver file difference for 500ms and 1000ms:

    And this value can be derived using below formula

    For example, in my case CPUC value is 7.

    And i need 1Sec time, that means tCOMP =1

    tRTICLK is 1/75Mhz

    Now substitute above values in the formula

    1sec =  (1/75Mhz) * (7 + 1) * RTIUDC

    RTIUDC = 1*75M / 8

    RTIUDC = 937500

    similarly for 0.5Sec or 500mS it would become 4687500.

    So, use same value to the COMPx and UDCPx registers.

    So similarly calculate the values for your required time.

    --
    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    Thanks for reply 

    I copy whatever you suggest but its not work in my projects.

    I can't figure out what I'm doing wrong.

    Below is my configuration.

    int main(void)
    {
    /* USER CODE BEGIN (3) */

    //INITIALIZE TMS570LS1224
    systemInit();
    gioInit();
    sciInit();
    rtiInit()

    rtiEnableNotification(rtiNOTIFICATION_COMPARE0);

    /* Enable IRQ - Clear I flag in CPS register */
    /* Note: This is usually done by the OS or in an svc dispatcher */
    _enable_IRQ();

    /* Start RTI Counter Block 0 */
    rtiStartCounter(rtiCOUNTER_BLOCK0);

    }

    void rtiNotification( uint32 notification)
    {
    printConsole("2nd device OTUT fault--\n");
    }

    Below is configuration is rti.c

    void rtiInit(void)
    {
    /* USER CODE BEGIN (3) */
    /* USER CODE END */
    /** @b Initialize @b RTI1: */

    /** - Setup NTU source, debug options and disable both counter blocks */
    rtiREG1->GCTRL = (uint32)((uint32)0x0U << 16U) | 0x00000000U;

    /** - Setup timebase for free running counter 0 */
    rtiREG1->TBCTRL = 0x00000000U;

    /** - Enable/Disable capture event sources for both counter blocks */
    rtiREG1->CAPCTRL = 0U | 0U;

    /** - Setup input source compare 0-3 */
    rtiREG1->COMPCTRL = 0x00001000U | 0x00000100U | 0x00000000U | 0x00000000U;

    /** - Reset up counter 0 */
    rtiREG1->CNT[0U].UCx = 0x00000000U;

    /** - Reset free running counter 0 */
    rtiREG1->CNT[0U].FRCx = 0x00000000U;

    /** - Setup up counter 0 compare value
    * - 0x00000000: Divide by 2^32
    * - 0x00000001-0xFFFFFFFF: Divide by (CPUC0 + 1)
    */
    rtiREG1->CNT[0U].CPUCx = 7U;

    /** - Reset up counter 1 */
    rtiREG1->CNT[1U].UCx = 0x00000000U;

    /** - Reset free running counter 1 */
    rtiREG1->CNT[1U].FRCx = 0x00000000U;

    /** - Setup up counter 1 compare value
    * - 0x00000000: Divide by 2^32
    * - 0x00000001-0xFFFFFFFF: Divide by (CPUC1 + 1)
    */
    rtiREG1->CNT[1U].CPUCx = 7U;

    /** - Setup compare 0 value. This value is compared with selected free running counter. */
    rtiREG1->CMP[0U].COMPx = 937500U;

    /** - Setup update compare 0 value. This value is added to the compare 0 value on each compare match. */
    rtiREG1->CMP[0U].UDCPx = 937500U;

    /** - Setup compare 1 value. This value is compared with selected free running counter. */
    rtiREG1->CMP[1U].COMPx = 46875U;

    /** - Setup update compare 1 value. This value is added to the compare 1 value on each compare match. */
    rtiREG1->CMP[1U].UDCPx = 46875U;

    /** - Setup compare 2 value. This value is compared with selected free running counter. */
    rtiREG1->CMP[2U].COMPx =75000U;

    /** - Setup update compare 2 value. This value is added to the compare 2 value on each compare match. */
    rtiREG1->CMP[2U].UDCPx = 75000U;

    /** - Setup compare 3 value. This value is compared with selected free running counter. */
    rtiREG1->CMP[3U].COMPx = 93750U;

    /** - Setup update compare 3 value. This value is added to the compare 3 value on each compare match. */
    rtiREG1->CMP[3U].UDCPx = 93750U;

    /** - Clear all pending interrupts */
    rtiREG1->INTFLAG = 0x0007000FU;

    /** - Disable all interrupts */
    rtiREG1->CLEARINTENA = 0x00070F0FU;

    /** @note This function has to be called before the driver can be used.\n
    * This function has to be executed in privileged mode.\n
    * This function does not start the counters.
    */

    /* USER CODE BEGIN (4) */
    /* USER CODE END */
    }

    Thanks.

  • int main(void)
    {
    /* USER CODE BEGIN (3) */

    //INITIALIZE TMS570LS1224
    systemInit();
    gioInit();
    sciInit();
    rtiInit()

    rtiEnableNotification(rtiNOTIFICATION_COMPARE0);

    /* Enable IRQ - Clear I flag in CPS register */
    /* Note: This is usually done by the OS or in an svc dispatcher */
    _enable_IRQ();

    /* Start RTI Counter Block 0 */
    rtiStartCounter(rtiCOUNTER_BLOCK0);

    }

    I can't see infinity loop in your main function, that is while(1); is missing.

    Can you try with below code:

    int main(void)
    {
    /* USER CODE BEGIN (3) */
    
    //INITIALIZE TMS570LS1224
    systemInit();
    gioInit();
    sciInit();
    rtiInit()
    
    rtiEnableNotification(rtiNOTIFICATION_COMPARE0);
    
    /* Enable IRQ - Clear I flag in CPS register */
    /* Note: This is usually done by the OS or in an svc dispatcher */
    _enable_IRQ();
    
    /* Start RTI Counter Block 0 */
    rtiStartCounter(rtiCOUNTER_BLOCK0);
    
    while(1);
    
    }

    --
    Thanks & Regards,
    Jagadish.

  • Hi Jagadish,

    Thanks for reply I try your code but not work. 

    Below is code I tried as per your suggestion but interrupt is coming at every us but I configured the interrupt for 1 sec.

    int main(void)
    {
    /* USER CODE BEGIN (3) */

    //INITIALIZE TMS570LS1224
    systemInit();
    gioInit();
    sciInit();
    rtiInit()

    rtiEnableNotification(rtiNOTIFICATION_COMPARE0);

    /* Enable IRQ - Clear I flag in CPS register */
    /* Note: This is usually done by the OS or in an svc dispatcher */
    _enable_IRQ();

    /* Start RTI Counter Block 0 */
    rtiStartCounter(rtiCOUNTER_BLOCK0);

    while(1);

    }

    void rtiNotification( uint32 notification)
    {
    printConsole("2nd device OTUT fault--\n");
    }

     

    Thanks.

  • Hi Sudhir,

    I created one example project to get RTI Compare0 interrupt for every 1 Sec.

    Here is the complete project:

    RTI_Interrupt_TEST_LS1224.zip

    I didn't test this project at my end due to lack of the LS1224 board, but this code will work. Please try to test this project at your end.

    --
    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    I try your code but your code did not work 

    The value of Flag Status is always remains 0.

    I checked it in debug.

    Thanks

  • Can we setup one live debugging session?

    Can you share your screen and show me the issue, so that i can suggest you well.

    If you okay for it then please share the meeting link.