MCU draws more than 100mA using internal pull-up

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

Hi 

 

I am using an ATmega328P for my project and I have 2 pushbuttons which are connected to PC2 and PC3.

When I push one of these buttons, the ground is directly connected to the corresponding pin but the MCU draws about 100 mA then.

When pushing both switches, the MCU draws 160 mA.

 

I was wondering if this is normal?

This topic has a solution.
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It would be if the pins are configured as outputs and are set high! 

 

 

Jim

Mission: Improving the readiness of hams world wide : flinthillsradioinc.com

Interests: Ham Radio, Solar power, futures & currency trading - whats yours?

 

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

I have following code for setting these pins as input:

 

DDRC = 0b00000000;			//1: output, 0:input
	PORTC = 0b00001111;			//when input and 1 -> pull-up enabled	

Can I assume that I have a damaged MCU? 

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

It's possible, a schematic would help.

Mission: Improving the readiness of hams world wide : flinthillsradioinc.com

Interests: Ham Radio, Solar power, futures & currency trading - whats yours?

 

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

Can I assume that I have a damaged MCU? 

First, I'd like to see a complete test program that demonstrates the symptoms, along with a schematic (or description of all connections).

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'm still in the prototype phase and I don't have schematic yet but it isn't more than the image below.

 

This is my complete code:

# define F_CPU 8000000UL
#include <avr/io.h>
#include <stdbool.h>
#include <util/delay.h>
#include <stdlib.h>
#include "lcd.h"

void initialisation(void);

char *menu[4] = {"foo", "bar", "bletch"};



int main(void)
{
	initialisation();	
	lcd_init();
	
	
	
    while(1)
	{
        if (!(PINC & (1 <<PINC3)))
		{
			set_cursor_to_1st_line();
			clear_display();
			_delay_ms(100);
			string_to_lcd(menu[1]);
		}
		
		if (!(PINC & (1 <<PINC2)))
		{
			set_cursor_to_1st_line();
			clear_display();
			_delay_ms(100);
			string_to_lcd(menu[2]);
		}
		
		
    }
}

void initialisation() {
	
	//disable analog comparator module
	ACSR = (1 << ACD);			//turn off comparator
	
	//global pull-up enable
	MCUCR |= (1 << PUD);
	
	//port directions
	DDRC = 0b00000000;			//1: output, 0:input
	PORTC = 0b11111111;			//when input and 1 -> pull-up enabled	
}

 

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

...the PUD bit in the MCUCR Register can be set to disable all pull-ups in all ports.
 

 

	//global pull-up enable
	MCUCR |= (1 << PUD);

You are >>disabling<< all internal pullups, not enabling them.  But that does not explain your 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.

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

Thank you, that was one stupid mistake of me.

 

The program was running at 8MHz so it was constantly clearing the display.

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

Quote:
The program was running at 8MHz so it was constantly clearing the display.
How does that explain 160 mA?

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

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

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

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

 

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

Since I have changed the PUD bit, it doesn't drawn that much current. And I couldn't see any text before on the display but now I do.

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

I can't imagine that any (normal sized) LCD display would ever draw that much current.  This makes me suspect a problem elsewhere in your schematic or in your code.  But progress is progress ;) ... glad you sorted out the buttons!

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

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

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

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

 

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

I can't imagine that any (normal sized) LCD display would ever draw that much current. 

Indeed.  But as the LCD code was only invoked with a button pressed, and if the input pin floated high (pullups disabled), then if e.g. the backlight circuitry was miswired causing some kind of short...

 

But then you'd think that the LCD init sequence would similarly fail.

 

This makes me suspect a problem elsewhere in your schematic or in your code. 

Indeed.  I guess as a sanity check I might disconnect LCD  and use e.g. an indicator LED.

 

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

Prototype without a schematic? - noooooow    noooooow!

 

idea > schematic > prototype ..... surely that's the way to go

 

Most likely your pins are either outputs set high or becoming outputs set "high" due to a program error and you are shorting them to ground resulting in excessive current