This document describes how to build a simple ADC using the STM8L101xx comparator.
The document details a method for creating an analog-to-digital converter (ADC) by utilizing the internal zero-crossing comparators found in the STM8L101xx family. This approach requires only one external resistor and one capacitor to generate a reference voltage, simplifying the hardware design significantly compared to traditional ADC implementations.
The guide covers both hardware configuration and software implementation. It explains how to connect the comparator inputs to measure an analog signal against an exponentially charging capacitor voltage. The provided software uses Timer 2 to generate a PWM signal for charging the capacitor and interrupts to capture the time when the input voltage exceeds the reference, calculating the digital value based on the RC charge equation.
The method requires a minimum of one resistor and one capacitor.
The demonstration uses a resistor of 10 kΩ and a capacitor of 100 nF.