Atmega 8 - Code Uploads but does not Run correctly

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

Hi AVRFREAKS,

I have a weird problem with an Atmega 8 TQFP. The chip is soldered to a Home made Dev board and it worked well the first day. I uploaded a simple LED blink program to test the functionality and it worked well. The programming was done via ATMEL studio 6 and AVR DUDE, the programmer used was STK500. The next day I tried a more complex program which drives 8 LEDs on PortD. ATMEL studio did recognise the Chip and it transferred the code successfully, so all that was missing was to remove the programmer and attach my LEDS. 

 

Here's the weird part, the 1st time it ran the LEDs illuminated but not in the order I programmed it and after a while it stopped blinking altogether. I noticed the 1st LED shining dimmer than it did on the first run and the others did not light at all. 

I then removed the LEDs and hooked up my programmer again to verify if the chip is still alive, it was Alive and I then Uploaded the Simple Single LED blinker code again to test. 

The code successfully transferred but the LED would not blink but briefly flash at random Moments. So I guess the chip is alive but not well. The Programmers still recognise it and can program it but it does not Drive my outputs.

 

Question: What could have gone wrong with the Chip ? All my connections are perfect and my Power is at a fixed Healthy 5v which is adequate. 

Is my chip destroyed or is there another element at play ? Please help. Thanks. 

This topic has a solution.
Last Edited: Wed. Dec 6, 2017 - 12:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is AVCC connected correctly?

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

Hi Kartman, 

I'm relatively new to this so I was not 100% sure. What I did was take AVCC directly to my VCC Pin, so AVCC also has the 5v attached to it. 

In my head I wonder if the fact that I routed the Track directly under the chip played a part in this. Below is how it is connected in real life. ARef is left floating. And the PortD Pins all run through to a set of Headers on my board. I unfortunately do not have a working smart phone to take a pic for u.  

 

Connection

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

What value resistors do you have in series with your LEDs?

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

Brian Fairchild wrote:
What value resistors do you have in series with your LEDs?
My question too. Sounds like LEDs without current limiting resistors.

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

Kidzo wrote:
The chip is soldered to a Home made Dev board

 

Please post the schematic of your board, and a photo (or photos) of the setup.

 

Instructions here: http://www.avrfreaks.net/comment...

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

Hi, yip, those LED's do not have any resistors inline. This problem is baffling because the LEDs do work when I remove them and test them directly. 

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

Kidzo wrote:
Hi, yip, those LED's do not have any resistors inline. This problem is baffling
What's baffling? If you don't have resistors what limits the current? You have probably burned something deep inside the AVR by sourcing/sinking too much current through it. AVR's generally have pins that can sink/source something like 20..40mA (and usually about 200mA for the complete chip). If you exceed that, as you will have probably done without resistors, you will have damaged the chip.

 

Maybe have a look at one or more of these:

 

http://led.linear1.org/1led.wiz

http://www.ohmslawcalculator.com...

https://www.digikey.de/en/resour...

http://ledcalc.com/

Last Edited: Tue. Dec 5, 2017 - 09:52 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for all the replies AVRFREAKS, you the 2nd one suggesting over current. 

I never considered current as a factor as I was under the impression these babies cannot deliver more than 20MA per pin. I guess there is no resurrection for that m8. This is a lesson learned the hard way.  

 

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

Kidzo wrote:
than 20MA per pin.
Yeah but suppose you drew 300mA or 500mA or something like that through one pin - what do you think would happen then?

 

Have a read of something like:

 

https://www.sparkfun.com/tutoria...

https://www.mouser.com/blog/dont...

etc.

 

(loads more about "led current limiting resistor" if you Google).

 

PS and "20MA" is something quite different to "20mA" (which is a typical limit on AVR pins). If it really was 20 Mega Amps and not 20 milli Amps you would have been OK!

Last Edited: Tue. Dec 5, 2017 - 01:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kidzo wrote:
 you the 2nd one suggesting over current.

That should tell you something!

 

 

I was under the impression these babies cannot deliver more than 20MA per pin.

Note that 20MA is 20 mega amps; ie 20 million amps!

 

You mean 20mA; ie, 20 milli amps = 0.02 amps.

 

But you are misinterpreting the specification!

 

When it says, "20mA max" it means that you must design whatever you connect to the pin to ensure that it will never be more than 20mA.

 

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

So that what it means. Thanks Awneil, I don't think we'll be having this problem again. Or so I hope. Electronics is a wicked game, just when you figure the solution to one thing, another annoyance pops up. 

 

I only joined this group today and do not regret it one bit. it's very refreshing speaking to fellow Circuit Heads. I look forward to getting a few more AVRs.

 

I took 2 key notes from this blog:

 

1. Be very conscious of the current you'll be consuming.

