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.

GPIO interrupt only 'Firing' once

Hi there,

I am trying to get an accelerometer to trigger an interrupt on PC6 when new data is available.

However, when trying to make this run it will only fire once. The accelerometer datasheet says that the pin will be cleared when the registers are read. I am out of ideas.

Thanks in advance.

Thomas.

I've created this function to initiate the pin:

void intSetup()
{
IntMasterEnable();
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);

GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_6);
GPIOPadConfigSet(GPIO_PORTC_BASE,GPIO_PIN_6,GPIO_STRENGTH_8MA,GPIO_PIN_TYPE_STD_WPD);
GPIOIntClear(GPIO_PORTC_BASE, GPIO_PIN_6);

GPIOIntTypeSet(GPIO_PORTC_BASE, GPIO_PIN_6,
GPIO_RISING_EDGE);

GPIOIntEnable(GPIO_PORTC_BASE, GPIO_PIN_6);
IntEnable(INT_GPIOC);

}

And the interrupt is:

void accelInt(void){
//clear the time interrupt

GPIOIntClear(GPIO_PORTC_BASE, GPIO_PIN_6);
datacollected++;
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
readAccData(accelG);
bufferX[i]=accelG[0];
bufferY[i]=accelG[1];
bufferZ[i]=accelG[2];
i++;
if(i==1024){
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 4);
i=0;
}}

I have also editted startup_css.c

extern void  accelInt(void);

accelInt,   // GPIO Port C

etc

  • Hi Thomas.

    Can you mention the name of the accelerometer you are using?

    Regards,

    Shashank

  • Hi Shashank,

    I managed to solve the problem this morning after days of it not working! 

    I am using a MMA8452Q by freescale. I had enabled drdy interrupt to interrupt pin 1 but not configured it properly.

    This involved sending the value 0x02 to register 0x2C.

    Thanks for the reply.

    Thomas.

  • Hi!!

    Thomas,

    Could you help me? how you resolve this problem? the same I here face now.

    Pls. correct me if there is any issue with initialization

    void console_init(void)

    {

                ROM_IntMasterEnable();
                ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);

                ROM_GPIOPinTypeGPIOInput(GPIO_PORTM_BASE, GPIO_PIN_0);
                  ROM_GPIOPadConfigSet(GPIO_PORTM_BASE,GPIO_PIN_0,GPIO_STRENGTH_8MA,GPIO_PIN_TYPE_STD_WPD);
                GPIOIntClear(GPIO_PORTM_BASE, GPIO_PIN_0);

                ROM_GPIOIntTypeSet(GPIO_PORTM_BASE, GPIO_PIN_0, GPIO_FALLING_EDGE);

                GPIOIntEnable(GPIO_PORTM_BASE, GPIO_PIN_0);
                ROM_IntEnable(INT_GPIOM);
                        
                ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
                ROM_SysCtlDelay(1);
            
                //For testing purpose (USER LED on Dev. Board)
                ROM_GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2);
                ROM_GPIODirModeSet(GPIO_PORTG_BASE, GPIO_PIN_2, GPIO_DIR_MODE_OUT);
                ROM_GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2, 0);

    }
      

    and interrupt handler

    void IntGPIOm(void)
    {
               GPIOIntClear(GPIO_PORTM_BASE, GPIO_PIN_0);

               status = ~status; // uint8_t  global variable
    }

  • Hello Pramod,

    It is unclear as to how are you causing the Pin PM0 to toggle. Are you connecting pin PG2 as output and connecting it to PM0? If yes, then

    1. The code is not generating a falling edge on the PG2. You have to write 1 to PG2 and then write 0 for the falling edge

    2. Once the first falling edge is generated for any subsequent falling edge you will have to do this in a while loop/

    Regards

    Amit