Internal pullup resistors are enabled on analog input ports...

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

....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?

 

-Thank you,

Hugh

 

 

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?"

Attachment(s): 

This topic has a solution.

Hugh Vartanian
EE Consultant

Last Edited: Wed. Oct 7, 2020 - 02:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

11. Parallel Input/Output (PIO)

11.1 PIO Line Configuration for AFEC and DACC Analog Inputs

Analog inputs, AFE_ADx or AFE_DACx, may not properly enable when internal pull-up or pull-down resistors are enabled.

 

Workaround

Disable the internal pull-up or pull-down resistors by writing a '1' to the PIO_PUDR or PIO_PPDDR for the port pins where analog inputs are needed.

This errata sounds relevant, i.e., disable pull-ups/pull-downs before enabling analog functions.

/Lars

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Lars,

 

Thanks so much for the pointer to the errata.  While we were able to enable the analog inputs with (through the vaguaries of the chip internals) the pullups enabled, they were indeed enabled as described in the original post.  In the end, we needed to set the ports as digital, disable the pullups, and then enable them as analog.  Bob, Software_Dude, will post the details of how he did this in the code generated by the pin configurator.  Above my pay grade to get into that!  Anyway, thanks again for the data in the eratta sheet.  And the reminder for us to check there in the future!

 

He is building a list of issues we have encountered with the pin configuration tool  Stay tuned for that!

 

Problem fixed!

 

Best,

Hugh

Hugh Vartanian
EE Consultant

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

HughV wrote:
Problem fixed!

Jolly good - thanks for feeding back.

 

Now please mark the solution - see Tip #5 in my signature, below, for instructions:

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I modified the startup code generated by Atmel Start to patch for this Chip Errata.

In driver_init.c I added code right after the clock initialization but before the GPIO initialization a call to DisableAdcPullups().

 

This turns off the pullups, which are supposed to be disabled automatically when Analog mode is selected for the pin.  This fixed the problem we were seeing.  Of course, this is another manual modification I need to make each time I run Atmel Start because it will overwrite this change to driver_init.c

 

 DisableAdcPullups()
{{
    gpio_set_pin_pull_mode(ADC0_1, GPIO_PULL_OFF);
    gpio_set_pin_pull_mode(ADC0_3, GPIO_PULL_OFF);
    gpio_set_pin_pull_mode(ADC0_6, GPIO_PULL_OFF);
    gpio_set_pin_pull_mode(ADC0_7, GPIO_PULL_OFF);
    gpio_set_pin_pull_mode(ADC0_8, GPIO_PULL_OFF);
    gpio_set_pin_pull_mode(ADC0_9, GPIO_PULL_OFF);
    gpio_set_pin_pull_mode(ADC0_10, GPIO_PULL_OFF);

}