ATtiny85 pin 1 RESET and PB5 functionality?

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

I want to use an ATtiny85 for an application, but I am an 8-pin-ATtiny-chip newbie.

 

So I am reading the "ATtiny25/V / ATtiny45/V / ATtiny85/V" databook (Rev. 2586Q–AVR–08/2013; which, even though I downloaded it from Microchip, it still says "Atmel" on the front page).

 

I would like to be able to keep pin 1 of the ATtiny85 as a reset pin (with the "reset disable" fuse unprogrammed), so that the device can be re-programmed using ICSP (for firmware upgrades). (IOW I would rather not have to revert to HVSP.) However, my application needs three input pins and three output pins (i.e. it needs all six pins to be used as I/O).

 

I do not think this is a real problem, because the databook section 1.1.4 says:

 

   "The reset pin can also be used as a (weak) I/O pin."

 

I presume this means that, when RESET is not disabled by the fuse settings, the port B bit 5 data direction register can be set as output, although the logic output source/sink currents are more limited (compared to other GPIO pins).  (So the output needs to be buffered for higher current requirements.)

 

Then, for ICSP programming, (I think) I can just hold the pin low while applying Vcc; but for running the application, the firmware can program the pin as output and write logic 0 or 1 signals out to the pin (without causing the device to reset).

 

Am I Correct?

 

But I was also wondering about the 'I' in the above quoted statement from section 1.1.4: "... (weak) I/O pin".  Does this mean that the pin can also be used as a general purpose logic input, even though the reset function is not disabled? How would one do that? (Or is the term "I/O" an error in the databook?) What about the pin's other functions? E.g. can ADC0 or debugWire be used when reset is not disabled by fuse settings?

 

Thanks and best regards,
  DuinoSoar
 

Last Edited: Tue. Jan 15, 2019 - 04:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DuinoSoar wrote:
Am I Correct?
No.

 

The device has a fuse called RSTDISBL. It is when that fuses is activated that the pin changes from being _RESET to being an available IO. But as you have noted, once you use I(C)SP to change the state of that fuse it will be the last ever I(C)SP session you will have with the chip because without _RESET I(C)SP can no longer be done. The only recovery at this stage is High Voltage Serial Programming which involves applying a +12V signal to that pin to allow the device to be put into a programming mode. This is probably fine if the chip can be lifted from the circuit and programmed separately but if it is "in circuit" the chances are that whatever else you have connected to the pin is NOT going to enjoy having +12V shoved in its direction.

 

Suggest you trade up to a 14 pin chip so you can avoid the RSTDISBL nonsense.

 

If you really want to persevere then make sure you have an HVSP programming system available.

 

Alternatively, as one of your very last actions before you turn off ISP you might want to consider putting a bootloader into the t85 so you have an alternative programming mechanism (but this too will involve some "re-use") of other device pins.

Last Edited: Tue. Jan 15, 2019 - 04:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As always, the answer can be found in the datasheet, although on this occasion you do have to work at it.

 

Looking at figure 10-5 and table 10-4 you can work out that RSTDISBL disconnects the output latch from the pin so no output function is possible. And if you try to use it as an input then any low on the pin will reset the chip.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

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

I have an app that uses a T25 where I used the reset pin as an analog input.

I had to make sure this input would never drop below the reset threshold (or the chip would reset) in normal operation, and I had to account for the weak pull up that is also on this pin to compensate for the analog reading I needed.

Bottom line, it worked, and was a successful product!

Pick your pins carefully.

 

Jim

 

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

One possibility is to multiplex both the LEDs and the button inputs.  Two rows and three columns gets you six nodes.  Five pins total.  Three of the nodes can be LEDs, and three can be buttons.

 

Have a look at AVR242 for an understanding of the basic concept (although it will require modification).

 

However, Jim's suggestion will require fewer external components, and is certainly easier to implement in software.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Tue. Jan 15, 2019 - 05:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ATiny Liberation!... Self Replicating Boot Unloader.

https://www.avrfreaks.net/forum/atiny-liberation-self-replicating-boot-unloader

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

Wow, thanks for the replies, folks.

 

Looks like I totally misinterpreted the comment from section 1.1.4, then.

 

@clawson: I knew about the RSTDSBL fuse, but 1.1.4 seemed to imply that I could still use the pin for output.  I guess that the "weak I/O" part means that it will be a weak I/O when RSTDSBL is programmed, and strictly a reset when it is not. I would rather avoid the 14-pin solution, to try to keep the circuit board small. Installing a bootloader might work, but I would somehow have to invoke it and switch two of the GPIO pins to serial Tx/Rx.  (I guess COULD hold one or two of my input signals low during power reset to do that.)

 

