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
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?
(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
Can I re-purpose AREF to get another analog input?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- JamieRI
- Posts: 2
- Joined: Mon Mar 06, 2023 6:15 pm
- TI545
- Posts: 98
- Joined: Tue Feb 27, 2018 5:25 pm
Re: Can I re-purpose AREF to get another analog input?
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?
- JamieRI
- Posts: 2
- Joined: Mon Mar 06, 2023 6:15 pm
Re: Can I re-purpose AREF to get another analog input?
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.
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.
Please be positive and constructive with your questions and comments.