2. Don't stock a single AVR, get as many as financially possible. 

 

Thanks.

Peace to all. 

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

Kidzo wrote:
2. Don't stock a single AVR, get as many as financially possible.
Better advice probably is to spend the same money buying complete Arduino boards in fact. A typical AVR costs $1..$10. Typical Arduino boards cost $3+. So it might bump the cost just a fraction but you will get SO much more for your money. Any Arduino board is well designed, has clock and power supply circuitry, has a USB connection to a PC that can be used for both loading code and to send/receive text while the AVR is running and more than anything every board has a working LED !!

 

(oh and don't think that because the board itself is "Arduino" that means you are tied to using the Arduino IDE to program it and the "Arduino language" to write your programs (actually "Arduino Language" is just C++ with embellishments anyway). YOu can write the programs for an Arduino board in whatever programming language you like and within any code editor/IDE that you like. The only thing that ties you to using anything specifically "Arduino" is that you will likely choose to deliver code to the board across the USB cable using avrdude.exe on the PC end - but you can set that up to be triggered in any IDE you like.

 

(oh and you won't need an ISP programmer either)

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

LED's should always be connected like this:

 

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

Edit:  Maybe NO.

 

The OP said he is using an STK 500, and the STK 500 already has current limiting resistors.

That, therefore, is not the source of the problem.

 

The STK500 uses a transistor driver for the LED so that the micro can run on a wide range of voltages and yet the LEDs will always appear brightly lit when turned on.

(Remember, also, that the STK500 LEDs are BACKWARDs, i.e. setting the pin LOW turns ON the LED, and vice versa.)

 

OP:

Please post your program for review, use the <> icon to do this.

 

Please post a photo of your PCB.

 

You did well to remember to connect AVCC to Vcc, that is correct.

You did well NOT to connect VRef, that is also correct, (it can have a cap to ground).

 

Did you add by-pass caps to your board?

 

You should have a 0.1 uF cap across each of the Vcc and AVcc / Ground pairs of pins, as close to the micro as possible, for reliable operation.

 

JC

 

Edit:  LED Driver image is from the STK500 manual.

Last Edited: Tue. Dec 5, 2017 - 09:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:
The OP said he is using an STK 500, and the STK 500 already has current limiting resistors.

That, therefore, is not the source of the problem.

Well, (s)he said (s)he used a STK500 as a programmer - but the code is running on her/his own board.

 

This would all be clarified by the schematics and photos requested in #6

 

 

Please post your program for review, use the <> icon to do this.

Full instructions were linked in #6

 

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

DocJC wrote:

The OP said he is using an STK 500,...

 

Kidzo wrote:

The chip is soldered to a Home made Dev board...the programmer used was STK500. 

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

Time will tell.

 

If the OP used the LEDs on the STK500 then the above holds true.

If not, then not.

 

JC

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

DocJC wrote:
Time will tell.

 

Schematic & photos will tell sooner - and, probably, better!

 

wink

 

(so long as they're good, clear, in-focus photos)

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

Hi again, here is a pic of the Board. It is the very first one I made, so little effort was put into cosmetics. So if you think u see a "SHORT", just know it is NOT. 

 

C0

 

 

Last Edited: Wed. Dec 6, 2017 - 10:54 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 ... and the schematic (aka "circuit diagram")  ?

 

EDIT

 

I see no LEDs on that board - so you're going to need to include details of what goes on those connectors ...

Last Edited: Wed. Dec 6, 2017 - 10:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah, I hope to post the schematic when I get home. But basically I have home made Jumper wires with female terminals on the end. Those jumpers go into my male Headers on board then the opposite ends go to a Breadboard. The LEDs reside on the breadboard. Unfortunately do not have it here today.

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

Here is the Diagram of the circuit. 

 

 

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

awneil wrote:
you're going to need to include details of what goes on those connectors ...

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

@#23

Which has no LEDs either?

 

(I thought this thread had already resolved the fact that you were using LED without resistors??)

Last Edited: Wed. Dec 6, 2017 - 12:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Final Draft. This is the exact Diagram. Just note that the LED's are not connected directly to the board but through Jumper wires and a ground connection attached to the Breadboard.

 

 

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

Nor caps?

David (aka frog_jr)

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

HAHAHAHA, Yes it is resolved. Going to rebuild this baby as soon and return to this post and give feedback. 

 

Thanks to all those who helped. 

See you on the other side of the PCB. 

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

clawson wrote:
I thought this thread had already resolved the fact that you were using LED without resistors?

So did I - until #15 (which originally started with just a categorical, "NO.").

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

When I first saw the photo of the PCB I thought I was right!

No LED's on the PCB, so the header must jumper to the LED header on the STK500, right?!

 

Oh well, it seemed like a good answer at the time...  Even if it was wrong. sad

 

JC