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.

Pin A2 and A3 Interrupt Config. @ Tiva C Dev Kit (TM4C123G H6PMI)

Hello my friends,

I am trying to configure the pins A2 and A3 to generate interruption so that I can count events (pull down) in both pins. I am using the UART at Pins A0 and A1 and it's working perfectly. 

Bellow follows the code I am using:

 #define SENSOR_T2M_PORT GPIO_PORTA_BASE

#define SENSOR_T2M GPIO_PIN_3

#define SENSOR_M2T_PORT GPIO_PORTA_BASE

#define SENSOR_M2T GPIO_PIN_2

 void InitSensorPins(void)

{

    GPIOIntRegister(SENSOR_T2M_PORT, SensorIntHandler);

    GPIOIntRegister(SENSOR_M2T_PORT, SensorIntHandler);

    GPIOPinTypeGPIOInput(SENSOR_T2M_PORT, SENSOR_T2M);

    GPIOPinTypeGPIOInput(SENSOR_M2T_PORT, SENSOR_M2T);

    GPIOIntTypeSet(SENSOR_T2M_PORT, SENSOR_T2M, GPIO_FALLING_EDGE);

    GPIOIntTypeSet(SENSOR_M2T_PORT, SENSOR_M2T, GPIO_FALLING_EDGE);

    GPIOPadConfigSet(SENSOR_T2M_PORT, SENSOR_T2M, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

    GPIOPadConfigSet(SENSOR_M2T_PORT, SENSOR_M2T, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

    GPIOIntEnable(SENSOR_T2M_PORT, SENSOR_T2M);

    GPIOIntEnable(SENSOR_M2T_PORT, SENSOR_M2T);

}

The interruption at pin A3 works but the A2 doesn't.

I already did the same code using the kit buttons (SW1 (pin F4) and SW2 (pin F0) ) and only the F4 pin worked.

I have seen some "unlocking"  piece of code in the forum but sincerely I do not understand if I need to use it or not and if I need, how should I code it.

Thank you in advance,

Regards,

Eduardo

  • To check which pins need unlock check Table 10-1. GPIO Pins With Special Considerations. 

    PF0 is actually one of the pins that needs to be unlocked.

    With A2, what exactly does not work? Does it work alone, without using A3 interrupt? Does the code simply get stuck and do nothing? 

    Please also provide the interrupt handler.

  • How could any "new" poster be expected to note - then comprehend - the on-going, "PF0/PD7 gotcha?"

    This reporter (unfortunately) notes that there's time/effort/funds available to, "Rename this forum" - yet no such (long suggested improvement mechanisms) to (somewhat) highlight the endless "PF0/PD7" pitfall.

    Claim of "Great" seems suspect when priorities seem so (pardon) misguided.

  • Hello Eduardo,

    I tested the code you have sent with one of my TM4C123 LaunchPads. It works fine. Attached is the code for your reference.

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_memmap.h"
    #include "inc/tm4c123gh6pm.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    
    #define SENSOR_T2M_PORT GPIO_PORTA_BASE
    #define SENSOR_T2M GPIO_PIN_3
    #define SENSOR_M2T_PORT GPIO_PORTA_BASE
    #define SENSOR_M2T GPIO_PIN_2
    
    void PortAIntHandler(void)
    {
    	if (GPIOIntStatus(GPIO_PORTA_BASE, GPIO_PIN_3) & GPIO_PIN_3){
    		GPIOIntClear(GPIO_PORTA_BASE, GPIO_PIN_3);
    	}
    	if (GPIOIntStatus(GPIO_PORTA_BASE, GPIO_PIN_2) & GPIO_PIN_2){
    		GPIOIntClear(GPIO_PORTA_BASE, GPIO_PIN_2);
    	}
    }
    
    void main(void){
    
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
        GPIOIntRegister(SENSOR_T2M_PORT, PortAIntHandler);
        GPIOIntRegister(SENSOR_M2T_PORT, PortAIntHandler);
    
        GPIOPinTypeGPIOInput(SENSOR_T2M_PORT, SENSOR_T2M);
        GPIOPinTypeGPIOInput(SENSOR_M2T_PORT, SENSOR_M2T);
    
        GPIOIntTypeSet(SENSOR_T2M_PORT, SENSOR_T2M, GPIO_FALLING_EDGE);
        GPIOIntTypeSet(SENSOR_M2T_PORT, SENSOR_M2T, GPIO_FALLING_EDGE);
    
        GPIOPadConfigSet(SENSOR_T2M_PORT, SENSOR_T2M, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
        GPIOPadConfigSet(SENSOR_M2T_PORT, SENSOR_M2T, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    
        GPIOIntEnable(SENSOR_T2M_PORT, SENSOR_T2M);
        GPIOIntEnable(SENSOR_M2T_PORT, SENSOR_M2T);
    	while (1);
    
    }
    

    Also as Luis mentioned, yes, PF0 needs to be unlocked. Please see the Stick Post...

    http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/374640.aspx

    Regards

    Amit

  • Amit Ashara said:
    PF0 needs to be unlocked. Please see the Stick Post...

    Is it not "painfully clear" that 90%+ will NOT see that "Stick Post" - nor note the brief/un-highlighted manual reference - to, "special pin handling?"

    Another poster (here Eduardo) predictably missed both - and the (slight) mention here (in a posting which will (likely) "Never be viewed again!") is clearly ineffectual. 

    Rename of the Forum hardly seems best/brightest choice among many, "most needed" activities... 

  • Solved,

    it was a hardware problem. In my sensor (the one I was counting events) I had a 1kohm pull-down resistor (only at the PA2) and as I was expecting the sensor to count falling edge events, it would never happen.

    I just fixed it by changing from falling to rising edge and it worked. 

    Thank you all for your help

  • Each/every PC @ our office bears (worn) Sticky Note stating, "Don't use PF0 or PD7!"  None of our (many) smart interns nor hires has "ever" found the forum "sticky" - nor noted the NMI advisory (mice-type) in the 1K+ pg. MCU manual.

    While (always) "duly noted" - Eduardo serves as the most recent victim of such (ineffectual) notice!

    What's needed is an effective FIX - not simple notation...

    Eduardo - good for you and thanks for sharing your "fix" with us guys...  And "fear not" when the forum's renamed - and this "years old" NMI issue lingers - that's (vendor's idea) of progress...  And that's well Noted!