Pages: [1]   Go Down
Author Topic: Atmega328 resetting  (Read 1497 times)
0 Members and 1 Guest are viewing this topic.
Finland
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem is that when any current more than 5mA goes from an output pin to ground my board resets. I investigated this with two codes.

With this sketch the led in the pin 15 ( arduino pin 9 ) blinks really rapidly, because the board is reset immediately when the pin gets high.
Code:
void setup( )
{               
  pinMode( 9, OUTPUT );
}

void loop( )
{
  digitalWrite( 9, HIGH );
  delay( 1000 );
  digitalWrite( 9, LOW );
  delay( 1000 );
}

With this sketch ( notice the switch of setting high and low ) in the other hand the led blinks every second. So when I start the board it properly sets the pin low and waits for a second after what the board resets when the pin gets set high and the sequence starts from all over again. Notice that the led is not on for a second but barely 0.1 second because of the reset.
Code:
void setup( )
{               
  pinMode( 9, OUTPUT );
}

void loop( )
{
  digitalWrite( 9, LOW );
  delay( 1000 );
  digitalWrite( 9, HIGH );
  delay( 1000 );
}

So what I need is a reason for my board resetting like this. Some additional information:

1. My board is atmega328 on a breadboard with general needed components such as proper decoupling capacitors. Notice that the microprocessor is not atmega328p but atmega328, it should not make a big difference though. I use 16MHz external crystal.

2. My voltage between VCC and GND is not too large, measured ~4,7V. It is also pretty stable as it changes between 4,69V and 4,70V ( No, my meter is not precise at all ).

3. My fuses are as follows.

Quote
avrdude: Version 5.4-arduino, compiled on Oct 11 2007 at 19:12:32
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         System wide configuration file is "..\etc\avrdude.conf"

         Using Port            : lpt1
         Using Programmer      : dapa
         Overriding Baud Rate  : 19200
         AVR Part              : ATMEGA328P
         Chip Erase delay      : 9000 us
         PAGEL                 : PD7
         BS2                   : PC2
         RESET disposition     : dedicated
         RETRY pulse           : SCK
         serial program mode   : yes
         parallel program mode : yes
         Timeout               : 200
         StabDelay             : 100
         CmdexeDelay           : 25
         SyncLoops             : 32
         ByteDelay             : 0
         PollIndex             : 3
         PollValue             : 0x53
         Memory Detail         :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : PPI
         Description     : Direct AVR Parallel Access cable
           VCC     = 3
           BUFF    =  (not used)
           RESET   = 16
           SCK     = 1
           MOSI    = 2
           MISO    = 11
           ERR LED = 0
           RDY LED = 0
           PGM LED = 0
           VFY LED = 0

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9514
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as 5
"-lfuse" memory type not defined for part "ATMEGA328P"

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

4. The microcontroller works just fine (?) with less currents than 5mA ( at least for one pin ). I experimented this by adding an adjustable pot in series with the led and 220 Ohm resistor. I adjusted the 10K pot to the point where the board started resetting and measured the resistances. The led takes ~1,8V of the voltage so the current my controller could handle was I = U/R = ( 4,7V - 1,8V ) / ( 317 Ohm + 223 Ohm ) = 5,3... mA.

If you need anything else, just ask. I am really stuck on this.
« Last Edit: July 28, 2011, 09:42:42 am by SnoW » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 207
Posts: 12903
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I use 16MHz external crystal.

With what size capacitors?

What are you using for a power supply?
Logged

Finland
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for your reply. My crystal capacitors are 22pF. As power supply is use an old Nokia phone charger rated at 3.7V which is still fine for my LM7805 because it actually gives at least 8.8V.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 207
Posts: 12903
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
it actually gives at least 8.8V

Under a load?
Logged

Finland
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, but you do understand that the load in my testing was really minimal, there is no way it would have any effect.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, but you do understand that the load in my testing was really minimal, there is no way it would have any effect.