@Brian: You're right about the digging; I look at the picture and the table and say to myself, "Huh?" I still don't fully understand the logic there, but I will study it and try to figure it out.

 

@Jim: In my case, the signals are digital logic so that would not really work for me - no analogue signals here.

 

@Joey: If my outputs were for LEDs I could try to come up with some smart "Charlieplexing" scheme but, alas, this is not the case.

 

Thanks folks.  Guess I will just have to go back to the drawing board on this one.  Probably the bootloader solution and disabling the reset pin might be the way to go.

 

Thanks,

  DuinoSoar

 

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

DuinoSoar wrote:
. I would rather avoid the 14-pin solution, to try to keep the circuit board small.

It makes sense to use the bigger chip while the project is in debug mode, where you have more resources to work with, (i/o pins, debugwire, flash size, ram size, etc) once the project is working, port to the smaller package!  This saves a lot of hair pulling and questionable workarounds (how much trouble shooting is involved just to get this workaround working), better to use a larger chip to start with!

Just my experience, and my two cents worth, take it or leave it!

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

DuinoSoar wrote:
Thanks folks. Guess I will just have to go back to the drawing board on this one. Probably the bootloader solution and disabling the reset pin might be the way to go.
Perhaps, but as Jim suggested, using /RESET as an ADC will work without RSTDISBL.

 

The maximum reset threshold is 0.9 VCC, so as long as you stay above that, the AVR won't reset.

 

There is an internal pull-up resistor on /RESET which cannot be disabled without RSTDISBL.  It has a value of between 30K and 60K, which will differ from device to device due to process variation.

 

With the schematic below, the worst case is for the lower value of 30K, so the voltage on /RESET would toggle between (1000/1030)VCC, or 97% of VCC and VCC.  This corresponds to ADC values of 993 and 1023.  Pick a threshold of halfway between that, or 1008.  Anything at or below that, the button is not pressed.  Anything above it, the button is pressed.

 

      VCC            VCC
       |              |
--------------+       |
              |       |
  T85   VCC   |       + |
         |    |         |
        30K   |         |--- button
       pullup |         |
         |    |       + |
         |    |       |
         +----|-------+
              |       |
              |       |
              |       |
              |       |
              |       |
              |       \
              |       /
              |       \ 1M
              |       /
              |       \
              |       |
--------------+       |
      |               |
     GND             GND

 

Unless, of course, your inputs are not buttons.  However, even if they're driven by some other logic device, the same concept will work:

      VCC
       |
--------------+
              |
  T85   VCC   |
         |    |
        30K   |
       pullup |
         |    |
         |    |         1M
         +----|-------\/\/\/----< driven input (swings from GND to VCC)
              |
              |
              |
              |
--------------+
      |
     GND

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Tue. Jan 15, 2019 - 08:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Perhaps all the buttons can be connected to one analog input pin like this:

Jim

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

DuinoSoar wrote:
I would rather avoid the 14-pin solution, to try to keep the circuit board small.

OK, let's peek at that one.  Assuming common surface mount SOIC...

8S2 is 5+mm x 8mm. 8S3 is 6mm x 5mm.

 

Let's find a 14-pin Tiny...say, the x4 series.  8.5+mm x 6mm.

 

So, for you an extra 3mm in one direction will be worth the hassle and expense of juggling the /RESET situation?

 

 

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

I had success with +5v to 1k resistor to  LED to PORTPIN to 220ohm to button Switch to ground.  I use the LED with a toggle function as the output indicator and the switch with a poll function as the input.  The poll function switches the PORTPIN from output low to input and reads the switch.  The 1k resistor/LED provides the pullup. De bounce is a must, of course. This is not a very pretty solution but it can work and only uses 1 pin.   Not sure how to do it in C.  I suggest the 220 ohm resistor for safety but I didn't use it.

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

