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: Define USER ISR function in application code

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

Tool/software: TI C/C++ Compiler

Hi,

 I would like to use userISR function in my code  . By referring the Instaspin code( from Motorware) added the USERISR  code   . But its now working , i have attached the code what i have done. i feel i would have missed something when i am  define the ISR function, but i couldnt find. please let me know i what i have to do  make this code  work .. One more thing i am loading my code in"CPU1_ RAM not in FLASH".

NOTE: Using C2000 LAUNCHPAD XL TMS320F28379D,VER2.0

thanks in advance.

MYCODE:


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

#ifdef FLASH
#pragma CODE_SECTION(mainISR,"ramfuncs");
#endif

void main(void)
{

        Device_init();

        Device_initGPIO();
        GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
        GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);

        Interrupt_initModule();

        Interrupt_initVectorTable();

        EINT;
        ERTM;

        for(;;)
        {

        NOP;
        }
    }


interrupt void mainISR(void)
{
                  GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);

                  DEVICE_DELAY_US(500000);

                  GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);


                  DEVICE_DELAY_US(500000);

}

    // End of File


    



  • Please refer to a simple interrupt example to understand the flow,

    ...c2000\C2000Ware_3_02_00_00\driverlib\f2837xd\examples\cpu1\interrupt\interrupt_ex1_external

    This should help you with all the basic steps needed to configure and interrupt as well as service the ISR.

    Use this as a reference to develop your own.

  • Karthik,

             I have worked with PIE interrupts its works fine .Now i am need to work with user ISR functions . I am not aware of how to implement that.

    My questions are :

    1.PIE interrupts are occurs based on peripheral events .  When USERISR function will occurs, how to control it?

    2. To initialize PIE interrupts ,EX

           For External Interrupt following bellow steps are taken :

           Interrupt_register(INT_XINT1, &xint1_isr);

           Interrupt_enable(INT_XINT1);

          GPIO_setInterruptPin(0,GPIO_INT_XINT1);

         GPIO_setInterruptType(GPIO_INT_XINT1, GPIO_INT_TYPE_RISING_EDGE);
         GPIO_enableInterrupt(GPIO_INT_XINT1);         // Enable XINT1

    interrupt void xint1_isr(void)
    {
       // GPIO_clearPortPins(GPIO_PORT_B,GPIO_GPBDIR_GPIO34); //GPIO34 is low
       // Dia_Spindle1Count++;
        Len_Spindle1Count++;


           //
        // Acknowledge this interrupt to get more from group 1
        //
        Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);


    }

    What i have to do for  USERISR  function?

    3.From Motorware example i got function

    interrupt void mainISR(void)
    {

      // toggle status LED
      if(++gLEDcnt >= (uint_least32_t)(USER_ISR_FREQ_Hz / LED_BLINK_FREQ_Hz))
      {
        HAL_toggleLed(halHandle,(GPIO_Number_e)HAL_Gpio_LED2);
        gLEDcnt = 0;
      }


      // acknowledge the ADC interrupt
      HAL_acqAdcInt(halHandle,ADC_IntNumber_1);


      // convert the ADC data
      HAL_readAdcData(halHandle,&gAdcData);


      // ADC processing and pwm result code goes here


      // write the PWM compare values
      HAL_writePwmData(halHandle,&gPwmData);


      return;
    } // end of mainISR() function

    so, need an help  to implement like MainISR function in my code . I didnt see this function inC2000ware apart from motorware coding ..

    Is this possible to work in C2000ware example codes.

    4. Is this possible to run in RAM (uploading code in RAM) not in Flash?

  • Okay the example #2 you have talked about is generating an interrupt using GPIO, when I/O toggles it generates an interrupt.

    On example #3 with motorware, its an ADC ISR, when ever an ADC conversion is complete you get an interrupt.

    If you are creating an example then you should determine who would generate that interrupt and map that ISR to that event interrupt.

    Running from Ram is possible.

    But if you are just starting with C2000 then I would recommend you to go through some of the basic C2000 training videos before you jump on to these.

  • Hi Karthik,

       I think i am not convey my thoughts properly to you,actually i  need to use software interrupt(TRAP).

    Ex. Want to blink my led in ISR function  without peripheral event .

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



    #ifdef FLASH
    #pragma CODE_SECTION(mainISR,"ramfuncs");
    #endif

    #ifdef FLASH
    // Used for running BackGround in flash, and ISR in RAM
    extern uint16_t *RamfuncsLoadStart, *RamfuncsLoadEnd, *RamfuncsRunStart;


    //
    // Main
    //
    void main(void)
    {

       

     #ifdef FLASH
      // Copy time critical code and Flash setup code to RAM
      // The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
      // symbols are created by the linker. Refer to the linker files.
      memCopy((uint16_t *)&RamfuncsLoadStart,(uint16_t *)&RamfuncsLoadEnd,(uint16_t *)&RamfuncsRunStart);


            // 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();

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

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

            NOP;
            }
        }


    interrupt void mainISR(void)
    {
                    //  EINT;
                      // Turn on LED
                      //
                      GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);

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

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

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

    }
    //
        // End of File
        //




        Linker CMD -File:

    SECTIONS
    {
       /* Allocate program areas: */
       .cinit              : > FLASHB_D     PAGE = 0
       .pinit              : > FLASHB_D,    PAGE = 0
       .text               : > FLASHB_D     PAGE = 0
       codestart           : > BEGIN        PAGE = 0
       ramfuncs            : LOAD = FLASHB_D,
                             RUN = P_RAML0,
                             LOAD_START(_RamfuncsLoadStart),
                             LOAD_END(_RamfuncsLoadEnd),
                             RUN_START(_RamfuncsRunStart),
                             PAGE = 0
    }

     

    I am not tried , might be if i do like this ISR will work????Any idea about this ? ? 

  • Can you please explain what's your end application or what you are trying to achieve ?

  • Hi ,

     I need a  five Software interrupts to run my application function . So i am trying to use TRAP( Software interrupt) function. but I dont know how to implement that .

  • Actually i want to use this function in my application code,

    interrupt void USER1_ISR(void)     // User Defined trap 1
    {
        EINT;
    
        // Insert ISR Code here.......
    
        // Next two lines for debug only to halt the processor here
        // Remove after inserting ISR Code
        asm ("      ESTOP0");
        for(;;);
    }

  • Hi rani,

    Hope you got your application working fine.

    You should ideally have any peripherals or Timers generating an interrupt if you want something periodic.

    SOftware interrupts are as good as normal CPU code, instead runs as an ISR when asked to with ISR privileges which doesn't get preempted by other code.

    Please close this thread if all the above queries are resolved.

  • Hi Karthik ,

           where is verify to answer button? to close the thread.