Easy way to tell. Find another independent power source and see if the symptom goes away. I think you will find your choice of a 3.7 volt cell phone charger is not cutting it. A charger will raise it's output voltage as high as it can to try and 'force' a given charge current rate, but once current is drawn if will lower it's output voltage to maintain a constant current rate. So your open circuit voltage of 8.8vdc is kind of meaningless. You need a constant voltage source to feed your 7805 of at least 8vdc at your required total load current, including all external components wired to the processor chip.

Lefty

Logged

Finland
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Easy way to tell. Find another independent power source and see if the symptom goes away. I think you will find your choice of a 3.7 volt cell phone charger is not cutting it. A charger will raise it's output voltage as high as it can to try and 'force' a given charge current rate, but once current is drawn if will lower it's output voltage to maintain a constant current rate. So your open circuit voltage of 8.8vdc is kind of meaningless. You need a constant voltage source to feed your 7805 of at least 8vdc at your required total load current, including all external components wired to the processor chip.

Lefty
Thank you for your reply. When I said "Yes" when asked if the voltage was under load I did not lie ( Why would I have? ). I did a measurement in closed circuit and it really is 8.8V. I actually did the measurement in closed circuit in the first place, only now measured open and it is actually less, something close to 8.2V.
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 4321
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I did a measurement in closed circuit...

Did the closed circuit happen to be an ATmega328 driving an LED?

Don
« Last Edit: July 28, 2011, 07:47:39 pm by floresta » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Easy way to tell. Find another independent power source and see if the symptom goes away. I think you will find your choice of a 3.7 volt cell phone charger is not cutting it. A charger will raise it's output voltage as high as it can to try and 'force' a given charge current rate, but once current is drawn if will lower it's output voltage to maintain a constant current rate. So your open circuit voltage of 8.8vdc is kind of meaningless. You need a constant voltage source to feed your 7805 of at least 8vdc at your required total load current, including all external components wired to the processor chip.

Lefty
Thank you for your reply. When I said "Yes" when asked if the voltage was under load I did not lie ( Why would I have? ). I did a measurement in closed circuit and it really is 8.8V. I actually did the measurement in closed circuit in the first place, only now measured open and it is actually less, something close to 8.2V.

Well if you were here with me, we would put a O-scope on the Vcc of the AVR chip and see WTF is up as you draw current from the output pin. I suspect your regulator output is possibly oscillating due to lack of input and output regulator caps or being current starved by the charger module.

If you wish you could ship your whole set-up to me and I'll diagnose your problem for free, other then shipping costs both ways.  smiley-wink

Lefty
 
Logged

Upstate NY
Offline Offline
Full Member
***
Karma: 2
Posts: 184
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Easier yet, post pictures and a schematic.
Logged

Finland
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did the closed circuit happen to be an ATmega328 driving an LED?

Don
Thanks, Jon. Yes, it happened.

Well if you were here with me, we would put a O-scope on the Vcc of the AVR chip and see WTF is up as you draw current from the output pin. I suspect your regulator output is possibly oscillating due to lack of input and output regulator caps or being current starved by the charger module.

If you wish you could ship your whole set-up to me and I'll diagnose your problem for free, other then shipping costs both ways.  smiley-wink

Lefty
An oscilloscope is a bit out of my budget ( there is a reason I began with an old phone charger ) and how probably are the shipping costs as well. I got to thank you for the offer though and I need to thank you as well that I do not even need the offer as I believe the problem is just how you described ( current starving ). I gathered couple of batteries and it seems my sketch just started working! You always feel little stupid after occasions like this when you did not do the thing you had to do in the first place.

Easier yet, post pictures and a schematic.
That would have been the next thing to do, thanks Joe.
« Last Edit: July 29, 2011, 06:53:31 am by SnoW » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 207
Posts: 12903
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Thank you for the follow-up.
Logged

Pages: [1]   Go Up
Jump to: