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.

can't get pull-up to work on EK-LM4F120XL

hi,

i wan't to set the pin PA7 for an interrupt on falling edge or low_level

I'm using the evaluation baord EK-LM4F120XL and Code Composer Studio v.5.3

but the following code doesn't work to set up the internal pull-up:

SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);

ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

ROM_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_7);

ROM_GPIODirModeSet(GPIO_PORTA_BASE, GPIO_PIN_7, GPIO_DIR_MODE_IN);

ROM_GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

ROM_GPIOIntTypeSet(GPIO_PORTA_BASE, GPIO_PIN_7, GPIO_FALLING_EDGE);

i meassure at the pin PA7 0 Volt;

when i hook up an external resistor between 3v3 and PA7 i meassure 0 Volt at the pin PA7, too.

What did i wrong?

  • Hi Uli,

         Maybe, this below(in red). Provide more details regarding your set-up. See this post.

         

    Uli Brugger said:
    ROM_GPIOPadConfigSet(rGPIO_PORTA_BASE, GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

    -kel

  • sorry,

    added the missing information in my first post.

    this line:

    ROM_GPIOPadConfigSet(rGPIO_PORTA_BASE, GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

    is the same, as in the function Buttonsinit:

    //
    // Set each of the button GPIO pins as an input with a pull-up.
    //
    ROM_GPIODirModeSet(BUTTONS_GPIO_BASE, ALL_BUTTONS, GPIO_DIR_MODE_IN);
    ROM_GPIOPadConfigSet(BUTTONS_GPIO_BASE, ALL_BUTTONS,
    GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

    i only changed the ports and pins.

    the buttonsinit function seems to work well, because after calling that function i could measure 3v3 at the ports PF0 and PF4

  • Ola!

    In this parameter rGPIO_PORTA_BASE where comes from the prefix "r"? Markel kindly suggest to wipe it out and try again...

    Petrei

  • sorry, 

    this is only a copy and paste mistake...

    this is right:

    ROM_GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

    the code compiles without errors or warnings...

  • Hi Uli,

    I copy and pasted your code and ran it on a Launchpad here. It worked with no modifications and I was able to detect a high level on PA7. Please make sure that you are measuring the correct pin (PA7 not PF1) and that nothing else is connected to PA7 that could pull it low.

    Regards,

    Sam

  • hi,

    i'm sure, that i measured the correct pin and nothing else is connected to the pin.

    could you send me your eclipse project, that worked?

    maybe my startup.css or something else is wrong.

    thank's for helping

  • Based from datasheet, PA7 is pin 24. 

  • Re: "I'm sure, that I measured the correct pin and nothing else is connected to the pin."

    If we had 1 USD for each time this claim was made...  (and then proved - not "quite" the case...)

    Unless PA7 is configured elsewhere as an output - or has been electrically abused - it should be unable to "pull down" a "reasonable value" pull-up R.  Early launchpads implemented a GPIO to GPIO "connect" - for "past compatibility" reasons.  Schematic should reveal - other than listed here - nothing else makes sense...

    May prove useful to instead config PA7 as an output - then toggle both high & low - and monitor.  Prior to this - always worthwhile to use a suitable meter to measure the resistance - this pin to ground. 

    Tall chip-stack on black   (I mean ... mislabeled pin or misunderstood MCU pin layout)...

  • hi cb1_mobile,

    thank's for reply. I have 2 lauchpads from the pre-order action last year.  so it could be an early launchpad.

    this morning i tried the following code an everything works right, until i uncomment the led lines. then the high levels go to zero or to 2 volt depending on the led colors. so i think, that there must be an "gpio to gpio connect". but in the manual: spmu289a.pdf (can't find this manual on your servers any more)  i couldn't see that connections.

    here is the code:

    //*************************
    //Include Files
    //*************************
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"

    int interrupt1;

    void PortAIntHandler(void) //PA7
    {
    interrupt1=1;
    GPIOPinIntClear(GPIO_PORTA_BASE, GPIO_PIN_7);

    //GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 ,2); //led red while measuring

    }

    void PortBIntHandler(void) //PB3
    {
    interrupt1=2;
    GPIOPinIntClear(GPIO_PORTB_BASE, GPIO_PIN_3);
    //GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 ,4); //led green while measuring

    }

    void PortDIntHandler(void) //PD1
    {
    interrupt1=3;
    GPIOPinIntClear(GPIO_PORTD_BASE, GPIO_PIN_1);
    //GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 ,8); //led blue while measuring

    }


    void PortEIntHandler(void) //PE5
    {
    interrupt1=4;
    GPIOPinIntClear(GPIO_PORTE_BASE, GPIO_PIN_5);
    //GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 ,6); //led while measuring

    }

    int main(void)
    {


    SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 ,0); //led off


    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    ROM_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_7);
    ROM_GPIODirModeSet(GPIO_PORTA_BASE, GPIO_PIN_7, GPIO_DIR_MODE_IN);
    ROM_GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    ROM_GPIOIntTypeSet(GPIO_PORTA_BASE, GPIO_PIN_7, GPIO_FALLING_EDGE);

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    ROM_GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_1);
    ROM_GPIODirModeSet(GPIO_PORTD_BASE, GPIO_PIN_1, GPIO_DIR_MODE_IN);
    ROM_GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    ROM_GPIOIntTypeSet(GPIO_PORTD_BASE, GPIO_PIN_1, GPIO_FALLING_EDGE);

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    ROM_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_3);
    ROM_GPIODirModeSet(GPIO_PORTB_BASE, GPIO_PIN_3, GPIO_DIR_MODE_IN);
    ROM_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    ROM_GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_3, GPIO_FALLING_EDGE);

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    ROM_GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_5);
    ROM_GPIODirModeSet(GPIO_PORTE_BASE, GPIO_PIN_5, GPIO_DIR_MODE_IN);
    ROM_GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_5, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    ROM_GPIOIntTypeSet(GPIO_PORTE_BASE, GPIO_PIN_5, GPIO_FALLING_EDGE);

    ROM_SysCtlDelay(SysCtlClockGet() / (3));

    GPIOPortIntRegister(GPIO_PORTA_BASE, PortAIntHandler);//for the interrupt handler
    ROM_GPIOPinIntClear(GPIO_PORTA_BASE, GPIO_PIN_7);
    ROM_GPIOPinIntEnable(GPIO_PORTA_BASE, GPIO_PIN_7);

    GPIOPortIntRegister(GPIO_PORTB_BASE, PortBIntHandler);//for the interrupt handler
    ROM_GPIOPinIntClear(GPIO_PORTB_BASE, GPIO_PIN_3);
    ROM_GPIOPinIntEnable(GPIO_PORTB_BASE, GPIO_PIN_3);

    GPIOPortIntRegister(GPIO_PORTD_BASE, PortDIntHandler);//for the interrupt handler
    ROM_GPIOPinIntClear(GPIO_PORTD_BASE, GPIO_PIN_1);
    ROM_GPIOPinIntEnable(GPIO_PORTD_BASE, GPIO_PIN_1);

    GPIOPortIntRegister(GPIO_PORTE_BASE, PortEIntHandler);//for the interrupt handler
    ROM_GPIOPinIntClear(GPIO_PORTE_BASE, GPIO_PIN_5);
    ROM_GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_5);


    while(1)
    {
    }


    }

  • @Uli,

    Feel your pain - but clearly you have no issue w/original, "failure of pull-up R to function."  Indeed - as all here stated - that works...

    Pardon - but digging into that expanse of code bit outside my, "day planner." 

    As past stated - my post & others - someway/somehow PA7 is being impacted - and if you must continue to employ PA7 - is that resolution not best self-solved?

  • @Uli,

    Two questions about your code:

    a) did you declared the GPIO interrupts in startup_ccs.c file? and modified the interrupt vector with the declared GPIO interrupts?

    b) I cannot see in your code where is or if you enabled global interrupts?

    Petrei

  • hi,

    @ Petrei

    i forget to enable the  IntMasterEnable function in this code.  but it should be only be an example for my problem. in my normal code i enabled the IntMasterEnable function.

    i thought, that this line:

    GPIOPortIntRegister(GPIO_PORTA_BASE, PortAIntHandler);

    is enough to register the interrupt correctly and it isn't necessary to edit the startup_css.c file. because this works without problems in  my normal codes..

    would it be better to edit the vector table of the startup_css.c file so:

    extern void PortAIntHandler;

    .

    .

     

    SysTickHandler, // The SysTick handler
    PortAIntHandler, // GPIO Port A
    IntDefaultHandler, // GPIO Port B
    IntDefaultHandler, // GPIO Port C

    greetings from germany