A1, A3 analog pins for interrupts on due not working but others are

I have some encoders that I need to use on the analog pins of the due. Encoder1 is attached to A1, A3 (pins 55 and 57) and encoder2 is attached to A6 and A8 (pins 60 and 62). I am using an arduino due

While encoder2 works fine, encoder1 does not. I checked the pins with an oscilloscope and it gets the pulses just fine, I believe the only remaining thing that would cause it not to work is if A1 and A3 were not capable of interrupts. According to that attachInterrupts page, it doesn't say if any of the analog pins can use interrupts (even if being used as digital pins), but I'm not sure why this would work for encoder2 only. I have also tried the format:

attachInterrupt( digitalPinToInterrupt(pin) );

I have the same results with other encoder libraries.
I am using the quadrature.h library. Here is a snippit of the code it sets up the interrupts

template<int A, int B>
inline
void Quadrature_encoder<A, B>::begin()
{
	    //store the starting state for the two interrupt pins
		if(b == Board::uno) {
			if (A_pin == 0) {
				pin_A_digital = 2;
				pin_B_digital = 3;
			} else {
				pin_A_digital = 3;
				pin_B_digital = 2;
			}
		}
		if(b == Board::due) {
			pin_A_digital = A_pin;
			pin_B_digital = B_pin;
		}
		
		/*
			TODO: Add mega support
		*/
		
	    pinMode(pin_A_digital, INPUT);
	    pinMode(pin_B_digital, INPUT);
    
	    Enc_A = digitalRead(pin_A_digital);
	    Enc_B = digitalRead(pin_B_digital);
    
	    //configure the interrupts
		attachInterrupt(A_pin, &Quadrature_encoder<A,B>::delta_A, CHANGE);
		attachInterrupt(B_pin, &Quadrature_encoder<A,B>::delta_B, CHANGE);
    }

According to the datasheet all pins are capable of interrupts.

As you didn't post your code we cannot check if you use the library correctly.

There is no error in the code as I have it working for the other encoders simply by changing the pin numbers

If there's no error in the code the error must be in the hardware. If you're also sure that there is no error in the hardware, why are you asking for help here?
The SAM3X of the Due is capable of interrupts for all it's IO pins. Did you check if you fried your pins?

I'm asking for other considerations that could make it not work that I might not be aware of. How would I check if I fried the pins?

If you configure the pins as simple inputs do you get the correct value in the code if you connect the pin to 3V3 or GND?

If this works, post complete code that shows the problem.

Thank you for your help, after doing this I found there was a loose connection in one of the header pins, the spring is no longer springy and hence it wasnt reading the value. I now have everything working.
To conclude, it was not an error with the analog pins or code but with a connection in my set up.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.