@Jim and @theusch: Both of your comments about using 14-pin devices have much merit, and I may end up going that route.  But, theusch, I am planning on using a DIP.  I have never done surface mount, and my tired old eyes and hands probably could not do it anyway.  (I have visions of melting the chip package with my soldering pencil! ; )   In any case, I am actually using a Digispark clone board for development - one that happens to have reset enabled on the ATtiny85 pin 1 (the clone board's PB5 pin), so I can use ISP.  But I am having other issues with the clone board.  (Cannot get the USB bootloader to work; it turns out that the Micronucleus bootloader is not even installed! Don't know if that's my fault or the vendor's, but that's a totally different problem and one about which I will be posting another thread probably at the Arduino website.)

 

Anyway, folks, my original question has been answered: when reset is enabled, pin 1 cannot be used as a digital GPIO pin; but there is a solution to INPUT digital signals using the pin's ADC functionality while still having the reset functionality available (by being very careful about voltage levels on the pin when used as input).  So that is probably the solution I will use (when I get around to testing it).

 

Thank you folks for your comments and input.  Much appreciated.

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

DuinoSoar wrote:
But, theusch, I am planning on using a DIP.
DuinoSoar wrote:
I would rather avoid the 14-pin solution, to try to keep the circuit board small.

An oxymoron?

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

DuinoSoar's wrist computer using small DIP devices:

The modern equivalent of a working VAX 11/780:

 

No 'Duino fits the bill, 'Duino?

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

DuinoSoar wrote:
I have never done surface mount, and my tired old eyes and hands probably could not do it anyway.

That is what I thought too a few short years ago, but then learned how to use hot air and will never build with through hole again!

SMD is SO easy to do!  An SMD rework station (small iron + hot air) goes for about $50-$100 on ebay.

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

LOL. Thanks, theusch and Jim.

 

OT:

 

I am actually old enough that I started my programming experience with FORTRAN IV on an IBM 360: keypunches, card readers, and line printers, and had to carry around stacks of cards and reams of paper printouts.  (Then eventually graduated to APL on an IBM Selectric terminal - still had the paper printouts, though.)

 

I have to admit, though, that wrist computer IS getting rather heavy. : D  BTW, I also did FORTRAN on a PDP-11 (the precursor to VAX) using the RT-11 OS (and found a very interesting compiler bug with how subroutine parameters were passed).

 

So, with that kind of history, maybe you guys can better understand my comment about my tired old eyes and shaky old hands.  My pseudonym, DuinoSoar, was chosen very carefully. ; )  And, yes, theusch, sometimes, at my age, I feel as clumsy as an ox and as stupid as a moron. ; )

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

O29 key punch, multi box cobol decks, IBM 1130... RPG, PL1, and FORTRAN were so much lighter to carry around....

RT-11, VMS, OpenVMS, VMS clusters CI, ethernet, Memory channel, DECnet, and M6800 M6809 6502, 8085 M68000 are all good ol friends here too!

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

DuinoSoar wrote:
sometimes, at my age, I feel as clumsy as an ox
Many of us are feeling past our prime (~R∊R∘.×R)/R←1↓ιR

 

That's life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}

 

DuinoSoar wrote:
So that is probably the solution I will use
Glad you got it sorted X[⍋X+.≠' ';]

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

DuinoSoar wrote:
I have never done surface mount, and my tired old eyes and hands probably could not do it anyway.
Proto Advantage has a service to solder a SMD to a DIP adapter.

DuinoSoar wrote:
In any case, I am actually using a Digispark clone board for development ...
An assumption is clone as the original is out of stock.

Digispark USB Development Board - Digistump

...

We will return to normal operations and restock in the first quarter of the New Year.

...

 


Proto Advantage - QFN-24-THIN to DIP-24 SMT Adapter (0.5 mm pitch, 4 x 4 mm body)

should be a match for ATTINY807 - AVR Microcontrollers - Microcontrollers and Processors - Microcontrollers and Processors

tiny804 is in SOIC though it's a future product.

ATTINY804 - AVR Microcontrollers - Microcontrollers and Processors - Microcontrollers and Processors

SMT at 1.27mm (50mil) pitch may be considered as an alternative to THT 2.54mm (100mil) pitch.

Surface Mount Prototyping PCBs | BusBoard Prototype Systems

 

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

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

DuinoSoar wrote:
... I am actually old enough that I started my programming experience with FORTRAN IV on an IBM 360: keypunches, card readers, and line printers, and had to carry around stacks of cards and reams of paper printouts.

...

BTW, I also did FORTRAN on a PDP-11 (the precursor to VAX) using the RT-11 OS ...

...

Similar ... IBM FORTRAN in '80 undergraduate and DEC PDP-11/34 up to '86 post-grad though the project's systems engineer said the PDP-11/34 could be replaced by the IBM PC/AT that he was operating.

DuinoSoar wrote:
... at my age, ...
Not age but health ... may you be well.

 

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