I have stucked and need help.
I've tried to make a simple project with analog input but I can't even catch an interrupt from analog pin A2.
I need to trigger some procedure then A2 voltage goes below 1.1 volt. So I've wrote this code in setup procedure:
ACSR = 0b01001110; // ACD=0, ACBG=1, ACO=0, ACI=0, ACIE=1, ACIC=1 and select falling edge
DIDR1 |= (1<< AIN0D);
DIDR1 |= (1<< AIN1D);
ADCSRB |= (1<<ACME); //ACME (connect to analog input)
ADCSRA |= (0<<ADEN); //ADEN (disable converter)
//select A2 as input pin
ADMUX |= (0<<MUX2);
ADMUX |= (1<<MUX1);
ADMUX |= (0<<MUX0);
and then I added interrupt procedure:
ISR(ANALOG_COMP_vect){
Serial.println("This is an analog interrupt!");
}
but ISR procedure not run at all.
What is wrong with this code?