Confusion on Atmega328p "Pull-Up" Resistor Datasheet

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

So on the Atmega328 datasheet there is a comment on the "Internal Pull-Up Resistor" being set to "on". It specifically says this:

 

Pxn will source current if ext. pulled low.

Maybe im just being really stupid....but what does this mean? I mean I understand what a Pull-Up does....but then it's talking about externally being pulled low? Im assuming this is saying that if the Pin is pulled up, it's connected to VCC (in some way, im probably wrong) but that if we connect the outside pin to GND that we'll have current flowing from VCC--->PIN--->Ext. Pull-down resistor---->GND.

 

Maybe im mis-understanding "Why" it's saying this? I assume because you'll just be wasting power?

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

When a pin pull up is enabled and the pin is pulled to gnd via some external device then the power consumption of the M328 will increase, DUH! Now you know....

I guess this is important to know if one is trying to design for a low power application...

Jim

 

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

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

Mercfh wrote:

 

Pxn will source current if ext. pulled low.

 

 

A pin that 'sources' current causes current to flow from inside the chip to the outside world via the pin. It normally comes from the +ve rail.

 

A pin that 'sinks' current causes current to flow from the outside world into the chip via the pin. It normally flows to the 0v rail.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "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." - Heater's ex-boss

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

Mercfh wrote:
we'll have current flowing from VCC--->PIN--->Ext. Pull-down resistor---->GND.

 

With an external pull down you would have:

VCC--->Int. Pull-up resistor---->PIN--->Ext. Pull-down resistor---->GND

 

So the internal and external resistors would form a voltage divider and that voltage would be input to the pin. If this voltage is neither >>HIGH<< nor >>LOW<<, you will have even more power consumption (besides the one flowing through the resistors) because CMOS transistors from the input buffer present in every pin will be in an intermediate state.

Last Edited: Tue. Nov 6, 2018 - 05:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The pull-up is (effectively) a resistor to Vcc. Thus,  when the pin is logic high, there is no effective pull-up because the pin is already as high as it will go. Pull-up only does something when the input is low. That is, the pull-up only sources current when the pin is low, and for low power situations, you need to take this current into account.

 

That is how I  interpret the text.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

Mercfh wrote:
(in some way, im probably wrong)

Aren't there >>pictures<< in your 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

Another problem related to pull up resistors.
I have written a small program to make PB0 low on my Xplained Mini board with a switch to light the LED.

But this is unstable, sometimes the LED stays on constantly or randomness goes out.
It is also sensitive when touched with a finger.

If I connect an external resistor (100kOhm) from PB0 to Vcc it works well, because I can then turn the LED on and off with the switch.

How could I solve this?

regards,
Bert

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

Another problem related to pull up resistors.
I have written a small program to make PB0 low on my Xplained Mini board with a switch to light the LED.

But this is unstable, sometimes the LED stays on constantly or randomly goes out.
It is also sensitive when touched with a finger.

If I connect an external resistor (100kOhm) from PB0 to Vcc it works well, because I can then turn the LED on and off with the switch.

How could I solve this?

regards,
Bert

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

Be_logic wrote:
I have written a small program to make PB0 low on my Xplained Mini board with a switch to light the LED.
Show the program.  Show the schematic.  Describe how you are testing.  Could it be as simple as the button/switch bouncing? 
Be_logic wrote:
Another problem related to pull up resistors.

How does your description following this relate to pullup?

 

Are you trying to excite an active-high LED with the pullup resistor?  No schematic yet, but at 5V and typical pullup value, that is about 100uA.  Is that enough for your LED?

 

Is your switch floating?  [sounds the most plausible...]

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

Be_logic wrote:
It is also sensitive when touched with a finger.

show schematic and a clear picture of the device.

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

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

I actually ran into the same problem as Be_logic.  Im assuming it's just floating, as moving the button around or repressing it would make the LED turn off. (Assuming it turns on when the Pin is pulled to ground via button push). Because if I straight up took the wire going to Pin whatever and touched it to ground then it always worked. Probably just a really floaty button I guess.

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

