Greetings,
I am working on a design that requires my ATMEGA 328p to sleep and wake-up from a 3-axis analog accelerometer. I am reading over the datasheet for the AVR and believe the Analog Input Comparator would be suitable for this.
On page 246 of the datasheet it says:
It is possible to select any of the ADC7..0 pins to replace the negative input to the Analog Comparator.
The ADC multiplexer is used to select this input, and consequently, the ADC must be
switched off to utilize this feature. If the Analog Comparator Multiplexer Enable bit (ACME in
ADCSRB) is set and the ADC is switched off (ADEN in ADCSRA is zero), MUX2..0 in ADMUX
select the input pin to replace the negative input to the Analog Comparator, as shown in Table
22-1. If ACME is cleared or ADEN is set, AIN1 is applied to the negative input to the Analog
Comparator
In my case I would like to use ADC0 for testing the X-axis input. According to Table 22-1 ADC0 requires ACME = 1, ADEN = 0.
What other setup is necessary to configure the Analog Comparator?
I want to setup the Analog Comparator, then the AVR sleep and power libraries to put the controller asleep. If possible the Analog Comparator can keep running and bring the controller back to life when the accelerometer threshold is met. For now I am simply using a potentiometer instead.
I will provide code samples as I am working on the project.
If there is any helpful examples of sleeping/waking up the 328p or other AVR chips it would be much appreciated.