Pages: [1]   Go Down
Author Topic: AVR ISP mkII Help, please  (Read 1456 times)
0 Members and 1 Guest are viewing this topic.
Kamloops BC Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Context: I live in a rural part of western Canada, a LONG way from electronics stores like Radio Shack (which isn't in Canada any more...). I have one electronics shop an hour from home, which sells parts to industrial users. The shop can order lots of discrete components, but not Arduino boards because their supplier doesn't carry them. I will probably order from a Canadian distributor, even though that usually takes weeks for delivery. That time delay got me in this trouble!

I bought a "starter kit" of a protoboard and some discrete components from Dale Wheat. None of what happened is Dale's fault; he's a good guy in my book. But, by not thinking things through I trashed the chip (ATMega328). My bad. N00b mistake. I admit it. I could have ordered another chip from Dale, but there's that shipping thing again.

I asked and discovered that my local shop could get the chip -- although "bare" with no bootloader (think I'm using the right phrase) so I couldn't just stick it in the board and start back learning to figure this stuff out. Checked the knowledge on this site and bought an AVR ISP mkII...

...which I, in my little dream world, thought would be a device into which I would plug the chip and it would get what it needed and I'd be good to go. I hear chuckles from around the world.

I keep getting in deeper over my head. What I want to do is order the "bare" chip, put in what it needs, and then proceed to build and program a project. It seemed like a good idea at the time to be able to use what I could get locally instead of having to spend endless time waiting on the post office. I'm a complete novice at Arduino, and just trying to speed up the learning process.

Everything I read about this ISP assumes I know more than I do. Can someone please give me a simple idiot-proof set of directions so I can get this working even if I don't understand what I just did? Something like: "get an xxx connector and wire it on the breadboard to pins blah-blah, then plug in the ISP and start Z program and tell it to burn." I think I'm that competent.

Note: if that simple set of instructions is impossible, please tell me. I'll go learn more stuff and buy a board and start over. This has just gotten frustrating and that's no fun.

Thanks for any help!

Logged

Dr. Charles Hays
"But he's not the kind of doctor that does anybody any good." -- Mom

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are on the right track.

You need three things to make the whole thing work:

1) an ide / compiler: you can download gcc-avr/code::blocks, or avrstudio (5.0/6.0 or even earlier ones), or commercial ones (iar-avr for example). This allows you to write code to get your chip to do whatever you want it to do.
2) have a program: your avrisp then can burn your code into the chip.
3) a circuit in which your chip functions: this can be done on a protoboard or a real board.

You have the programmer and the circuit / chip (or can make them presummably). The ide/compiler is just a few clicks away. So you are 99% there in terms having the right software / hardware to start writing code.
Logged

Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1098
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can use the ISP with an ATMega328P chip or any of the other ATMega or ATTiny chips with no bootloader.  It is VERY rewarding to do it this way.  You need a 2x3 header for that AVR II programmer (or a sparkfun "AVR Programmer Adapter") and then wire the 4 pins that correspond to SCK, MISO, MOSI, and Reset to the chip, as well as VCC and GND.  I learned how to do it from this reference, read this:

http://allaboutee.com/2011/05/11/how-to-program-an-avr-microcontroller/

NOTE.  The tutorial does not say this, but you don't have to use Atmel Studio to do the compiling.  Use the Arduino environment, compile your program and then search for the ELF file.  If you know how to use the command line and your project is called MyProject then search your root drive for *MyProject*ELF*.  Use this file with the programming software described in the tutorial above, it's included in the Atmel Studio download.

Here is a project I did.  You can see the header and the bare ATMega328 (not finished at the time, now finished):

« Last Edit: August 24, 2014, 06:27:33 pm by JoeN » Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A plug for Code::Blocks: I use commercial ides for a living. But I would say that on writing code and utilities, CB is no second rate vs. those commercial products. CB+gccavr is a great combination for people who are on a limited budget.

If you need extensive debug support, I would recommend iar-avr ($$$), or avrstudio if you have a fast computer.
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5522
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Everything I read about this ISP assumes I know more than I do. Can someone please give me a simple idiot-proof set of directions so I can get this working even if I don't understand what I just did? Something like: "get an xxx connector and wire it on the breadboard to pins blah-blah, then plug in the ISP and start Z program and tell it to burn." I think I'm that competent.

That's basically it...all you need is to connect the ISP connector to the corresponding pins on the chip, select "AVR ISP mkII" in the IDE and you're done!

Look at the second image in this thread for how I once did it on a breadboard: http://arduino.cc/forum/index.php/topic,125212.0.html

(OK, that's a Tiny85, not a Mega328 but the principle is the same...)

The chip and ISP connector pinouts are here: http://www.akafugu.jp/images/microcontroller-reference-sheet.png

nb. The ISP connector shown there is the 'male' version, the connector from your programmer will be backwards because it plugs onto that.

Here's another guide: http://robotics.org.za/image/cache/data/AVR%20ISP%20Programmer%20connections-500x500.jpg

Identify the +5V and GND pins with a multimeter to make sure you get them right. The red wire on the cable should be +5V, the GND wire should go to outer metal case of the USB plug. Don't connect it up to USB power until you're absolutely sure you have those two connections right. You can mess the other ones up without much harm, but not the power.

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6619
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can write your sketch using the Arduino IDE and then upload it to your chip using the "Upload using programmer" menu option. You need to download an extra driver to use the AVRISPmkII with the Arduino IDE (sorry, I can't remember where I downloaded mine from).

A virgin atmega328p will have the clock set to the internal 8MHz oscillator with a prescaler of 8 (so 1MHz clock frequency). To use anything different, you will need to program the low fuse byte. The easiest way to do this is to use AVR Studio and your AVRISP. Two warnings:

1. Be very careful with the high fuse byte, one of the bits in it will DISABLE future programming via ICSP if you get it wrong.

2. Once you set the low fuse byte to use a crystal, you can't then program the chip unless you have the crystal in place or you apply an external clock signal.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5522
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can write your sketch using the Arduino IDE and then upload it to your chip using the "Upload using programmer" menu option. You need to download an extra driver to use the AVRISPmkII with the Arduino IDE (sorry, I can't remember where I downloaded mine from).

Arduino 1.0.1 has AVRISPmkII support as standard...

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6619
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Arduino 1.0.1 has AVRISPmkII support as standard...

Yes, but I still had to find a USB driver for the AVRISPmkII. The one that was installed with AVR Studio wasn't recognised by the Arduino IDE. [EDIT: unless I was still on 1.0 when my AVRISP arrived...]
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5522
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Arduino 1.0.1 has AVRISPmkII support as standard...

Yes, but I still had to find a USB driver for the AVRISPmkII. The one that was installed with AVR Studio wasn't recognised by the Arduino IDE. [EDIT: unless I was still on 1.0 when my AVRISP arrived...]

Oh, yeah, you need a USB driver for Windows (or Linux/Mac/whatever).
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Kamloops BC Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you, everyone! That will get me going, I think.

ch
Logged

Dr. Charles Hays
"But he's not the kind of doctor that does anybody any good." -- Mom

Pages: [1]   Go Up
Jump to: