Comparator with Hysteresis: In this design, the 5-V VDD supply input is used as the reference. The high threshold value for the comparator is set to is set to 3V using the DAC_MARGIN_HIGH register, and the low threshold is set to 1V using the DAC_MARGIN_LOW register. The codes programmed to these registers, in decimal, is calculated using:With a 5-V reference, unity gain, and threshold values of 3V and 1V, the equation becomes:
This is rounded to 614d and 205d to give a high threshold of 2.998V and low threshold of 1V.