80 mA out of mega32

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

I looked mega32 datasheet and absolute max rating of current for each IO pin is 40 mA.

I made this circuit and I get 80 mA.

I tried putting 100 ohm resistor to ground but I dont get logic 0 on that pin.

I dont know if mega32 will burn out after longer period beeing on with it.

here's the circuit:

http://www.avrtutor.com/tutorial...

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

Respet the data sheet! You will need to modify your circuit to add either a bipolar treansistor or FET.

Your statement about adding a 100 ohm resistor to ground and not getting a logic zero is missing a lot of informtion. What is flowing through the 100 ohm resistor? The 80ma? If so, Ohms Law says that there would be a voltage drop of 8V.

Your circuit does not have any place where 80ma should flow. The port pin should be an input. Things do not add up. Please tell us more.

Jim

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

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

Well I did the same schematic as above 5V is applied to mega32 (VCC)

AND BTW NOW MY MEGA32 WORKS ON 4 MHz LED is blinking like crazy :) :)

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

Where do you think that 80ma will flow? The port pin needs to be set as an input so no current will flow there. There is a maximum of 1ma flowing through the switch when it is closed. I am puzzled about you concern over "80ma".

In all probability, you set the fuses incorrectly. This is a common error. You can't program anything until the processor has a running clock. The solution that is commonly suggested is to provide an external clock to the crystal oscillator input pin. You can make such a clock with a crystal and a logic inverter or several inverters with some resistors and capacitors.

Jim

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

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

I will take picture of actually 77 mA.

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

Where do you measure? What is connected to the AVR? What is the AVR doing when you take the measurement?

Jim

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

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

What port and pin are you using, maybe you are using the Jtag port ?
Port C also serves the functions of the JTAG interface and other special features of the ATmega32 as listed on page 58

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

Looking at your schematic, I can see that if you configure your anonymous port pin as an output and drive it high you are shorting the pin to ground. You will probably get more than 80mA.

The schematic is correct for use as an Input pin.

Judging by your name, is this an exercise in semiconductor abuse?

David.

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

Quote:

I looked mega32 datasheet and absolute max rating of current for each IO pin is 40 mA.

And what does that mean:
Quote:
*NOTICE: Stresses beyond those listed under “Absolute Maximum Ratings” may cause permanent damage to the device. This is a stress rating only and functional operation of the device at these or other conditions beyond those indicated in the operational sections of this specification is not implied. Exposure to absolute maximum rating conditions for extended periods may affect device reliability.

Quote:

I made this circuit and I get 80 mA.

See explanation of Absolute Maximum Ratings above.

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 unable to take picture today but I will explain how did I connected everything

I connected resistor and button with pin 5 of port D
I measured current between pin 5 and button when button is pressed and I get 80 mA.

AVR is turning on and off a LED on pin 6 of port D while button is pressed

DDRD is set to 255.

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

david.prentice wrote:

Judging by your name, is this an exercise in semiconductor abuse?

David.

THAT'S WHY I AM ASKING AND IT IS GOOD THAT I EVEN CHECKED CURRENT

Here's schematic

Attachment(s): 

Last Edited: Mon. Aug 13, 2007 - 07:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hammer111 wrote:

DDRD is set to 255.

And what does this mean ?
Please check the basics !

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

here's the code:

I put here DDRD as 111 to set port D as input to chip and I also get 80 mA

#include 

#define BIT(x) (1 << (x))
#define SETBITS(x,y) ((x) |= (y))
#define CLEARBITS(x,y) ((x) &= (~(y)))
#define SETBIT(x,y) SETBITS((x), (BIT((y))))
#define CLEARBIT(x,y) CLEARBITS((x), (BIT((y))))
#define BITSET(x,y) ((x) & (BIT(y)))
#define BITCLEAR(x,y) !BITSET((x), (y))
#define BITSSET(x,y) (((x) & (y)) == (y))
#define BITSCLEAR(x,y) (((x) & (y)) == 0)
#define BITVAL(x,y) (((x)>>(y)) & 1)


/// Typedefs //////////
typedef unsigned long u32;
typedef unsigned char u8;

/// Defines ///////////
#define forever         117
#define LEDOFF          SETBIT(PORTD,6);
#define LEDON           CLEARBIT(PORTD,6);

void InitPorts(void)
{
    DDRD = 111;
}

void Delay(u32 count)
{
    while(count--);
} 

void main()
{
	SETBIT(PORTD,5); 
    InitPorts();
	LEDOFF;

    while (forever)
    {
		if (!(PIND & (1<<PIND5)))  
		{
        	LEDON; Delay(2000);
        	LEDOFF; Delay(20000);
		}
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You don't want ?

DDRx register selects direction of port pins. If logic one is written to DDRx then port is configured to be as output.
Read here: http://winavr.scienceprog.com/av...

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

DDRD = 111; still sets D.5 as an output.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
#define forever         117 // 0x6D

    DDRD = 111; // 0b0110111 or 0x67 

Sorry if I cast aspersions on your name. I am confused as to your use of magic integers.

David.

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

Oh yeah, its 223 I forgot about 8th bit I thouht this 1101111 but should be 11011111 my mistake. Thanks to everyone for help.

Yeah I'll use hex :) changing code now.

Now I read 0 mA on ampermeter picture is above ;)

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

To avoid such a mistake, on experimental boards sometimes a small resitor is put between the button and the AVR pin to protect the output driver.

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

Well, use this as a learning lesson! In all probability, no silicon was damaged in this exercise. One hopes that the original poster now knows a bit more about DDR. But, there is still more about the most basic input and output that probably still needs to be learned. Had the current not been measured, we probably would have had a question about why the program didn't read the right value from that pin.

One also hopes that the poster understands a bit more about the need to post clear and correct information when a question is being asked.

Jim

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

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

Well starting with this statement of the topic starter
I looked mega32 datasheet and absolute max rating of current for each IO pin is 40 mA. I made this circuit and I get 80 mA.

A restriction of an output port is used to prove that an input port is wrong, senseless !
The poster assumed that the mega32 was taking to much current on the input port.

I feel that poster is missing some basic knowledge like:

- An input port has typical a high imput impedance.
- The current on an output port MUST be limited by the load and not by the mega32.

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

Well I new it is defined as an output... DDRB=255 but I tried using DDRB=111 which is also wrong (1 bit missing) and I revert back to DDRB=255. Finally I saw I made a mistake when Iyachtu told it still doesn't make pin 5 as input(It is actually 223). And also instrument showed that current flows from chip