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.

Compiler/TMS320F28379D: Induce Software ISR function in TMS320F28379D

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE, CONTROLSUITE

Tool/software: TI C/C++ Compiler

Hi,

 Any one could help me to work on Software ISR(TRAP) function .Actually i want to use this interrupts . My aim is want to blink my led in software interrupt.

    PINT USER1_INT;                                  // User Defined Trap 1
    PINT  USER2_INT;                                  // User Defined Trap 2
    PINT  USER3_INT;                                  // User Defined Trap 3
    PINT  USER4_INT;                                  // User Defined Trap 4
    PINT  USER5_INT;                                  // User Defined Trap 5
    PINT  USER6_INT;                                  // User Defined Trap 6
    PINT  USER7_INT;                                  // User Defined Trap 7
    PINT  USER8_INT;                                  // User Defined Trap 8
    PINT  USER9_INT;                                  // User Defined Trap 9
    PINT  USER10_INT;                                 // User Defined Trap 10
    PINT  USER11_INT;                                 // User Defined Trap 11
    PINT  USER12_INT;                                 // User Defined Trap 12

If anyone have idea please share me the procedure to implement in code .

Thanks in advance .


 

  • Part Number: TMS320F28379D

    Tool/software: TI C/C++ Compiler

    Hi,

     I'm trying to configure and use a software interrupt using the TMS320F28379D. The CPU interrupt vector declares USER 1 - USER 12 are the user-defined software interrupts according to the Technical Reference Manual.

    Please any one share the procedure to implement the software interrupt in TMS320F28379D.I didnt get any example relevant to software interrupt in c2000ware example codes in driverlib as well as in controlsuite.

    Thanks in advance .

  • Sorry for the delay, one of our experts will get back to you.

  • Hello,

    Thank you for your question! These user interrupts can be configured identically to the other device interrupts. To make an led blinky example using USER interrutps, While we cannot directly provide an exact procedure to do so, I suggest you do the following (which will directly solve your issue):

    In the LATEST C2000Ware (please make sure it is up to date):

    Look at both the following examples and use them as a basis to write your interrupt configuration and routine:

    "interrupt_ex2_with_i2c_sci_spi_loopback.c" (located in C2000Ware_VERSION###\driverlib\f2837xd\examples\cpu1\interrupt)

    "sci_ex2_loopback_interrupts.c" (located in C2000Ware_VERSION###\driverlib\f2837xd\examples\cpu1\sci)

    -AND-

    View the following led example as a basis for how to toggle LEDs:

    "led_ex1_blinky.c" (located in C2000Ware_VERSION###\driverlib\f2837xd\examples\cpu1\led\led_ex1_blinky.c)

    If you combine these two learning examples (after learning and understanding how they work), you will be able to toggle LEDs using user interrupts!

    Regards,

    Vince

  • Hi Rani,

    Sorry for the delay. PFB the details related to USER interrupts.

    USER1 – USER12 are user-defined software interrupts which are non-maskable interrupts. These can be raised through TRAP instruction only. ISR for the software interrupt will run even if interrupts are disabled.

    // Code for raising user interrupts:
     __asm(" TRAP #20");    // This will raise USER1 interrupt. 20 is the vector id
    
    // USER1 ISR
    __interrupt void user1ISR(void)
    {
        temp1++;
        temp2++;
    }

    Thanks
    Vasudha

  • Hi,

      I have done my code as per my understanding by referring the Examples and your guidance . But its not works ,please help me to slove this problem .

    //#############################################################################
    //
    // FILE:   led_ex1_blinky.c
    //
    // TITLE:  LED Blinky Example
    //
    //! \addtogroup driver_example_list
    //! <h1> LED Blinky Example </h1>
    //!
    //! This example demonstrates how to blink a LED.
    //!
    //! \b External \b Connections \n
    //!  - None.
    //!
    //! \b Watch \b Variables \n
    //!  - None.
    //!
    //
    //#############################################################################
    // $TI Release: F2837xD Support Library v3.08.00.00 $
    // $Release Date: Mon Dec 23 17:32:30 IST 2019 $
    // $Copyright:
    // Copyright (C) 2013-2019 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without
    // modification, are permitted provided that the following conditions
    // are met:
    //
    //   Redistributions of source code must retain the above copyright
    //   notice, this list of conditions and the following disclaimer.
    //
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the
    //   documentation and/or other materials provided with the
    //   distribution.
    //
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    //
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // $
    //#############################################################################

    //
    // Included Files
    //
    #include "driverlib.h"
    #include "device.h"

    //
    // Defines
    //
    # define LOOP_COUNT 10
    interrupt void USER1_ISR(void);
    //
    // Main
    //
    void main(void)
    {
        //
        // Initialize device clock and peripherals
        //
        Device_init();

        //
        // Initialize GPIO and configure the GPIO pin as a push-pull output
        //
        Device_initGPIO();
        GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
        GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);

        //
        // Initialize PIE and clear PIE registers. Disables CPU interrupts.
        //
        Interrupt_initModule();

        //
        // Initialize the PIE vector table with pointers to the shell Interrupt
        // Service Routines (ISR).
        //
        Interrupt_initVectorTable();


        Interrupt_register(INT_USER1, &USER1_ISR);


            //
            // Enable interrupts required for this example
            //
        Interrupt_enable(INT_USER1);
        // Code for raising user interrupts:

         __asm(" TRAP #20");    // This will raise USER1 interrupt. 20 is the vector id

        //
        // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
        //
        EINT;
        ERTM;

        //
        // Loop Forever
        //
        for(;;)
        {
            NOP;


        }
    }

    // USER1 ISR


    __interrupt void USER1_ISR(void)
    {
       
                GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
                DEVICE_DELAY_US(50000);
                GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);
                DEVICE_DELAY_US(50000);

    }


      Thanks in advance .

  • Hello,

    Unfortunately, we cannot directly debug code logs pasted into the window. I can provide some guidance however:

    If you only call TRAP once, this will only be called once. You will only see the LED on for 50ms total, one time. You'd probably see it with a logic analyzer, but very unlikely you would see it with your eyes.

    Also, the ISR only keeps the LED on/off for 0.05s (50 ms), so you will likely not even notice that its on (or even if you repeat it constantly it will just look really dim). Try making the delays a bit longer, and repeating the TRAP call once every couple seconds.

    Regards,

    Vince

  • Hi,

     Thanks a lot for all, help me to accomplish the task  . Finally my blinky code is running  within user_isr function.

    #include "driverlib.h"
    #include "device.h"

    interrupt void USER1_ISR(void);
    //
    // Main
    //
    void main(void)
    {
        //
        // Initialize device clock and peripherals
        //
        Device_init();

        //
        // Initialize GPIO and configure the GPIO pin as a push-pull output
        //
        Device_initGPIO();
        GPIO_setPadConfig(DEVICE_GPIO_PIN_LED2, GPIO_PIN_TYPE_STD);
        GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED2, GPIO_DIR_MODE_OUT);

        //
        // Initialize PIE and clear PIE registers. Disables CPU interrupts.
        //
        Interrupt_initModule();

        //
        // Initialize the PIE vector table with pointers to the shell Interrupt
        // Service Routines (ISR).
        //
        Interrupt_initVectorTable();


        Interrupt_register(INT_USER1, &USER1_ISR);


        //
            // Enable interrupts required for this example
            //
        Interrupt_enable(INT_USER1);
        // Code for raising user interrupts:

         __asm(" TRAP #20");    // This will raise USER1 interrupt. 20 is the vector id



        //
        // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
        //
        EINT;
        ERTM;

        //
        // Loop Forever
        //
        for(;;)
        {

            __asm(" TRAP #20");    // This will raise USER1 interrupt. 20 is the vector id



        }
    }

    //
    // End of File
    //

    // USER1 ISR


    __interrupt void USER1_ISR(void)
    {
        //__asm(" TRAP #20");    // This will raise USER1 interrupt. 20 is the vector id


        //
                // Turn on LED
                //
                GPIO_writePin(DEVICE_GPIO_PIN_LED2, 0);

                //
                // Delay for a bit.
                //
                DEVICE_DELAY_US(500000);

                //
                // Turn off LED
                //
                GPIO_writePin(DEVICE_GPIO_PIN_LED2, 1);

                //
                // Delay for a bit.
                //
                DEVICE_DELAY_US(500000);

    }