Can I re-purpose AREF to get another analog input?

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
JamieRI
 
Posts: 2
Joined: Mon Mar 06, 2023 6:15 pm

Can I re-purpose AREF to get another analog input?

Post by JamieRI »

I need another analog input... I am using the M4 Feather and it seems possible based on schematic and the chip ADC and DAC reference selection capability.

Can I cut the AREF trace from V3.3 trace
schematic cut AREF.png
schematic cut AREF.png (49.2 KiB) Viewed 81 times
and set the REFCTRL.REFSEL register to 0x3 to select the VDDANA pin for the ADC (is routed to 3.3 on the board); and set the CTRLB.REFSEL register to 0x1 for the DAC?
refsel register.png
refsel register.png (215.66 KiB) Viewed 81 times
ctrlb.refsel register.png
ctrlb.refsel register.png (307.42 KiB) Viewed 81 times
(I presume this is being set to AREFA in some Arduino library and needs to be changed in our code? I'm the hardware guy who sometimes writes code...)

This must be legacy... I would think the use of AREF over another analog input is a strange... the board is shorting this trace to V3.3. Are there software library risks to doing this?

thanks Jamie Murdock

https://learn.adafruit.com/adafruit-fea ... an-express

User avatar
TI545
 
Posts: 98
Joined: Tue Feb 27, 2018 5:25 pm

Re: Can I re-purpose AREF to get another analog input?

Post by TI545 »

That is a good question. I don't know enough to say yes, but looking at what you have pointed out, it makes sense. Obviously, an AREF pin has to read voltage in order to be a voltage reference. Making the cut you show would let the voltage float. But you'd need to find a way to read the AREF. And without an AREF, what do you compare your analog in voltages to?

User avatar
JamieRI
 
Posts: 2
Joined: Mon Mar 06, 2023 6:15 pm

Re: Can I re-purpose AREF to get another analog input?

Post by JamieRI »

re: "But you'd need to find a way to read the AREF." actually not, that is the purpose of changing the REFSEL register values I pointed out.

I did find in wiring_analog.c called by TrueRMS.ino the following feature:

#define ADC_REFCTRL_REFSEL_INTVCC1_Val _U_(0x3) /**< \brief (ADC_REFCTRL) VDDANA */
and in the code a switch on "mode":
case AR_DEFAULT:
default:
//ADC0->INPUTCTRL.bit.GAIN = ADC_INPUTCTRL_GAIN_DIV2_Val;
ADC0->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC1_Val; // VDDANA = 3V3
ADC1->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC1_Val; //
break;

I did not find a similar REFSEL for the DAC in that code, however.

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”