I am new to NXP and there is something I want to do and I don't understand how to do it.
I have a product running on a 3 volts battery. There is a voltage divider on the battery that connects to pin PIO_0/ACMP_I1. I need to monitor this voltage, and when it goes under a certain threshold, set a flag to indicate it is time to change the battery. I went through the datasheet and I don't understand what I should do. Can someone please give me a quick overview of what I should do?
I would start with the example project (periph_acmp) in the LPCOpen library for the LPC812:
With the LPC1518 I used the ACMP interrupt to trigger a handler. If you are using the LPCOpen library functions, which I highly recommend, it should be fairly straight forward (but not simple) using the sample. The key is to know your compare reference and how to scale your threshold. Once you have your polarity, scaling and threshold set you enable the interrupt and let your implemented IRQ handler set your flags, etc.
FYI, since you reference you are using a 3.0V battery I assume you will be sensitive to power consumption. Only power up the compare channel you want to use. In the Chip_ACMP_Init( LPC_CMP ) call on the LPC1518 it will enable all of the channels wasting some power. Again, use the LPCOpen library code as an example and implement for precise control.