ATtiny2313 port pins and pull up's

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

I am using PD5 and PD6 on the ATtiny2313 as switch inputs. I read in the doc’s that the pin’s can sink/source 20mA. I interpret this to mean that I can just apply ground directly to the PD5 or PD6 inputs with out a pull up?
Is this the proper interface or should external resistors be used.
Thanks in advance.

I'll believe corporations
are people when Texas executes one.

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

You need some sort of pullups, either internal pullups if they are available or resistors. Otherwise the inputs will be floating when the switch is open and will be drifting between ground and Vcc.

Leon

Leon Heller G1HSM

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

Just to further that, the sink specification is for when the pin is configured as an output. The port doesn't sink or source anything if set as an input. (with the exception of having the internal pull-up enabled, in which case it will source a small amount of current)

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

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

I have programmed the port pins as 1 and, of course the
Direction reg as inputs.
DDRD = 0x7f
PORTD = 0x7f // This should provide the internal PU?

My concern is , can the ATtiny2313 handle the current when applying GND, through the switch to the pin?

I'll believe corporations
are people when Texas executes one.

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

Well, how much current is drawn through the typical resistance of the pull-up resistor (see datasheet) at your Vcc level? Is that within the limits of "all pins" current for that AVR model? (see datasheet)

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

Thanks folks. It seemed when activating the switch then the device seemed to start getting warm. The application may call for the switch to remain on (GND to the input pin) for an extended time, => 8 hours.

UPDATE: Well, I see that I had the pins set as outputs instead of inputs.

I think that will solve the chip getting warm!

I'll believe corporations
are people when Texas executes one.

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

Quote:

It seemed when activating the switch then the device seemed to start getting warm.

A lot of "seems" in there. I'd suggest some measurements, of temperature and/or current. If your current draw increases by more than a mA when holding the switch down then you'd better look more closely at your wiring. In fact, with the code you gave you are NOT making the pins inputs, but rather high outputs, which would certainly explain the symptoms.

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.