Comparator inputs

I ran into some trouble recently trying to connect a TI LMT01 temperature sensor to the internal comparator of the UNO R3 ATmega328p. Even with the ACSR properly set up, the sensor would simply not trigger the interrupt from the sensor’s falling edges. While researching the issue, I found this page which suggested connecting the sensor outputs to D7 instead of A1 like i originally did, which solved the issue.

My question is, why D7 instead of A1? Referring to the image attached, the ACSR controls only inputs between A1 and A0 (Of which A0 is connected to the reference voltage), how does D7 factor into this? And why will A1 not work?

ACSR.png

Post your code?

Did you read this note in the datasheet?

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 20-1. If ACME is cleared or ADEN is set, AIN1 is applied to the negative input to the Analog Comparator

D7 is AIN1, so this makes sense. My guess is you left the ADC enabled, so it wasn't able to use the ADC mux for the negative input and fell back to using AIN1.

Hi, thanks for the reply. I don't think that was mentioned in the data sheet I referred to, can you link to where you found that? (Mine is here)

Attached is my code below, you're right, i did not disable ACME, i didn't even know it existed!

*EDIT: I read that ADEN defaults to zero in ADCSRA, shouldn't that be a non-issue then?

volatile int pulseCount=0;
float temp = 0;
int hold = 0;

void setup() {
  ACSR = B01011010;
  Serial.begin(9600);
}

void loop() {
  if (pulseCount != hold){
    while(pulseCount !=hold){
      hold=pulseCount;
      delay(1);
    }
    temp = 0.0625*pulseCount-50;
    Serial.println(temp);
    pulseCount = 0;
  }
  delay(2);
}

ISR(ANALOG_COMP_vect)
{
  pulseCount+=1;

}