UPDI pin as an analog input

Go To Last Post
63 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a need to use the UPDI pin and an analog input (limited by the number of external wires available). The sketch I am using works perfectly on a Nano, Uno and Mega2560 but when I run it on a tiny3217 the OLED display doesn't start to display anything until the input on the UPDI pin is ~3V, then it is fine and will work across the full range of analog input voltages.

 

Is there something I need to do to "disable" the UPDI pin and make it a full analog input? If I do can it still be reprogrammed afterwards?

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


How is the UPDI pin configured in the fuses? If it's configured as a reset pin then of course it need to be high or the chip is in reset.

 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

I have a need to use the UPDI pin and an analog input

Life is much easier if you just select a micro with enough I/O pins to meet your needs, and leave the programming pin ( s ) alone.

 

The rules change when you need to manufacture 1000's of your board, but until then when fight with the micro every time you need to reprogram it while you develop your code?

 

There are several techniques for combining several functions into one I/O pin.

If you post a schematic, or a block diagram showing the inputs and outputs, people might have some suggestions for you so that you don't need to use the UPDI pin if you have decided that you absolutely must use that micro.

 

JC

 

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

DocJC wrote:

I have a need to use the UPDI pin and an analog input

Life is much easier if you just select a micro with enough I/O pins to meet your needs, and leave the programming pin ( s ) alone.

 

The rules change when you need to manufacture 1000's of your board, but until then when fight with the micro every time you need to reprogram it while you develop your code?

 

There are several techniques for combining several functions into one I/O pin.

If you post a schematic, or a block diagram showing the inputs and outputs, people might have some suggestions for you so that you don't need to use the UPDI pin if you have decided that you absolutely must use that micro.

 

JC

 

 

It is not the chips pins that are the problem. It is the pins to the outside world. I only have 4 pins total, 12V, GND, analog in (UPDI) and digital out.

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

js wrote:

How is the UPDI pin configured in the fuses? If it's configured as a reset pin then of course it need to be high or the chip is in reset.

 

 

Nice one. Is this from the Atmel studio 7? Unfortunately I use Linux and Arduino ISP. 

 

How do I set that to GPIO using C++?

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

I think you need to use a programmer, don't know if you can do it with code like other fuses...but I don't really know...smiley

 

Also you may need to use 12V?? if you enable the pin for GPIO but again I don't really know, haven't used them new chippies, I'll have a quick look at the data sheet again to see if it spreads any light.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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


This what I get when trying to change the pin to GPIO mode as I suspected (I'm just using the simulator, don't know if I have a board with the real chip)

 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Ok.

 

Well i am currently using Nano with the jtag2updi code installed. I am going to have to have a play me thinks.

 

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

Consider the UPDI pin as dedicated, just like the VDD and GND pins.

The truth is more important than the facts.

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

poftamunk wrote:

Consider the UPDI pin as dedicated, just like the VDD and GND pins.

 

Consider reading my requirements.

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

