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.

LP-MSPM0G3507: Problem with button & Leds

Part Number: LP-MSPM0G3507
Other Parts Discussed in Thread: MSPM0G3507,

Tool/software:

Dear all,

I am new to the field of programming microcontrollers and I started to program the MSPM0G3507 on the Launchpad. I would like to turn on the RGB Leds LED2 via the button S1 on that Launchpad. For this case I used the part of the code example "spi_controller_echo_interrupts" where a message is sent via an interrupt and modified it for my purpose. The problem is that nothing happens when I press the button. Do you have a clue what might be my mistake? Here is a copy of my main. If there has to be more information, please reach out to me.

#include "ti_msp_dl_config.h"

/* This results in approximately 0.5s of delay assuming 32MHz CPU_CLK */
#define DELAY (16000000)
void turnonled (void);
volatile uint8_t help = 0;

int main(void)
{
    /* Power on GPIO, initialize pins as digital outputs */
    SYSCFG_DL_init();
   
    NVIC_EnableIRQ(GPIO_Button_INT_IRQN);


    // Clear Pin and Set pin command lines
    DL_GPIO_clearPins(GPIO_LEDS_PORT,  GPIO_LEDS_USER_LED_1_PIN & GPIO_LEDS_USER_LED_2_PIN & GPIO_LEDS_USER_LED_3_PIN );
    //DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_2_PIN | GPIO_LEDS_USER_TEST_PIN);
   
   

 while (1)
    {
        __WFI();
        if(help ==1)
        {
            turnonled();
        }
    }    
       
       
}
void GROUP1_IRQHandler(void)
{
    switch (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1)) {
        case GPIO_Button_INT_IIDX:
            switch (DL_GPIO_getPendingInterrupt(GPIO_Button_PORT )) {
                case GPIO_Button_User_S1_IIDX:
                    /* When SWITCHES_USER_SWITCH_1 is pressed, initiate data transmission */
                    help = 1;
                    break;
                default:
                    break;
            }
            break;
        default:
            break;
    }
}

void turnonled (void)
{
    DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN | GPIO_LEDS_USER_TEST_PIN);
}
  • Hello Daniel,

    1). I think you don't need to set the second "

     switch (DL_GPIO_getPendingInterrupt(GPIO_Button_PORT )) {
                    case GPIO_Button_User_S1_IIDX: "
    because all the GPIO interrupt is in the Interrupt_Group1. So you just need to use the 
    "switch (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1)) {
            case GPIO_Button_INT_IIDX: "
    2). This is the circuit of LP-MSPM0G3507. Please check your interrupt logic, you should set the GPIO interrupt to "Rising edge trigger". Search "SLAU873C" on ti.com, you can download this circuit file.
    3). Please try to use debug mode to debug your code step by step.
    Best Regards,
    Janz Bai
  • Hello Janz,

    Thank you very much for ur input. I solved this problem. The input was not correctly assigned to the pin. Thats why the interrupt did not work perfectly.

    Ill close this thread.

    Regards,

    Daniel