Hi,
As you know that the LPC804 has ACMP module, and the ACMP input pin is multiplexed with GPIO. for example, PIO0_14/ACMP_I3/ADC_2, the pin can function as GPIO pin and ACMP_IN3 pin.
you connect a capacitor to the PIO0_4 pin, when the pin is configured as ACMP_IN3 function, the pin has high impedance, you can use a current source to charge the capacitor, when it is above a threshold which is programmable, the ACMP_OUT will become high and can trigger an interrupt.
If you want to discharge the capacitor, you can configure the pin as PIO0_4 and configure the pin as GPIO output and output LOW logic, which can sink the charge via a current limited resistor.
It appears you program with Arduino platform, unfortunately, I am not familiar with the platform.
You can use the code to configure the PIO0_14 as GPIO output
#define BOARD_LED_RED_POR 0
#define BOARD_LED_RED_PIN 4
void BOARD_InitPins(void)
{
/* Enables the clock for the GPIO0 module */
CLOCK_EnableClock(kCLOCK_Gpio0);
gpio_pin_config_t LED_RED_config = {
.pinDirection = kGPIO_DigitalOutput,
.outputLogic = 0U,
};
CLOCK_EnableClock(kCLOCK_Swm);
SWM_SetFixedPinSelect(SWM0, SWM_PINENABLE0_ACMP_I3_MASK, false);
/* Initialize GPIO functionality on pin PIO0_13 (pin 4) */
GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_PORT, BOARD_LED_RED_PIN, &LED_RED_config);
}
You can configure the pin as ACMP_IN3
void pinInit()
{
CLOCK_EnableClock(kCLOCK_Swm);
SWM_SetFixedPinSelect(SWM0, SWM_PINENABLE0_ACMP_I3_MASK, true);
}
You can download SDK from the link:
https://mcuxpresso.nxp.com/en/welcome
You can use MCUXPresso tools to compile/debug
Hope it can help you
BR
XiangJun Rong