By default, the avr0/1 tiny's will have the fuse RSTPINCFG set to UPDI mode. You can switch to the other modes- GPIO/RESET, but once set to either you now need 12v to override the pin and 'force' the UPDI to start. You don't say it, but I would suspect you can no longer program the tiny either. The programmer you use 'most likely' has no protection (such as  shown in post #7), so will let you program that fuse bit without warning. If you already programmed the fuses incorrectly, and your RSTPINCFG is now in RESET mode, you are stuck there until you find a way to restore it (using 12v to override, see datasheet).

 

You will know soon enough if that is the case, as you  will no longer be able to program the tiny.

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

the OLED display doesn't start to display anything until the input on the UPDI pin is ~3

What does display anything mean?  The display is off/blank?  Are other parts of the system running normally when the display is blank? There is even a chance it is some code problem, though it sounds like it probably is held in reset (iunless other stuf iss seen to be running).

 

if you shut off UPDI:

an external programmer capable of 12V UPDI activation will be required.

 

On low pin count AVR devices with UPDI, the UPDI pin can be configured as General Purpose Input/Output (GPIO) or RESET by configuring the RSTPINCFG configuration bits. In order to do further programming, the MPLAB PICkit 4 will have to use a high voltage pulse to reactivate the UPDI interface. When using the high voltage pulse, you must make sure that all circuits connected to the UPDI wire can tolerate a pulse of at least 12 V.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Mon. Aug 31, 2020 - 07:42 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just for now would it be possible to apply a 12v pulse then plug in the programmer?

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

Look at the data sheet 33.3.2.1.3 UPDI Enable with High-Voltage Override of RESET Pin
 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Yes, I saw that. I mean using a wire from the input power (12V) and then connecting the programmer or does it have to come from the programmer?

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

Yes, I saw that. I mean using a wire from the input power (12V) and then connecting the programmer or does it have to come from the programmer?

You might take a look here if you are thinking of becoming a member of the 12V overriding gang:

https://github.com/MCUdude/microUPDI/issues/3

 

Be sure to get some insulated gloves before you head out.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Hehehe i will have a read.

Last Edited: Tue. Sep 1, 2020 - 08:35 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Thanks. I found those last night. I will probably order one today.

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

There is a dire warning of 13V maximum on that pin, so make sure the supply is well regulated.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:
There is a dire warning of 13V maximum on that pin, so make sure the supply is well regulated.

 

Yes, but the UPDI doesn't really need 12V to be enabled. The datasheet doesn't clarify this but rumor has it that the real threshold is around 2x VDD.

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

For some reason I can't purchase the dlloyd version. Won't ship to Oz.

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

They closed to border to QLD?? devil

 

EDIT So they show the price in AU$ but not shipping here?? I'm sure someone in Canada or the US can buy it for you and send it over......not that I have ever done something under handed like that.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

Last Edited: Tue. Sep 1, 2020 - 11:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I ordered the MCUdude one instead. Means I have to buy a Pro Micro as well.

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

Magically they are now shipping to Oz. 

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

I put one in my cart but the system deleted it....maybe they think they have a big market here and fixed the shipping. laugh

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

That happened to me too the first time but I received an email saying they now ship to Oz.

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

Is there a way to set the UPDI pin to GPIO in code?

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

Is there a way to set the UPDI pin to GPIO in code?

will have the fuse RSTPINCFG set to UPDI mode ...nope

 

By the way, something is wrong with your postings...they are all getting messed up with a bunch of blank lines in the lower area

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Wed. Sep 2, 2020 - 06:24 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


avrcandies wrote:

By the way, something is wrong with your postings...they are all getting messed up with a bunch of blank lines in the lower area

There are no blank lines, the height of that DIV is determined by the avatar area:

 

You only notice it perhaps because of the brevity of the replies.

 

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

You only notice it perhaps because of the brevity of the replies.

Ah yes, ...not sure why it suddenly seemed so offbeat! 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Yes, I saw that. I mean using a wire from the input power (12V) and then connecting the programmer or does it have to come from the programmer?

Yeah that worked fine for me back when I was playing around with it (I had a pickit 4 which did 12V for PICs but Microchip hadn't yet built that in for AVRs). You'll basically want to just kind of brush the 12V wire against the UPDI pin connection, give it a very brief pulse not more than a few ms. Needless to say, the AVR needs to have power, the 12V source must share the AVR's ground, and be VERY careful not to touch any of the other pins with the 12V wire.

I seem to remember reading about the HV UPDI entry requirements being made more stringent in later versions of the chips, but I'm not quite sure. 

-Sam

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

samay wrote:

Yes, I saw that. I mean using a wire from the input power (12V) and then connecting the programmer or does it have to come from the programmer?

Yeah that worked fine for me back when I was playing around with it (I had a pickit 4 which did 12V for PICs but Microchip hadn't yet built that in for AVRs). You'll basically want to just kind of brush the 12V wire against the UPDI pin connection, give it a very brief pulse not more than a few ms. Needless to say, the AVR needs to have power, the 12V source must share the AVR's ground, and be VERY careful not to touch any of the other pins with the 12V wire.

I seem to remember reading about the HV UPDI entry requirements being made more stringent in later versions of the chips, but I'm not quite sure. 

 

Yes I read that too. I will have a play later on.

 

I need to get it into GPIO mode first. No idea how to do that yet. I am using Arduino IDE and have not been able to find any settings for fuses.

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

Use a USB-serial adapter and pyupdi, it has an option to write fuses. I've never used the Arduino IDE to program these chips, so I'm clueless in that area.

-Sam

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

>I need to get it into GPIO mode first

 

Either you are confused, or I am. If you can no longer program the 3217 (and the UPDI pin acts as a reset pin), you must have set the FUSE RSTPINCFG value to RESET, then programmed the 3217 (your programmer puts up no warnings, and just does it). The only way to get out of the default RSTPINCFG/UPDI mode is by setting the fuse values and programming, which you seem to have done. OR you can still program the 3217 and there is no need to deal with 12v.

 

Which is it?

 

If you can no longer program because you set the fuses wrong, you cannot  set any fuses or do any programming until you get 12v programming working. If you can still program, why are you looking for a way to lock yourself out by setting the updi pin to GPIO?

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

I guess (s)he's doing some research early. 

From what I understood, the UPDI pin is required to be used as an IO in his project because of constraints related to pins available externally.

-Sam

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

>I guess (s)he's doing some research early. 

 

It seems a lot of reading between the lines is needed. Looking at a 3217 datasheet- AIN0 is what you can get when switching to GPIO mode for the updi pin, and that is probably what is wanted. Maybe he is still in UPDI mode, who knows (if can program without 12v, then still is). It also may be the adc is perfectly happy to use the AIN0 pin whatever mode you are in (all analog pins routed to adc mux regardless), but the analog input is dealing with the UPDI pullup so may depend on how strong the analog signal is.

 

So maybe some simple questions-

can you still program the 3217?

have you changed or set the FUSES array?

are you using AIN0?

 

Switching to GPIO mode is easy enough via FUSES array, but then programming requires the 12v so better have that sorted out before.

 

I do have a tiny3217 curiosity nano board, and could see how AIN0 acts.

Last Edited: Thu. Sep 3, 2020 - 10:07 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

curtvm wrote:

>I guess (s)he's doing some research early. 

 

It seems a lot of reading between the lines is needed. Looking at a 3217 datasheet- AIN0 is what you can get when switching to GPIO mode for the updi pin, and that is probably what is wanted. Maybe he is still in UPDI mode, who knows (if can program without 12v, then still is). It also may be the adc is perfectly happy to use the AIN0 pin whatever mode you are in (all analog pins routed to adc mux regardless), but the analog input is dealing with the UPDI pullup so may depend on how strong the analog signal is.

 

So maybe some simple questions-

can you still program the 3217?

have you changed or set the FUSES array?

are you using AIN0?

 

Switching to GPIO mode is easy enough via FUSES array, but then programming requires the 12v so better have that sorted out before.

 

I do have a tiny3217 curiosity nano board, and could see how AIN0 acts.

 

Ok. Some clarification.

 

1.   I have to use that pin as I have minimal external pins. 12V, Gnd, Analog in and Digital out.

 

2.   Yes I can still program. Not game to change it until I get a new programmer.

 

3.   While in UPDI mode the analog in is not working 100%. It doesn't start working until the input reaches about 3V. I am assuming that once in GPIO mode it will work fine.

 

I have a few other issues I need to fix so I will wait till the programmers arrive before setting fuses. Although I have a few these breakout boards so I might risk it on one of them to prove the Analog in will work properly.

 

PS. Thanks everyone for your help.

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

windoze_killa wrote:
3.   While in UPDI mode the analog in is not working 100%. It doesn't start working until the input reaches about 3V. I am assuming that once in GPIO mode it will work fine.

 

Yeah, not surprising. For digital input it doesn't make that much difference that the UPDI unit has partial control of the pin, but for analog it's a different story. The UPDI can decide to turn on the pin pull-up and that will mess an analog signal.

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

El Tangas wrote:

windoze_killa wrote:
3.   While in UPDI mode the analog in is not working 100%. It doesn't start working until the input reaches about 3V. I am assuming that once in GPIO mode it will work fine.

 

Yeah, not surprising. For digital input it doesn't make that much difference that the UPDI unit has partial control of the pin, but for analog it's a different story. The UPDI can decide to turn on the pin pull-up and that will mess an analog signal.

 

Once the 3V has been reached it works fine going back towards 0V. It is just the initial detection of the input voltage.

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

>While in UPDI mode the analog in is not working 100%. It doesn't start working until the input reaches about 3V. I am assuming that once in GPIO mode it will work fine.

 

You are simply dealing with the updi pullup, it would seem. I tested the 3217 and AIN0 works ok but you have to deal with the ~20k pullup in some way. If you will have 12v programming ability, then you can eliminate the pullup.

 

>I need to get it into GPIO mode first. No idea how to do that yet. I am using Arduino IDE 

 

I don't use arduino, but I would assume even if it doesn't want to deal with the FUSES array for some reason, coming up with a 9 byte hex record for your programmer would not be too difficult and only needs to be done once.

 

Here is a default tiny3217, with the RSTPINCFG set to GPIO (default F6 -> F2)

:02000004008278
:090000000000020000F2070000FC
:00000001FF

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

That second bit has gone over my head. I am on a steep learning curve but thats a cliff face.

 

I will get there in the end.

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

>:09 0000 00 00 00 02 00 00 F2 07 00 00 FC

             |---                   ---|

 

You 'should' be able to put this in your code-

FUSES = {0,0,2,0,0,0xf2,7,0,0};

and you will then get the fuse section programmed by the programmer.

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

Now that would make it easy. Thank you.

 

I will try it on the weekend and waste a board although I should get it back when the programmers arrive.

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

Do you have a good solid analog signal going to the pin?  Like the output from an opamp?  It seems like it would work regardless, then.  Where is your schematic?

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

avrcandies wrote:

Do you have a good solid analog signal going to the pin?  Like the output from an opamp?  It seems like it would work regardless, then.  Where is your schematic?

 

Yes it is a solid analog signal. 5V via a pot.

 

Schematic is in my head at the moment.

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

Yes it is a solid analog signal. 5V via a pot.

No, that doesn't qualify as a 'solid signal'.

 

The voltage on the pot's wiper terminal is influenced by the load to which it is connected.

The load to which it is connected essentially forms a voltage divider, and therefore changes the wiper terminal's voltage.

For example if one had a 10 K (linear) pot and the wiper was set at 1/2 way position, and was not connected to anything else, then the output voltage would be 1/2 of the voltage across the pot, (assuming for now that one terminal is connected to V+ and the other terminal is connected to ground).

Now connect a 10K "pull-up" resistor from the pot's wiper terminal to V+, (an to the input to a pin on the micro).

The top half of the pot, (5K), and the pull-up resistor, (10K), are now in parallel.

The "top half" of the circuit, above the wiper terminal, is now 3.3 K.

The bottom half remains 5K.

So the wiper is no longer "in the middle" of the circuit, and the output voltage will be above 1/2 of the supply voltage.

The calculation of the new output voltage is left as an exercise...

 

A 'solid signal', such as that provided by the output of an op-amp, will hold the terminal at expected voltage, (within the limits of the op-amp).

As the load changes, (say due to a pull-up resistor, the op-amp adjusts for the change in the load and keeps the output voltage where it should be.

 

JC

 

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

Yes I know all that. I have been a technician/engineer for over 40 years, just very little software experience. This is why I want set the pin to GPIO so I can lose the pullup.

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

DocJC wrote:
... such as that provided by the output of an op-amp, ...
High source resistance will affect the output of the sample&hold; compensated by increasing the sampling duration (a feature of XMEGA E whereas XMEGA can disable discharge of the sampling capacitor; a feature of AVR Dx ADC and AVR DD may be the follow-on to tinyAVR 0,1, and 2)

 

ATtiny3216/3217

[search for SAMPLEN]

[bottom of page 431]

...

This [SAMPDLY, SAMPLEN] allows sampling of high-impedance sources without relaxing conversion speed.

...

via ATTINY3217 - 8-bit AVR Microcontrollers

 

Configure the ADC | Differential ADC Using the AVR128DA48 Curiosity Nano

[mid-page]

 

Figure 2. ADC0 Hardware Settings

 

https://www.avrfreaks.net/forum/what-are-avr28da128-avr32da128-avr48da128-avr64da128?page=2#comment-2987491

 

"Dare to be naïve." - Buckminster Fuller

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

windoze_killa wrote:
Yes I know all that. I have been a technician/engineer for over 40 years, just very little software experience

in that case you have my permission to shoot your self in the foot, it will only hurt for awhile but you will learn a lot.

Good luck with your project.

 

jim

another 40 yr T/E

 

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

ki0bk wrote:

windoze_killa wrote:
Yes I know all that. I have been a technician/engineer for over 40 years, just very little software experience

in that case you have my permission to shoot your self in the foot, it will only hurt for awhile but you will learn a lot.

Good luck with your project.

 

jim

another 40 yr T/E

 

 

 

Now is that a bit of a dig??

Pages