Is something wrong with my Atmega8A-PU

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

Hi, I am a beginner to microcontrollers.. I bought a programmer (AvrProg USB v3) and Atmega8A-PU. I successfully connected it together and in my atmel studio I managed to read my device using tools > device programming.

Until that, I was successful. But when I tried to connect diode and make it light, I can't get a result. Nothing happens.

The simplest possible I wrote is this:

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

int main (void)
{
	board_init();

	DDRD = 0xFF;
	PORTD = 0x00;
	while(1) {
		// this maybe useless
	}
}

But no matter what I do, the diod is not blinking on (btw I connected longer end to PD0 and shorter end to ground, which is probably obvious from the code).

 

Am I doing something wrong? Can i somehow find out there is something wrong with my chip? Thank you.

 

 

Last Edited: Fri. Dec 29, 2017 - 05:59 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

 the diod is not blinking

I don't use C, so some others can help out here, but a few things to keep in mind:

 

You generally need a instruction that tells the compiler the clock frequency of the micro, (e.g. 8 MHz, or whatever).

 

For the LED to blink, you need to turn it on, wait a while, then turn if off, and wait a while, then loop.

 

Pseudo code:

Definitions, compiler info

 

Main:

configure I/O pin for output

Do

  turn on LED, (set the I/O pin High)

  delay 500 mSec

  turn off LED, (set the I/O pin low)

  delay 500 mSec

Loop

 

Additionally, you need to have a 330 ohm or 470 ohm resistor or something similar in series with your LED.

 

Welcome to the Forum.

 

JC

 

 

Last Edited: Fri. Dec 29, 2017 - 05:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sorry that was a mistake, I corrected it, I want the diode just to be on. To see the light, nothing more. But it doesnt work.

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

DocJC wrote:
you need to have a 330 ohm or 470 ohm resistor or something similar in series with your LED

Indeed.

 

See, for example: https://electronicsclub.info/leds.htm

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Increase wrote:
sorry that was a mistake, I corrected it

It's unhelpful to change your post after people have replied to it - because it makes nonsense of the replies!

 

I want the diode just to be on. To see the light, nothing more. But it doesnt work.

So have you tried it with just the LED and resistor ?

 

(if you tried connecting just the LED to a power supply with no resistor, you have probably blown the LED).

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I saw it in some youtube, that since i am using 3.3V that it shouldn't hurt the diode for a while. Anyway i took new diode and added 330 ohm resistor, but the program is not working.

I get no error, build runs and the avrprog diode blinks to indicate the program is being uploaded to the chip.

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

Increase wrote:
I connected longer end to PD0 and shorter end to ground

LED circuit symbol

LED connections

https://electronicsclub.info/leds.htm

 

So, in other words: you connected the anode to PD0 and cathode (or "kathode") to ground.

 

So that's the lower of these two:

 

sinking and sourcing current

https://electronicsclub.info/ics.htm

 

Which means that you need to set the port pin high for the LED to light.

 

But your code sets it low.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

good point, I set it to 0x01 but it still doesnt do anything.

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

Increase wrote:
I saw it in some youtube, that since i am using 3.3V that it shouldn't hurt the diode for a while

Sorry, that's just wrong.

 

The length of time it takes to blow up semiconductors like LEDs is measured in thousandths of a second!

 

Anyway i took new diode and added 330 ohm resistor, but the program is not working.

Again, does it work without the microcontroller - just the LED, resistor, and power supply?

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

 

Anyway i took new diode and added 330 ohm resistor, but the program is not working.

Again, does it work without the microcontroller - just the LED, resistor, and power supply?

 

yes

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

 

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

int main (void)
{
	board_init();

	DDRD = 0xFF;
	PORTD = 0x00;
	while(1) {
		// this maybe useless
	}
}

Hmm...  Why are you using ASF with an old, 8-bit device, as ASF has little to no support for old, 8-bit devices.  What board are you using?

 

 

Greg Muth

Portland, OR, US

Xplained/Pro/Mini Boards mostly

 

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

I actually do not have a clue what is it for, I followed some tutorial and didn't focus on that.

I tried to create project without ASF, so now its just

#include <avr/io.h>


int main(void)
{
    DDRD = 0xFF;
    PORTD = 0x01;
    while (1) 
    {
    }
}

still no result.

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

1. do not connect LED directly to MCU otherwise you will damage both MCU and LED, use a resistor seried with LED to limit current, 

