12.4 Initialization and Configuration
The following example shows how to configure an analog comparator to read back its output value from an internal register.
- Enable the analog comparator clock by writing a value of 0x0000.0001 to the RCGCACMP register in the System Control module (see Section 4.2.98).
- Enable the clock to the appropriate GPIO modules using the RCGCGPIO register (see Section 4.2.87). To find out which GPIO ports to enable, see the device-specific data sheet.
- Enable the GPIO port and pin (in the GPIO module) associated with the input signals as GPIO inputs. To determine which GPIO to configure, see the device-specific data sheet.
- Configure the PMCn fields in the GPIOPCTL register to assign the analog comparator output signals to the appropriate pins (see Section 17.5.22 and the device-specific data sheet).
- Configure the internal voltage reference to 1.65 V by writing the ACREFCTL register with the value 0x0000.030C.
- Configure the comparator to use the internal voltage reference and to not invert the output by writing the ACCTLn register with the value of 0x0000.040C.
- Delay for 10 µs.
- Read the comparator output value by reading the OVAL value of the ACSTATn register.
- Change the level of the comparator negative input signal C- to see the OVAL value change.