....but not all of them.
Hi, Hugh here, hardware guy working on a new board design with a SAMV71.
1. We have a bunch of power supply monitors with relatively large resistors (10's of K, 100K, etc.) used as voltage dividers to get into the 0-3V analog input range on a number of ADC0 and ADC1 input pins.
2. One input, reading 12V, has a 120K/30K divider, reads correctly (2.39V read, 11.93 scaled, 2.388 with meter on the pin). Another input, on the analog 12V supply, has the same divider, but reads high (2.53V read, 12.66 scaled, 2.536 with meter on the pin). The ADC is reading the pins correctly, matching the meter.
3. There are a bunch of other pins similarly reading high. I did an experiment where I added 3 different resistors in parallel with the low side of the divider on the good and several bad reading inputs, read the voltage, modeled the circuit and calculated the value of the internal resistor from all that.
4. Assuming there is an internal pullup to 3.3V, the calculations result, consistently, in a value of pullup resistor in the processor of 110-120K ohms. They match closely for each input with different resistors, and pretty close between different inputs. Look at the attached excel sheet for the highlighted values if you like. Note that the input that does not read incorrectly comes up with a pullup resistor of negative a zillion ohms.
5. We used the debugger to look at the pullup enable status registers and mostly found 0's (indicating enabled pullups), even on the correctly reading input, and a 1 for the pullup bit on a pin that reads high. No correlation with the state of the bit read in the register to the apparent pullups on the inputs.
6. We then tried writing the pullup enable and pullup disable registers. These seem to toggle the status bits correctly, however there is no change in the input pin behavior. i.e. we could not disable the apparently connected internal pullups. Nor could we enable the one on the correctly reading pin.
7. We didn't really expect to see anything sensible in items 5&6 above because the pullups are supposed to be disconnected on the pins set up as analog inputs.
8. The input impedance specifications for the analog inputs are in the megohms, iirc, and are not consistent with these readings. Particularly interesting that one pin reads correctly.
9. We are using the 144 pin part. The input that reads correctly is Pin 21/PB0/ADC0-10. Some of the ones reading incorrectly are: Pin 32/PA21/ADC0-1, Pin28/PE5/ADC0-3, pin 19/PC13/ADC1-1, pin 25.
10. This all distills to the question: How is it possible that the pullup resistors are enabled on the analog inputs? Any ideas as to how to disable them? Is this maybe an order of pin programming by the startup code? Is it possible that this is an Atmel Start configurator issue?
The original post by my software sidekick, CPU-Dude, for reference: "Can Pullups be enabled on analog input pins?" (Hugh: not really the correct question; more aptly described as "How is it possible that the pullups are enabled on analog input pins?"
"I would think that pull-ups / pulldown resistors are disabled (SAMV71, ASF4) when an Analog function is selected for an ADC pin. However, I can’t find anything in the data sheet that says that. And I want them off.
I have an analog input pin with a voltage divider (100k, 100k) on the input so with a 3.3Volt input I would expect to see 1.65 volts coming to the ADC. I read 2.14 Volts. A Voltmeter confirms that there is 2.14V on the divider. There resistors appear to be correct.
The HW engineer believes that there is an internal pullup on the ADC internally causing the voltage change. I would think that pull-ups are disabled when Analog mode is selected. But I can’t find confirmation in the V71 datasheet.
Atmel Start does not have any way to select a pullup on an analog pin. I can’t find any call the PIO_PUER (Pulldown Enable Register) for that pin in the generated startup code. Using my IAR debugger, the PIO_PUSR (Pullup Status Register) is a ‘1’ for that bit, which would indicate pullup is disabled, unless this bit is invalid when in Analog mode.
Can anyone confirm that pull-ups/pulldowns are disabled in Analog mode?"