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.

CCS/TMS570LC4357: Interrupt Routine

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

Hi,

i know that the Interrupt routine "gioNotification" appears, when i press a user button. (configured in HalcoGen)

The Problem is, my Board has 2 user button. But i want, that each button has its own interrupt routine. The funciton gioNotification apears, independently which button is pressed.

Thanks

  • Hello,

    I don't recommend you to modify the Interrupt service routine in gio.c. You can add 2 if() loop for the interrupts from user button1 and user button2 in gioNotification().

    If offset= 0x08 (GIOB4), it is from UserButton A, and if offset=0x10 (GIOB5), the interrupt is from UserButton B.

    Regards,
    QJ
  • Thanks,

    i do not unterstand, what you mean with offset= 0x08? Could you write a little code, so that i can follow you..
    Thanks
  • Hello,

    The GIOOFF1 and GIOOFF2 registers provide a numerical offset value that represents the pending external interrupt with high priority and low priority. The offset value can be used to locate the position of the interrupt routine in a vector table in application software.

    The GIO interrupt service routine uses this value as the argument of gioNotification(.. , ..). 

    void gioHighLevelInterrupt(void)

    {

    uint32 offset = gioREG->OFF1;

    if (offset != 0U)
    {
    offset = offset - 1U;
    if (offset >= 8U)
    {
       gioNotification(gioPORTB, offset - 8U);
    }
    else
    {
       gioNotification(gioPORTA, offset);
    }
    }

    }

    In notification.c, the arguments of gioNotification(..,..) are changed to "*port" and "bit":

    #pragma WEAK(gioNotification)
    void gioNotification(gioPORT_t *port, uint32 bit)

    Regards,

    QJ

  • Thanks ! Very good explained.

    But where do i find gioHighLevelInterrupt this fcn? do i have to implement myself?

    Thanks
  • Hello,

    Those are the procedure to generate this code in HALCoGen:

    1. Enable Drivers: check "Enable GIO Driver"

    2.  Configure Vectored Interrupt Module Channels (VIM):

    1. Map VIM Channel 9 to GIO High interrupt
    2. Enable VIM Channel 9
    3. Map VIM Channel 9 to IRQ

    3.  Save the Project, and Generate Code. The Interrupt service routine will be generated, and placed in gio.c

    Regards,

    QJ 

  • void gioNotification(gioPORT_t *port, uint32 bit)
    {
    /* enter user code between the USER CODE BEGIN and USER CODE END. */
    /* USER CODE BEGIN (22) */

    switch(bit) {

    case 0x08: i = 1; break;
    case 0x10: i = 0; break;

    }

    /* USER CODE END */
    }

    For example this is not working. what can i do

  • Hello;

    Change your code to:

    case 0x05: i = 1; break; //interrupt from GIOB[4]; 1 for GIOB[0], 2 for GIOB[1], ...

    case 0x06: i = 0; break; //interrupt from GIOB[5]