LPC11e68 - can't read GPIO 0-12 or 0-13

cancel
Showing results for 
Search instead for 
Did you mean: 

LPC11e68 - can't read GPIO 0-12 or 0-13

Jump to solution
364 Views
chrispflieger
Contributor IV

This seems so simple yet nothing works...

I really need 0-12 to feed a capture timer, but let's just verify these can read the pin state.

IOCON - set to function 1 (because 0 is JTAG). Verified by looking at the registers in the debugger.

The pullup / pulldown function WORKS! - verified with a scope.

Yet the pin value (checked in the  GPIO-PORT registers via the debugger) is always zero.

Also I verified the LED functions do work (I can revers the logic and the lights stay on).

In the debugger, I was messing around, and found out that changing the "inverted" mode on the IOCON register would actually turn my LED on and off, changing the pullup doesn't do anything but change the actual pin voltage. It's like it's somehow disconnected inside.

I just can't figure out what I missing here. It's so simple, yet so broken.

 

int main(void)
{
    SystemCoreClockUpdate();

    Chip_GPIO_Init(LPC_GPIO);
    Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON);

    GREEN_LED_SETUP();
    GREEN_LED_OFF();
    BLUE_LED_SETUP();
    Chip_GPIO_SetPinDIRInput(LPC_GPIO, 0, 12); // reduntant, but testing
    Chip_GPIO_SetPinDIRInput(LPC_GPIO, 0, 13);
    Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 12, IOCON_FUNC1 | IOCON_MODE_PULLDOWN);
    Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 13, IOCON_FUNC1 | IOCON_MODE_PULLDOWN);
    while(1)
    {
        if (Chip_GPIO_ReadPortBit(LPC_GPIO, 0, 13))
        {
            BLUE_LED_ON();
        }
        else
        {
            BLUE_LED_OFF();
        }
        if (Chip_GPIO_ReadPortBit(LPC_GPIO, 0, 12))
        {
            GREEN_LED_ON();
        }
        else
        {
            GREEN_LED_OFF();
        }
    }
}

 

I noted that the IOCON table also lists function 5 as having the same property as function 1, but the pullups didn't work for that.

 

I did check with another design of ours on this MCU, and it looks like it was using 0-12 for an ADC input OK.

 

0 Kudos
1 Solution
359 Views
chrispflieger
Contributor IV

Wouldn't you know that after a week pulling out my hair, I'd figure it out thirty seconds after begging for help?

 

IOCON_DIGMODE_EN

 

Interestingly, that doesn't show up as a configuration in the debugger. IOCON register view.

View solution in original post

0 Kudos
2 Replies
354 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

From your description, I see that your LED can not work. For the issue, as you know if you want to turn on or turn off a LED, I suppose that you connect the LED to a GPIO pin via a serial resistor. In the case, the pin has to be a output pin instead of an input pin. If the pin is in input mode, the input impedance is several Mohm level, the pin has not enough driving capability to light a lED. In output mode, the pin has several mA driving capability, so the output mode of GPIO pin is required.

This is a procedure to configure a GPIO pin as output mode.

1)enable gated clock for the IOCON and the GPIO group

Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON);

use the similar line to enable the GPIO group gated clock

2)configure the pin as GPIO function

Chip_IOCON_PinMuxSet(LPC_IOCON, 0, LED pin, IOCON_FUNC0 | IOCON_MODE_PULLDOWN);

pls add a option to select digital mode for the above line

 

3)configure the pin as GPIO output mode instead of input mode

Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, LED pin);

 4)toggle the LED pin

BLUE_LED_ON();

 delay()(

BLUE_LED_OFF();

delay()

 

Hope it can help you

BR

XiangJun Rong

0 Kudos
360 Views
chrispflieger
Contributor IV

Wouldn't you know that after a week pulling out my hair, I'd figure it out thirty seconds after begging for help?

 

IOCON_DIGMODE_EN

 

Interestingly, that doesn't show up as a configuration in the debugger. IOCON register view.

0 Kudos