How to program the chip

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

Dear All,

I have a question about the programming the microcontrollers.

When I finish writing a C program for Atmega8 microcontroller. I want to flash the program code into the microcontroller. Like to load the C program into the Atmega8.

Does anyone know how to load a program code into the AVR microcontroller?

Thanks

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

You buy a programmer like a AVRISP Mk2 and use that. Do you have a ISP header on your board?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

electrical_engineer wrote:
Does anyone know how to load a program code into the AVR microcontroller?
Although it might at first seem mysterious, it is not at all. There are two basic methods. One is to use an AVR-specific programming devices that are available from a variety of sources. The ones manufactured by Atmel, although perhaps somewhat more expensive, may be the better choice but many readers of this forum successfully use non-Atmel programmers. I use the AVR ISP, AVR ISP MkII, and the JTAG ICE MkII all Atmel devices.

The second approach is to use some pre-installed firmware called a bootloader. The bootloader allows you to send the program to the device over a communication channel (serial, USB, Ethernet, etc.) and the device self-programs. Most of the Atmel chips do not have a bootloader pre-installed so you'll likely have to buy your AVR from another source in this case.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

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

js wrote:
You buy a programmer like a AVRISP Mk2 and use that. Do you have a ISP header on your board?

hey thanks for your reply, what board are you talking about? The STK500?

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

Hey Mr. Don Kinzer,
Thanks for your reply, currently all I have is AVR studio and WinAVR and STK500. I heard people are saying STK500 is a simulation board, does that mean it's not a emulation device?

Could I use them to load the program code into AVR microcontrollers?

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

The STK500 board also contains a programmer. And AVR Studio knows very well to talk to that programmer. So for programming you don't need yet another Atmel tool or board. What you should do is to thoroughly read AVR Studio's built-in help, because it contains the STK500 documentation.

What the STK500 doesn't do is supporting on-chip debugging (OCD), often also called for historical reasons in-circuit emulation (ICE), although the later is technical wrong.

If you want to do OCD, you (a) need to use an AVR MCU that does support OCD (not all do), and (b) you need an additional tool. Atmel's JTAGICE mkII or Atmel's Dragon, for example.

Stealing Proteus doesn't make you an engineer.

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

hey thanks for your advice,
so all i need to do is to program the code either assembly or C in the AVR studio environment and put Atmega8 onto the STK500 board and then download the program to the chip on the STK500 board, would that work? after that does the microcontroller have the code inside itself?

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

Yes, if you have a C cross-compiler installed (for C programming) and if you have set up the STK500 correctly.

Btw, the mega8 is rather old. Look at the mega88 or mega48.

Also, if you plan to use the mega8 on some other board, and merely use the STK500 for programming, look up ISP in the documentation.

Stealing Proteus doesn't make you an engineer.

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

ArnoldB wrote:
Yes, if you have a C cross-compiler installed (for C programming) and if you have set up the STK500 correctly.

hey thanks for your advice, when u say C cross-compiler, does that mean like WinAVR or Codevision AVR?

What I do is I try to download the codes into the microcontroller and mount the microcontroller onto my PCB board to make my PCB board working. Any comments for missing tasks?

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

There's a bunch of good information in the AVR Programming Methods tutorial.

Don

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

An easy way to program a chip like the Atmega8
is using an ISP programmer. Several companies make such devices and some are under $20 USD.

Here are some links with lots of good information on the subject.

http://ladyada.net/learn/avr/
The sections on "programming" and "programmers" have good information about programming AVRs like the Atmega8.

http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=93
Part 2 of a very good WEB lecture series on embedded microcontrollers -specifically AVRs.

http://imakeprojects.com/Projects/avr-tutorial/
Yet another AVR tutorial.

--- bill

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

Although you can use the STK for programming, if you want a separate programmer, the cheapest one you can get is to make a simple parallel port programmer. If you have a parallel port on your PC the programming cord takes like 4-5 resistors, a 6-conductor wire, a 6-pin socket compatible with the AVR ISP header (optional, if breadboarding you can just label the wires), and a parallel port connector (again optional, but highly recommended if you don't want to keep jamming stuff randomly into the parallel port and risk damaging it). All together, a complete cable costs around $5 to build, primarily for the parallel port connector and shielding hood for it.

The only downside is that this type of cord isn't compatible with AVR Studio, you have to use the command-line app called "avrdude" which loads your compiled .hex files onto AVR chips and supports a ton more programmers than AVR Studio does.

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

Having tried multiple programmers (AVRISP, JTAG) I vote for the STK500. I use that even when I am prototyping on my breadboard.

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

the STK500 is good, you can ISP your mega8 while is on the the target board using your stk500. another simple way is to build a bsd cable( parallel port) or a dasa cable(serial port) for programming below are links where you can find more info

http://fab.cba.mit.edu/about/fab/
http://fab.cba.mit.edu/content/t...

Analog + Digital= 21 century technology and beyond. digital is easy, analog is professional!!!!!!!!!!

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

Quote:
Although you can use the STK for programming, if you want a separate programmer, the cheapest one you can get is to make a simple parallel port programmer. If you have a parallel port on your PC the programming cord takes like 4-5 resistors, a 6-conductor wire, a 6-pin socket compatible with the AVR ISP header

Why on God's green earth would you do this? The STK500 is one of the best, most reliable intelligent ISP programmers you can possibly buy and you are suggesting ditching this in favour of just about the worst ISP solution ever conceived. Why oh why would you do this? It just doesn't make any sense whatsoever.

If you were going to make a second ISP programmer (though I still don't understand why) then far better would be to use ISP of the STK500 to program a chip that would form the heart of an "intelligent" programmer. I guess you might want to construct a USB based one this way for use with laptops/modern PCs (though the STK500 works well through a USB-RS232 converter anyway)

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

I guess there's no reason to ditch the STK500 if you have one, but there's a lot of us students who can barely afford the $5 AVR and breadboard to get started. I was using an AVRISP that our robotics team has (it's a nice programmer indeed) but not being able to program chips at home wasn't a great thing so I built something that works fine for my applications out of parts I had lying around. I've had great success with my parallel programmer for what it's worth.

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

My point was that your post was completely inappropriate for this thread - OP already identified that he had an STK500 - you seemed to be deliberately trying to confuse by posting something irrelevant.

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

I am using  STK500 board  which contains a programmer. It is working fine for me.

C programming language (link removed)

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

Thanks,
We waited six years for the solution!

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

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

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

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

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

Jim,

 

If you check his previous posts, I conclude he is a spammer and should be banned/deleted. You or me?

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

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

Jim, he's a spammer - unfortunately I thwarted him by removing the URL from his signature ;-)

 

(I didn't delete/ban because it's just vaguely possible someone might be interested in what he's offering - but they will have to scan through his posts to find the one that remains where the links have not been removed).

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

I know that....My comment was my way of rolling my eyes.

 

This is a prime example of why we should have an expiration date on threads.  NO activity in X month(s) topic locked.  Radio button to request it be unlocked.

 

No matter, the plug will be pulled soon

 

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

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

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

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

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

I like you POSITIVE attitude James. wink

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly