Go Down

Topic: Atmega328 rapidly resetting itself, parallel upload (Read 1 time) previous topic - next topic

SnoW

I upload a simple sketch via parallel programmer to my atmega328-pu ( notice it is not atmega328p ) with proper "flash verified" and "Done uploading." inputs. My sketch simply sets pin 12 mode to output and writes it high but what happens is that the led blinks with a frequency of about 5Hz. I believe the board is resetting itself very fast and that is why the blinking. The sketch is following.

Code: [Select]
void setup( )
{
     pinMode( 12, OUTPUT );
     digitalWrite( 12, HIGH );
}

void loop( )
{

}


I am out of ideas so all help is appreciated, thanks.

spycatcher2k

have you tied pin 1 to +5v with a 10k resistor, and got caps on the power lines?

Drew.
Mrs Drew
-=-
http://www.uk-pcb.co.uk - UK PCB Fab Company
I will design & code for you, but I will also charge you (PM me)
If you don't like my answers, realize : I'm not being cheeky, I'm Just trying to prompt you to use your own brain/google etc.

SnoW

#2
Jun 12, 2011, 09:19 pm Last Edit: Jun 12, 2011, 09:20 pm by SnoW Reason: 1

have you tied pin 1 to +5v with a 10k resistor, and got caps on the power lines?

Drew.

Yes, I do. After my further testing this just got much more interesting. With following sketch I got 2Hz blinking led:

Code: [Select]
setup( )
{
    delay( 500 );
    pinMode( 12, OUTPUT );
    digitalWrite( 12, HIGH );
}


And with following 1/3 Hz blinking led:

Code: [Select]
setup( )
{
    delay( 3000 );
    pinMode( 12, OUTPUT );
    digitalWrite( 12, HIGH );
}


What came to me first was obviously that the setup was treated like loop. After that I realized that could it be somehow possible that the high on the pin 12 would cause the reset, no idea though how could this happen as I have not tied the pin 12 to pin 1. Reset would need though be tied to GND and as I leave the pin12 high that does not make sense either. This seems more than weird. I am going to test this with another digital pin, just to make sure.

Coding Badly


Do you have a series resistor with the LED?

Did you change the clock source (via fuse settings)?

SnoW

#4
Jun 12, 2011, 09:32 pm Last Edit: Jun 12, 2011, 09:35 pm by SnoW Reason: 1
Do you have a series resistor with the LED?

Yes, I do.
Did you change the clock source (via fuse settings)?

Fuses are default.

I tested this with another digital pins and they acted the same. So I can now pretty much verify it is not my circuit doing this but the software somehow resets the chip after setup. Can this be because of the incompatibility of atmega328 and atmega328p?

spycatcher2k

what voltage do you have? Also can you tell us the fuse settings you have plz, and if poss a photo of your setup.


Drew.
Mrs Drew
-=-
http://www.uk-pcb.co.uk - UK PCB Fab Company
I will design & code for you, but I will also charge you (PM me)
If you don't like my answers, realize : I'm not being cheeky, I'm Just trying to prompt you to use your own brain/google etc.

SnoW

Coding Badly, you saved my day.

It was my circuit, have to admit. Your series resistor with the led did it. I obviously had a resistor ( 220 Ohms ), I do not know what is up with the led but that was not enough. I threw there 33K resistor and the circuit stopped resetting and led is slightly dimmed. I just measured the resitor and it came 227 Ohms. I do not know what is up with these leds, probably better buy some decent ones next time. Thank you.

Go Up