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/LAUNCHXL2-RM57L: Interrupt handling to turn on LEDs using the user button

Part Number: LAUNCHXL2-RM57L
Other Parts Discussed in Thread: HALCOGEN,

Tool/software: Code Composer Studio

Hello,

I was able to turn on the LEDs on the board using several GIO functions. However, I am still trying to get the LEDs to turn on/off by pressing the user buttons. I believe this can be done using an interrupt, but I do not how to enable it in HALCoGen and how to include it in my code in CCS. Any help would be appreciated. Thanks!

  • Hello Andrea,
    You can try this:
    In HALCoGen:
    - Go to "Driver Enable" tab;
    - Diasable all drivers (using Mark/Unmark all drivers checkbox);
    - Check "Enable GIO drivers";
    - Go to PINMUX tab;
    - check "GIOB" checkbox;
    - go to "GIO" tab, then "Port B" tab;
    - Enable GIOB[2] pull-up;
    - Enable generating interrupt by clicking on "Enable" (between "Falling Edge") and "Low Priority");
    - Go to "VIM Channel 0-31" tab;
    - Enable channel 23: "GIO Low" interrupt;
    - From File menu select "Generate Code";

    In CCS;
    - Create project with the same name as the one created with HALCoGen;
    - In CCS Build-->ARM Compiler->Include Options add include folder created by HALCoGen;
    - in sys_main.c file enable interrupts ( _enable_IRQ() ) and GIO notifications ( gioEnableNotification(); )
    GIO ISR is in notification.c ( gioNotification ). You can toggle LED here.

    Here you can find nice training for how to use HALCoGen: training.ti.com/hercules-how-tutorial-using-halcogen

    Hope this helps!

    Best regards,
    MIro
  • The LEDs (ports B6 and B7) are still not turning on by the push of the user button (ports B4 and B5). I am wondering if there is anything else I need to do on the main function in sys_main.c to be able to do that. Also, do I have to enable interrupts for the user button ports? Thank you for your help!

    ~Andrea

  • Hello,
    You should use gioEnableNotification(gioPORTB, 4) and gioEnableNotification(gioPORTB, 5) to enable interrupts generated by GIOB[4] and GIOB[5]. Also _enable_IRQ() must be called to enable MCU IRQs.

    Best regards,
    Miro
  • What does the GIOB[2] port handle?. In other words, why is an interrupt enabled for the GIOB[2] port?
  • Hello,
    That was typo. In some launchpads, GIOB[2] is connected to button.

    Best regards,
    Miro
  • Based on the schematics, I understand the two ports that control the user buttons are GIOB[4] and GIOB[5]. However, when I use those ports, the user buttons do not turn on/off the LED lights. Yet, when I use GIOB[2], it does work. I was wondering if you could answer this, and what the GIOB[2] port is used for? What is its function?

  • Hello,
    GIOB[2] is part of General-Purpose Input/Output (GIO) Module (Section 25 of device TRM). On LAUNCHXL2-RM57L it is exposed to connectors J2.10, J10.5 and J14.8. And it does not connected to on-board button. If you want, you can connect external button.
    To use any GIO as interrupt source you have to enable: GIO interrupt (High/Low) in VIM module (VIM Channel 0-31 Tab in HALCoGen). Then you have to enable individual pin interrupts from GIO tab, Port A or Port B. Pull-up resistors for particular pins should be enabled.
    For LAUNCHXL2-RM57L GIOB[4] and GIOB[5] are connected to user buttons. To generate interrupt from GIOB[4] and GIOB[5] you should enable GIO interrupts from VIM Channel 0-31 Tab (you could enable both Low and High). Then from GIO tab Port B you have to enable GIOB[4] and GIOB[5] individual interrupts and change pull resustor to Pull-up.
    In CCS:
    in sys_main.c file enable interrupts ( _enable_IRQ() ) and GIO notifications ( gioEnableNotification(); )
    In you case you should use:
    gioEnableNotification(gioPORTB, 4); and gioEnableNotification(gioPORTB, 5);
    GIO ISR is in notification.c ( gioNotification ). You can toggle LED here.

    Best regards,
    Miro