SAMD21 ADC issue with external reference

Hello Everyone,

I am working on SAMD21G18A controller. I am using an external reference of 2.5V on AREFA pin (PA03
). The pins used are as follows :-

PA03 - AREFA = 2.5V
PA02 - ADC_IN_1
PA05 - ADC_IN_2
PA04 - Digital_Output_1
PA06 - Digital_Output_2

I am selecting external reference voltage of 2.5V for my ADC_REF and continuously reading both adc input pins with a delay. Both Digital outputs are connected to transistors to drive the opto-isolator IC. When both outputs are High my analogread function stucks and CPU goes to halt.

Digital Outputs ADC raw counts Status
DO_1 DO_2 ADC_1 ADC_2

LOW LOW 8 10 OK

HIGH LOW 46 48 OK

LOW HIGH 47 46 OK

HIGH HIGH - - ADC read stucks (analogread function)

But when i use the internal reference it works in all conditions. Any suggestion would be helpful.

Thanks
Sibin.

Post your complete code, a wiring schematic of your circuit, What your expectation of "works" means and what it's actual behavior is.