Mercfh wrote:
Probably just a really floaty button I guess.

No, you need to bias it.  As this is a thread about pullup -- enable the internal pullup and wire the button active-low.  Tell this floaty-button schematic/picture/diagram.  show the test program.

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

The first attempt was made with a standard Xplained Mini board with a switch and an SMD LED on the board, see http://ww1.microchip.com/downloa...
But if I use eg Port B0 as switch input from which I can switch a short wire to ground then it only works if I use an EXTERNAL pull resistor to Vcc from PB0.

regards,
Bert

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

Be_logic wrote:
then it only works if I use an EXTERNAL pull resistor to Vcc from PB0.

I find that VERY hard to believe.  Please post the shortest complete test program that demonstrates the symptoms.  Tell language/toolchain/version and build settings.  Tell/show how you are testing. 

 

I've done scores and scores of AVR8 production designs.  Many/most use internal pullups for simple stuff like close-by control buttons and DIP switch blocks and switches and similar.  The number of units in the field is close to or at seven figures.  Many of the designs are with the discussed AVR family.  If there was a floaty problem, I'd have been hearing about it, loud and clear.

 

(global PUD on?)

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

Be_logic wrote:
The first attempt was made with a standard Xplained Mini board with a switch and an SMD LED on the board, see http://ww1.microchip.com/downloa...

That board is a '328PB, right?  I looked over the thread again; is that the first mention of PB?

 

Was your second attempt also with the PB?

 

theusch wrote:
Please post the shortest complete test program that demonstrates the symptoms.

 

[edit]  Tell more about this "first attempt", and the results.  The Xplained Mini hardware user guide indictes an active-low button on PB7, with an external pullup.  Show the program that used that pin, andc tell the failing results.

 

 

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.

Last Edited: Wed. Nov 7, 2018 - 04:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The source for testing I got from "Micrsoft Makes" on Youtube and works with  the Xplained Mini board.

 

Here is the source

 

#define F_CPU  8000000UL

#include <avr/io.h>
#include <avr/interrupt.h>

#define LED_ON  PORTB |= (1<<PORTB5)
#define LED_OFF PORTB &= ~(1<<PORTB5)
#define LED_TOGGLE  PINB |= (1<<PINB5)
#define SWITCH_PRESSED  !(PINB & (1<<PINB0))

ISR(PCINT0_vect)
{
       if(SWITCH_PRESSED)  // if PINB0 is low
       {
           LED_ON;
       }
       else
       {
           LED_OFF;
       }
}

int main(void)
{
    DDRB |= (1<<DDB5);
    DDRB &= ~(1<<DDB0);

    PCMSK0 |=(1<<PCINT0);
    PCICR |=(1<<PCIE0);

    sei();

    while (1)
    {

    }
}

 

I only changed it for using PB0 and according to the ATmega 328 datasheet there are internal pull up resistors on PORT B.

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

Be_logic wrote:
and works with the Xplained Mini board.

I'm getting confused.  The Xplained Mini works -- or does not work?  That board has a button on PB7.  What is this about PB0?  Is this your own board, and not the Xplained?  Let's see the schematic, and a good picture of this button area. 

 

As mentioned, buttons bounce.  You can indeed get an odd number of ISR hits.

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

OK, Be_logic, let's be logical about this...

 

-- In #8 you entered the pullup-resistor discussion, and you say you have "another problem". 

-- I'm still not clear about the physical setup.  The Xplained Mini has a button on PB7, active-low, and external pullup resistor.

-- You say you have a problem with PB0, but also mention Xplained Mini.  Have you added another button to PB0?

-- You gave some code in #16.  I'm still not clear about what hardware, but...

-- Your posted code does not activate the internal pullup resistor!!!  So how can you have a "problem" with it?

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

Be_logic wrote:
according to the ATmega 328 datasheet there are internal pull up resistors on PORT B.

Yes most port pins have internal pull ups, but they must be turned on in the program, they are off by default and after reset!

 

Jim

 

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274