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.