2. you need to know max rating current and forward voltage of your LED , to calculate resistor value, if you cant calculate, any value 220 ohm to 560 ohm will be fine

3. put the resistor between MCU and LED.

4. PORTD = 0x00 means set port pins to 0V , so your code is wrong, you need to set pins to Vcc (maybe 5V) : PORTD=0xff will set all pins to Vcc, PORTD=0x01 will set just pin0 to Vcc

5. longer lead generally is anode but maybe not in some LEDs, after correcting your code if still not work, try reverse LED connection

 

Majid

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

m.majid wrote:

1. do not connect LED directly to MCU otherwise you will damage both MCU and LED, use a resistor seried with LED to limit current, 

2. you need to know max rating current and forward voltage of your LED , to calculate resistor value, if you cant calculate, any value 220 ohm to 560 ohm will be fine

3. put the resistor between MCU and LED.

4. PORTD = 0x00 means set port pins to 0V , so your code is wrong, you need to set pins to Vcc (maybe 5V) : PORTD=0xff will set all pins to Vcc, PORTD=0x01 will set just pin0 to Vcc

5. longer lead generally is anode but maybe not in some LEDs, after correcting your code if still not work, try reverse LED connection

 

tried all, still nothing happening.

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

Time to post a schematic (aka "circuit diagram") of your setup.

 

Also a good, clear, in-focus photograph (or photographs) where all connections can clearly be seen.

 

Instructions on how to post images (photos & schematics): https://www.avrfreaks.net/comment...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is how it looks, no exposed wires are touching..

I am not sure how to draw this circuit diagram (never did it with MCU) but this should be sufficient enough, hopefully.

(As I said with this setup i can read the MCU in atmel studio no problem. )

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

See the note on page 16 of the datasheet:

AVCC ... should be externally connected to VCC, even if the ADC is not used

http://www.atmel.com/images/atmel-8159-8-bit-avr-microcontroller-atmega8a_datasheet.pdf

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I see, that might be it! What does it mean exactly? Should I connect a battery to avcc and gnd then? 5V battery? Sorry I am total newbie. And thanks!

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

I cant see pull-up resistor on reset pin
10k ohm - 47kohm between reset and vcc

Majid

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

Remove the wire from the reset pin and see if the LED turns on after adding the pull-up resistor as m.majid has written above.

 

EDIT: m.majid

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

Last Edited: Fri. Dec 29, 2017 - 07:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Increase wrote:
What does it mean exactly?

It means you take a wire, and use it to connect the AVCC pin to the VCC pin

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You do not need a resistor to Rest as long as you are not trying to program the AVR.  For programming you will need the resistor.  In this application as Larry and majid suggest I would put a 10k resistor to Vcc and remove the wire.

 

Question regarding the wire to the RESET line....is that wire going to your programmer by chance?

 

JIm

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

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

awneil wrote:

Increase wrote:
What does it mean exactly?

It means you take a wire, and use it to connect the AVCC pin to the VCC pin


Ok I'll try that thanks.

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

jgmdesign wrote:

You do not need a resistor to Rest as long as you are not trying to program the AVR.  For programming you will need the resistor.  In this application as Larry and majid suggest I would put a 10k resistor to Vcc and remove the wire.

 

Question regarding the wire to the RESET line....is that wire going to your programmer by chance?

 

JIm

The reset leads to my programmer indeed.

What do you mean by "programming"? I thought that creating and compiling the code above and uploading it on the chip IS programming. :-)

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

Increase wrote:
What do you mean by "programming"?

"Programming" is used both to describe the act of writing programs, and the process of loading the resulting executable into the target processor.

 

Similarly, "Programmer"  is used both to describe a person who writes programs, and the equipment for loading the resulting executable into the target processor.

 

jgmdesign wrote:

For programming you will need the resistor.

in that context, "programming" is the process of loading the executable into the target processor

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Fri. Dec 29, 2017 - 08:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Increase wrote:
What does it mean exactly?

It means you take a wire, and use it to connect the AVCC pin to the VCC pin

it didn't help

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

Time to post a complete program that can be compiled by others.

Too much back and forth with the small snippets of info......

 

Happy New Year!

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

So the diode finally flashed. But I don't understand it.

When I have a reset connected to the programmer, the program is apparently uploaded but not executed.

When I dont have the reset connected, the program is not updated (uploaded) but the present version on the MCU runs for a second (the diod lights) until I get error (got  0xc0 instead of 0x00) which I am getting every time I connect the programmer in a wrong way to the MCU.

When I connect VCC to ACC nothing changes in both cases.

When I connect VCC to reset via 1k resistor nothing changes when reset unpluged. And another error (Unexpected signature 0x003e9397 (expected 0x001e9307).) happens when I also connect reset to the programmer.

edit: with 10k resistor its the same as above

Last Edited: Fri. Dec 29, 2017 - 08:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Increase wrote:

So the diode finally flashed. But I don't understand it.

I assume this occurred when you disconnected the reset wire.

Increase wrote:
When I have a reset connected to the programmer, the program is apparently uploaded but not executed.
Because the reset wire is still connected, yes?

Increase wrote:
When I dont have the reset connected, the program is not updated (uploaded) but the present version on the MCU runs for a second (the diod lights) until I get error (got  0xc0 instead of 0x00) which I am getting every time I connect the programmer in a wrong way to the MCU.
The programmer cannot program the chip with the reset line disconnected.

Increase wrote:
When I connect VCC to ACC nothing changes in both cases.
Connect it anyway as this is per the data sheet.

Increase wrote:
When I connect VCC to reset via 1k resistor nothing changes when reset unpluged. And another error (Unexpected signature 0x003e9397 (expected 0x001e9307).) happens when I also connect reset to the programmer.

edit: with 10k resistor its the same as above

You have something wired incorrectly.

 

What programmer are you using to program the chip?  Please don't say yourself. ;)

 

EDIT: Please follow the instructions in post #27 and include a new picture of the breadboard circuit with all of our suggested connections in place.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

Last Edited: Fri. Dec 29, 2017 - 09:52 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Increase wrote:
When I connect VCC to reset via 1k resistor nothing changes when reset unpluged. And another error (Unexpected signature 0x003e9397 (expected 0x001e9307).) happens

That is too strong a pull up, the programmer can not pull the line down, change the resistor to 10k!

 

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

Increase wrote:
When I connect VCC to reset via 1k resistor nothing changes when reset unpluged. And another error (Unexpected signature 0x003e9397 (expected 0x001e9307).) happens when I also connect reset to the programmer.

edit: with 10k resistor its the same as above

ki0bk wrote:

Increase wrote:
When I connect VCC to reset via 1k resistor nothing changes when reset unpluged. And another error (Unexpected signature 0x003e9397 (expected 0x001e9307).) happens

That is too strong a pull up, the programmer can not pull the line down, change the resistor to 10k!

I'm beginning to wonder if the 10K resistor was really ever tested.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

Last Edited: Fri. Dec 29, 2017 - 09:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It was tested.

I am not sure what more to give you of the code.

This is all:

#include <avr/io.h>


int main(void)
{
    DDRD = 0xff;
    PORTD = 0x01;
    while (1) 
    {
    }
}

In atmel studio if you create GCC  C Executable Project and paste this to the main.c you will have exactly the same as I do.

Here is updated circuit:

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

Oh, and as I wrote above I use AVRProg USB v3 https://www.gme.cz/data/attachments/orn.752-447.1.pdf

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

I find it a bit odd, and confusing, that the ground wires are red and the VCC wires are green.  That is completely opposite what would be considered the norm.

 

Use red for VCC and black (or green if you must) for GND.  Don't believe it?  Plug these terms into a browser search and select images - avr atmega8 circuit breadboard​

 

If you disconnect the reset wire after programming the chip does the LED light up?

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

Last Edited: Fri. Dec 29, 2017 - 10:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does the LED light if the '+' is directly connected to VCC (leaving the '-' connected to GND through the resistor)?

(In other words, leaving the uC out of the mix... does the LED work?)

David (aka frog_jr)

Last Edited: Fri. Dec 29, 2017 - 10:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Both the Vcc and the AVcc pin must be connected to your +5 V power supply positive side.

Both of the grounds, (pins 8 and 22), need to be connected to the power supply's negative side, (ground).

 

You should put a 0.1 uF capacitor from the Vcc pin to Ground, and from the AVcc pin to Ground.

This is for reliable operation.

These are called By-pass capacitors.

Put the one end as close to the micro's Vcc and AVcc pins as possible, (nearest hole on the bread board).

 

Next:

You do not need to have a resistor on the Reset\ pin.

The micro has an internal pull up resistor that will work just fine for your bread boarding experiments.

IF you do use one, make it 10K ohms or higher, NOT 1K.

 

Next:

Consider disconnecting your programmer and cycling the power off and then on, to test your circuit.

Depending upon the hardware programmer, and the software running it, it is sometimes possible for the hardware programmer to hold the micro in its reset, (non-running) state.

 

Finally:

The color of the wires doesn't matter.

Not even a little bit.

 

BUT, some of us old timers would NEVER use a red wire for Ground, and a Green wire for Vcc.

Red wires are traditionally used for the V+ powering bus.

Black or Green wires are traditionally used for the Ground bus.

 

As I said, it doesn't matter at all.

But when troubleshooting a layout it is beneficial to follow "Standards" and tradition.

 

Do report back on how your project is coming along.

 

JC

 

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

most strange thing just happened:

there is a switch on the programmer, which changes 3.3V to 5V. I switched it and nothing happened for a while... but... after a minute or so, the diode started shining.

So I updated the program as following:

#ifndef F_CPU
#define F_CPU 1000000UL
#endif // F_CPU

#include <avr/io.h>
#include <util/delay.h>

#define set_bit(target, num)    (   target |=   _BV(num))
#define clear_bit(target, num)  (   target &=   ~ _BV(num))
#define toggle_bit(target, num) (   target ^=   _BV(num))

#define DELAY_IN_MS 500 /* 1 sec */


int main()
{
    set_bit(DDRD, PD0);
    set_bit(PORTD, PD0);
    while(1)
    {
        toggle_bit(PORTD, PD0);
        _delay_ms(DELAY_IN_MS);
    }

    return 0;
}

An started debug session and it works! the diode is blinking.

 

I guess I should've switched to 5V from the beginning, what I do not get is the delay after which it suddenly started working. Does anybody know?

 

larryvc: thank you for the color codes tip, I will adjust that.

And thank you all for your patience.

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

DocJC wrote:
BUT, some of us old timers...
Speak for yourself Doc ;)

 

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

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

thank you, your insights helped me, and I will try that capacitors once I buy them tomorrow.

I switched the cables, as you say standards are good to follow.

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

DocJC wrote:
But when troubleshooting a layout it is beneficial to follow "Standards" and tradition.

Particularly when asking other people to help with the troubleshooting

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You should put a 0.1 uF capacitor from the Vcc pin to Ground, and from the AVcc pin to Ground.

This is for reliable operation.

These are called By-pass capacitors.

Put the one end as close to the micro's Vcc and AVcc pins as possible, (nearest hole on the bread board).

 Why is this making things more reliable? Do I do it only for breadboard projects or is it a common practice?

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

See Wiki Decoupling Capacitor for a better answer than I can provide.

 

They are required for reliable operation for any layout, bread board or PCB.

 

They are expected standard practice for digital logic circuits.

 

JC

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

ok Ill check it, thanks :)

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

 

Increase wrote:
I saw it in some youtube, that since i am using 3.3V that it shouldn't hurt the diode for a while

awneil wrote:
Sorry, that's just wrong.

 

The length of time it takes to blow up semiconductors like LEDs is measured in thousandths of a second!

See also: https://www.avrfreaks.net/comment... (and preceding comments)

 

edit

 

preceding comments

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Tue. Jan 2, 2018 - 12:11 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Increase wrote:

I saw it in some youtube, that since i am using 3.3V that it shouldn't hurt the diode for a while.

 

The only reason you don't instantly burn the diode and the pin, is because AVR pins have aprox. 20-30 ohm of internal resistance. This may keep the current under the absolute max of 40mA even without a (external) resistor for certain LEDs if VCC = 3.3V, but at 5V it would surely burn something very quickly.

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

El Tangas wrote:
The only reason you don't instantly burn the diode and the pin, is because AVR pins have aprox. 20-30 ohm of internal resistance.

True for the LED connected to an MCU output pin.

 

But it seemed that the OP might be misinterpreting it as meaning that the LED could be connected direct to any 3.3V power supply with no resistor.

 

While it's possible that a 3.3V power supply might limit its current to a safe level, that is by no means guaranteed!

 

There are also youtubes showing LEDs connected directly to 3V coin cells. This, again, relies on the coin cell's (relatively) high internal resistance - it should not be attempted with any other type of battery!!

 

surprise

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...