[TUT] [HARD] AVR Programming Methods

Go To Last Post
76 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are many ways to program AVR microcontrollers. Since many people ask about different ones at one time or another, I thought I'd outline them here so that their questions can be answered quickly and efficiently. Please forgive me if I miss a method or make an error.

METHOD 1: In System Programming (ISP)
Supported By: Vast majority of AVRs (see below posts)
Supported Programmers: AVRISP MKI/II, JTAG MKII, STK500, STK600, Dragon, AVRISP clones, AVR910 Programmers, AVRONE

    In System Programming is perhaps the most common method of programming the flash, EEPROM, fuse and lockbytes of the entire AVR line. ISP can program AVRs at extremely high clock rates (assuming the target AVR is running at a high frequency and the programmer supports it) and is the method of choice for almost all AVR hobbyists. There are many, many AVRISP clones and AVR910 programmers on the market in addition to simple do-it-yourself dongles which connect to your computer's parallel port.

    Recent new dongle designs may use the computer's serial port, however anecdotal evidence has said that this method is *extremely* slow due to technical limitations.

    ISP requires that the target AVR is running at a clock rate of at least four times that of the ISP clock. This is a common pitfall and a source of confusion to many new to AVRs.

METHOD 2: JTAG
Supported By: See AVRStudio Tools help for MKI and MKII device support
Supported Programmers: JTAG-ICE, JTAG-ICE MKII, Dragon, JTAG-ICE clones, AVRONE, STK600 (programming only)

    Technically JTAG is a debugging system, not a programming method. Still, the JTAG interface allows for the programming of an AVR which supports it.

    JTAG is an in-system debugging tool which allows you to manipulate and examine the status of a supported AVR while it is running in a circuit. JTAG allows the user to stop execution at any time, the manipulation of the AVR's internal registers and much more.

    The official JTAG-ICE units from ATMEL have been superseded by the JTAG-ICE MKII, which supports the newer and more widely supported across the AVR range DebugWire debugging protocol as well as programming via the ISP method (see above).

    JTAG-ICE clones are available for low prices, however their limited compatibility with only a handful of AVRs limits their usefulness. Regardless of this, if your AVR supports the JTAG interface the JTAG-ICE remains a very nice and effective debugging method and programmer.

METHOD 3: DebugWire
Supported By: Many smaller AVRs
Supported Programmers: JTAG-ICE MKII, Dragon, AVRONE

    Again DebugWire is a debugging rather than a programming interface, but can be used to load in programs into supported AVRs. The dW interface uses a single AVR pin (the /RESET line) for all communications, making it ideal for the low-pin count AVR devices.

METHOD 4: Bootloader
Supported By: Most newer AVRs
Supported Programmers: N/A

    Again technically not a programming method. A bootloader is a small AVR program which sits in a user-settable reserved section of the regular flash. Bootloaders make use of the flash self-modification features available in the newer AVRs to allow the AVR to program itself via program data loaded from an external source. Bootloaders may source their data from any location (eg external dataflash or SD card) however by far the most common type of Bootloader communicates with a PC via the AVR's RS-232 (serial) port.

    Bootloaders are limited in that they do consume flash space (limiting the size of the flash available to the AVR's application) and they are unable to change the AVRs fusebits.

    Bootloaders are widely available on the internet for download, but they suffer from a "chicken and egg" problem; you need another type of programmer listed here to program in the bootloader in the first place. This is usually solved by the construction of a simple parallel port dongle (See ISP section) or by the purchase of an AVR already preloaded with a bootloader (eg the AVRButterfly board).

METHOD 5: High Voltage Parallel Programming (HVPP)
Supported By: Most non-TINY AVRs (with exceptions)
Supported Programmers: STK500, STK600, Dragon, Homebrew Dongles, AVRONE

    High Voltage Parallel Programming is a method of programming which is rarely used, because of the hassle it requires to set up. Despite this, HVPP programming is commonly used to "resurrect" AVRs whose fusebits have been mis configured via another programming method.

    Both the STK500 and the Dragon supports HVPP. During HVPP, the target's /RESET pin is raised to the unusually high value of 12V which engages the internal parallel programming circuitry. The /RESET pin is the only pin of the AVR (on HVPP supported AVRs) which can be safely raised to this level.

    You can make your own HVPP dongle using online plans such as this one.

METHOD 6: High Voltage Serial Programming (HVSP)
Supported By: Many TINY AVRs (with exceptions)
Supported Programmers: STK500, STK600, Dragon, Homebrew Dongles, AVRONE

    HVSP is similar to HVPP, except the data transfer is performed serially rather than in parallel. This is the alternate programming method used on many TINY series AVRs who lack enough pins for HVPP.

METHOD 7: PDI
Supported By: XMEGA AVRs
Supported Programmers: STK600, AVRONE, JTAG MKII, Dragon, AVRISP MKII

    PDI is the new programming interface based on the debugWire protocol, for the XMEGA line of AVRs. It's not currently used on any other 8-bit AVR microcontrollers.

METHOD 8: TPI
Supported By: 6-Pin TINY AVRs (ATTINY10, etc.)
Supported Programmers: STK600, AVRISP MKII

    TPI is a very tiny programming interface for the newer TINY line of AVRs with limited pins, like the 6 pin ATTINY10. Like dW, TPI uses the device's /RESET line as part of the communication interface, but there the similarity ends. Since the pint-sized TINY AVRs lack a on-chip debugging circuit, the TPI protocol uses a new programming interface of three pins, in a half-duplex protocol. Because the /RESET line needs to be raised to +12V for programming when the device's RSTDSB pin is set, this is currently only supported by the newer STK600 programming board.

Bonus FAQ Section!

1) Which is the best method?
There is no universal "best" method. ISP programming is simple and extremely popular, however all the above methods will work. The two high voltage programming modes (whichever is applicable to your device) are the most feature rich, as they allow for the repair of an AVR which has had its fuses misconfigured. However, those methods are a pain to set up, hence the reason most users go with with ISP.

2) I've made a parallel port dongle. Can I use it with AVRStudio?
I'm afraid not. AVRStudio cannot interface with any "dumb" dongles - it requires a smart programming device - containing a microcontroller itself - to decipher the communication protocol it sends. Simple dongles without a microcontroller must be "bit-banged" (ie. the appropriate signals simulated through the dongle via the computer) itself.

3) So my dongle's useless then?
No. You can still program through a home made dongle with a third party programming software tool. AVRDude is a good, known, free command line utility - and it comes included with the WinAVR package.

4) What are my options if I want my programmer to work with AVRStudio?
Choose a programmer that uses an AVRStudio-supported protocol. This can be the simple "AVR910" protocol (deprecated) or a custom implementation of the protocol used by the STK500/AVRISP. Note that these programmers require a micro controller in them, leading to a catch-22 situation. This may be solved by having the programmer's AVR pre-programmed at time of purchase with the appropriate firmware, or by having the AVR pre-programmed with a bootloader.

5) Ok, I want to use a bootloader. How do I get it in there in the first place?!
To use a bootloader in an AVR, you first have to have the bootloader programmed in. If you do not have an existing programmer (even a simple dumb dongle will suffice for the initial programming), you can alternatively purchase AVRs pre-programmed with a bootloader from several suppliers.

Atmel also manufactures the Butterfly demo board, whose MEGA169 AVR comes pre-loaded with an AVR-Studio compatible bootloader.

6) Help! I've messed with the fuses and knackered my AVR while using ISP!
The most common mistake is changing the clock selection fuses to an invalid setting. Try putting an external clock on the AVR's XTAL1 pin and see if that helps.

Failing that, if possible use one of the high-voltage methods. These will fix any misconfiguration, including ones involving the clock source as the high-voltage methods provides its own clock to the AVR for programming.

7) How do I interface with my programmer?
Which software you use to interface with your programmer depends on the type of programmer you are using.

Simple "dumb" dongles require third party software, such as PonyProg or AVRDude. These may be command line or GUI tools - look around on the web and you will fine one to fit your needs.

Programmers and bootloaders based on the AVR910 protocol can be used within AVRStudio. From the Tools menu, select the "AVRProg" option to open up a GUI screen to interface with your programmer. As an alternative, third party tools such as AVRDude are also AVR910 compatible.

Official tools are tightly integrated into AVRStudio, especially in the case of the debugging variants (JTAG/Dragon/etc). From the AVRStudio Tools menu, select the "Program AVR..." submenu and click the "Connect" item. From the new window, select your tool and its connection interface and click ok.

As is the case with the dumb dongles and AVR910 programmers, the official tools may also be used with third party programming software.

- Dean :twisted:

(C) Dean Camera, 2009. All rights reserved. Not for reproduction on any website other than AVRFreaks.net without prior explicit permission.

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

Last Edited: Thu. Sep 20, 2012 - 06:14 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ecxellent! Just add examples!

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

Quote:

METHOD 3: Bootloader
Supported By: MEGA AVRs
Supported Programmers: N/A

Hi Dean,

I think it would be more accurate to say bootloaders are supported by most newer AVRs since there are Tinys that support bootloaders also.

Thanks!
Mike H.

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

mikehg1,

You're right - I wasn't sure about the new TINYs so I played it safe. I've fixed my post - cheers.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

Nitpick #2:
The ISP programming method isn't available on two currently in-production AVR's:
-ATtiny28
-ATmega406 (According to preliminary datasheet)

As well as at least one "mature but still available" AVR:
-ATtiny11

These devices must use HVPP ('406 and '28) or HVSP ('11) or JTAGmkII ('406) or Bootloader ('406).

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

Thanks for this tutorial... I'm sure it will help many AVR programmers who are starting... (like me...).

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

By "ISP clock" do you mean the clock on the SCK pin?

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

hooloovoo wrote:
By "ISP clock" do you mean the clock on the SCK pin?

Yes indeed. If your AVR is running at a speed of 1MHz, the maximum SPI speed (SCK) is one quarter of that, 250KHz.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

Good deal, thanks!

I was *comfortable* with all but the JTAG stuff, you have verified for me what I thought I knew and added the JTAG knowledge.

Thanks again!

  • "Give me six hours to chop down a tree and I will spend the first four sharpening the axe."  -- Abraham Lincoln
  • "All right wise guy, where am I?"   -- Daffy Duck
  • "Well, we're safe for now. Thank goodness we're in a bowling alley."  -- Big Bob, Pleasantville
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for the excellent tutorial. I'm just starting out with AVR after working with Microchip PIC chips a little. I still have a question after reading your tutorial. Pardon me if it's been posted somewhere in these forums. Says if I pick the ISP method of programming, does the target AVR have to have power and xtal connected before it could be programmed? With some PIC's that I've been working with, I just need to connect a few wires (5) to the pins of the bare chip to program it. Power to the chip was taken from the programmer (serial JDM programmer). The PIC doenst need an Xtal. I wonder if its the case with AVR?

Thanks

Thanh

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

It depends. AVRs DO need both a clock source and a power source, but in the case of the former the more modern AVRs have an internal clock source which is enabled via default (making power the only external item to be connected other than the programmer).

Older 90S series AVRs do not have an internal clock source, and so will need an external crystal to run. If you're using an AVR with an internal clock, it is enabled via default (from the factory) and usually runs at about 1MHz - this means that you should try ISP programming at 250KHz or less to start with.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

Thanks very much for the information Dean!

Thanh

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

Great tutorial! Thank you...

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

thanks a lot.

praveen

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

very useful information
thank you

mr blonde

Codevisionavr & Avrstudio 4.18
Easyavr5A-Jtagicemk1

Call me Pedantic, But not after 9.

if Milk_Brilliant
else Codevision_Avrs==Better

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

Good memo Dean.

It appears you have kept this information up to data because you included the newly released Dragon board.

A question I have had for several months now is how do you use the debug wire to program the AVR?

Regards,
Jim Braden

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

I appreciate all the above messages of thanks, it validates my work :).

jimbraden: I do indeed try to keep it updated. I should probably include dW as well, although it really is meant purely for debugging rather than for programming.

dW requires a JTAG-MKII, or a Dragon. To use dW, you first connect the JTAG to the target in a configuration that allows for normal ISP programming. Once done, you can then tell the IDE to send the commands via ISP to enable the DWEN (dW ENable) fuse to start the session.

One the session has started, you can program the device by starting a debug session. This will program the target and allow you to view the internal chip status at any point in time.

dW remains active until the session is closed by turning off the DWEN fuse. This means that you can program the AVR via a dW session, then close the session to leave the code in the target.

Leaving a dW session unclosed in a production device is VERY unwise, as it disables the /RESET pin functionality.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

Another limitation of debugWire is that it prevents certain system clocks from ever being disabled, even if the part is placed into a deep sleep mode. That will increase power consumption. debugWire uses the same clock as the SPI module; if your software attempts to save power by disabling the SPI clock using PRR, then the debugWire interface will lock up. As well, I haven't seen any hard evidence about how effective the memory protection lock bits are while the debugWire interface is enabled.

I guess it's appropriate to mention debugWire as a programming interface. But it should always be included with a huge caveat: Its limitations make it inappropriate to use as a general-purpose programmer for production purposes!

In order to get the chip back into a fully functional state, you must disable the debugWire fuse; In order to disable the debugWire fuse, you must have a full-up ISP connection (reset/sck/mosi/miso); All ICE units which support debugWire (Dragon, JTAGICE mkII) can also be used as general-purpose ISP programmers; If you have the full-up ISP connection in place already, then you're better off using the ISP connection for the production programming in the first place because it is more reliable, probably faster, and allows modification of all fuse/lock bits.

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

Hi. I have been searching for the longest time for a tutorial such as this to get me started. Thank you very much.

However, I have a question about the DB-25 connections. I have been looking at other websites and found that there are many different layouts as in which pins are used.

http://www.bsdhome.com/avrdude/
uses pin 7-10, 18

http://www.instructables.com/id/...
uses pin 1,2,11,16,18

http://elm-chan.org/works/avrx/r... (while it was working which is just a few days ago)
uses pin 2-4,11,18

I am wondering which one will work with AVRStudio 4. Could someone help me out here?

Many thanks,
Ken

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

None of them.

AVRStudio does not support Parallel Programming dongles. It has limited support for serial "AVR910" programmers, but it's designed for the official Atmel AVRISP/Dragon/STK500/JTAG systems.

All the dongles are different since there are several IO lines in the parallel port connector, yet only a few are needed for the ISP signals. Whichever one you choose to make, you need to configure your third party programming software (eg AVRDude) up the same way for it to work.

EDIT: Added in a new FAQ section to the original post. If you want a question addressed in that FAQ, post it here!

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

Thanks Dean, but I seem to be getting more and more confused with all the new softwares I have to learn how to use. Allow me to describe my current situation. I have installed AVR Studio 4 and WinAVR, and have made a dongle. You explained that AVRdude comes with WinAVR. Does this mean that I don't have to download and install AVRdude? With all my current hardwares and softwares, is it possible for me to program a chip? If so, is there any tutorial on how to go from AVR Studio to a working chip? I have been looking at sample codes in both AVR GCC and ASM, however I have only ran those codes with the simulator in the studio thusfar.

Please excuse me if these questions sound basic or can easily be answered on google or have already been covered somewhere else. I am simply running out of time. Any help is greatly appreciated.

A Real Amatuer,
Ken

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

AVRDude is a command-line programming software. Unlike AVRStudio, it supports simple "dumb" (i.e. passive components only) dongles just fine.

AVRDude is included with WinAVR - you don't need to download anything else. To use it from the command line, just open up a new command console from the start menu (START->Run, type "cmd" with no quotes and press enter). Type "avrdude" and press enter to give a list of all the possible command line options.

For the AVRDude manual, check your C:\WinAVR\doc\avrdude\ directory. That will teach you how to configure the command line options for your dongle. Once all done, you can always create a batch file to automate the process.

EDIT: Someone's just made a new GUI for AVRDude to make your life a lot easier. I haven't tried it myself, but check it out yourself.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

Thank you very much, Dean. This has definitely been a productive Christmas break. I feel I am one step closer to have a working AVR everyday. Now that I am somewhat familiar with AVR Studio and AVRdude, all what's left is to read about WinAVR, and then to actually get some hands-on experiences when I get back to Skule. Thank you again for all your help.

Dream of one day when I can help others,
Ken

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

Thanks for the description of really necesary basics.
Please, could You tell a simple word how to start programming with AVRStudio?
I have AVRDragon and can use it to programm device only by running comandline tool AVRDragon.exe.

To explain how one could start, I can write an C or ASM program, set make output to Intel HEX, and then use external programer to transfer generated data to device.

I have had simple parallel port isp programmer, it works well as ISP with Ponyprog. I consider it easy to use, comfortable and intuitive tool to program any ordinary avr device, its fuses and lock bits or eeprom. In case I need some troubleshooting, I see the data and in case i wish I can enable editing and change some values directly in it.
I can use commandline AVRDude, telling it that my LPT programmer is pony-STK200, I have tested it and it works.

Recently I purchased AVRDragon.
Now I have an oportunity to work with JTAG and Dw, as well as old good ISP and eevn HVPP. However, I am scared by the lack of any gui tool to help me see what I do.
My AvrStudio (latest build, 498) will show "no supported board found" if I will try to select AVRProg from menus.
I can run commandline AVRDragon.exe with few params and read/write device using the same ISP as I did.

Anyway - Could someone help me, and perhaps the others, and let me see the user manual for AVRDragon? The only I found is help that comes with AVRStudio, but I found not even led colours description.

My primary point is to find some easy to use gui based programmer like PonyProg is, to use it with my new Dragon - just to keep the work comfortable.
For a newbies, as an tutorial, I guess it is very helpfull, even if experienced proffesional can write the flash directly from makefile.

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

coro:

I could add in a small section as a FAQ question, however I think anything really in-depth would be outside the scope of this tutorial and in the realms of another, seperate tutorial.

However, using the Dragon is easy.

FOR DEBUGGING A PROJECT:

    1) Connect Dragon to PC and target via JTAG/dW. 2) Open project ELF file with AVRStudio (or open existing project). Select as the platform the Dragon.
    3) Follow prompts.

FOR PROGRAMMING:

    1) Connect Dragon to PC and target via JTAG/dW. 2) From the Tools menu, chose the "Program AVR" submenu and click Connect...
    3) Choose the Dragon from the platform list, click OK
    4) Use GUI to program target

Note that AVRProg in AVRStudio is designed for AVR910 style programmers and bootloaders, while the Program AVR->Connect... is used to connect with the official ATMEL tools such as the STK500, Dragon et al.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

Thanks for the help,
I think that I should write the reason of my troubles here, to help others in case of the same issue.

There is no submenu "Program AVR" in AVRstudio at all,
until You will enable STK500 plugin from "Plugin manager".

If STK500 was enabled (even if I have nothing like
that kit), then, after exit and next AVRstudio
start, necesary submenu is there and runs with
AVRDragon without any problem in any mode You choose.

Edit to explain :
I have installed AVRstudio long time before my purchase of AVRDragon. Because I did use only simple parallel programer (74ls244) and PonyProg, I did disabled everything unused just to not waste memory and startup and project open time a looong time ago. After upgrade of AVRstudio, plugin setting probably remain unchanged.
Anyway, that could happen to anyone, and as I have never seen what I need, it was hard to search for.
As well, using google with "program AVR" is difficult because of milions of matches.

Last Edited: Wed. Jan 10, 2007 - 12:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Interesting. The STK500 plugin comes automatically pre-enabled in every installation of AVR Studio I've ever performed.

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

I was confused with all these terms and today I got my answers. Thanks Dean. I still have confusion not related to these but other terms ie. i2c, spi, parallel if you please explain it in just two three lines. I was googling but unable to catch the fundamental differences in these terms.

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

Updated to include the DebugWire and PDI interfaces, and the SKT600/AVRONE programmers.

Quote:

I still have confusion not related to these but other terms ie. i2c, spi, parallel if you please explain it in just two three lines.

They're communication busses. I2C is a multi-master two wire bus, allowing several devices to connect to one another and send messages via the I2C protocol. SPI is a basic serial interface which has each device on the bus implement a special enable pin, so that a single master can talk to any one slave on the bus at the one time. "Parallel" can refer to many things but means several bits being transferred simultaneously over several wires for faster transfers.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

hi, abcminiuser

how old are you? 19 years old?? is it true??

woooow ... interesting.. smart kid!!!

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

Hi suriva,

Yep, 19 indeed! I don't think age matters much - it's all about passion and talent. At least, that's what I tell myself after yet another 5 hour debugging marathon for that one elusive bug that's been bothering me for weeks ;)/

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

If your fuses are set to an external clock, can you use a programmer, such as the AVRdragon, to supply the clock source through jtag? I have very limited knowledge and am trying to find the simplest way to reset a chip back to internal clock.

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

Quote:
If your fuses are set to an external clock, can you use a programmer, such as the AVRdragon, to supply the clock source through jtag? I have very limited knowledge and am trying to find the simplest way to reset a chip back to internal clock.

Not with the Dragon but certainly with an STK500 (which has an external clock generating circuit) you can produce the necessary "recovery square wave" for pumping into XTAL1. Apart from STK500 other methods are frequency generator, simply NE555 circuit, another AVR with a small program to toggle a port pin, another (of the modern!) AVRs with the CKOUT fuse set.

Cliff

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

Thanks for this clear and concise summary! I have been searching for this type of info for a while ( looked in this section before and somehow missed it).

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

Quote:
I guess it's appropriate to mention debugWire as a programming interface. But it should always be included with a huge caveat: Its limitations make it inappropriate to use as a general-purpose programmer for production purposes!

In order to get the chip back into a fully functional state, you must disable the debugWire fuse; In order to disable the debugWire fuse, you must have a full-up ISP connection (reset/sck/mosi/miso); All ICE units which support debugWire (Dragon, JTAGICE mkII) can also be used as general-purpose ISP programmers;


I have a Dragon board and can program my ATTiny85 using ISP without a problem.

But, when I attempt to debug code running on the HW I have to enable the debugWIRE interface (makes sense).

Once enabled all seems well until I attempt to reconnect to the Dragon board with my programmed and debugged chip in place.

At that time I can no longer connect to the chip to disable the debugWIRE interface, erase or reprogram the device.

This seems to be a "one way street", destructive debug method at least with this device?

What am I missing?

Turns out I was missing the later thread that explains the problem.
:oops:

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

Hey Everyone,

Dean mentioned having the AVR's pre-programmed. I am looking to order about 1000 ATTiny2313's in an MLF package, pre programmed with my software.

Does anyone know where I can get this done?

Thanks,
Dan

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

Hey,

I have never programmed an avr before (used pics before) and am trying to use the stk500 to program an atmega644 which unfortunately is in-circuit on a PCB I have designed. I get the message "Entering Programming Mode..Failed". I have tried some of the things mentioned in other posts such as changing my ISP frequency to 4k, making sure my fuses and lock bits are correct (although the spi enable box is greyed out, i am not sure if its supposed to be like that). Another thing I think might be a cause of a problem is that on my PCB I have SPI IC's with active LO chip selects and these are set HI in code (when the avr is working) and so before the avr is programmed, the chip selects may become enabled (which is bad h/w design on my part) and might be causing SPI interference. I am also wondering if I have bad versions of firmware on the stk500 and should update that.

Any suggestions or things I should look for would be greatly appreciated because I am a little lost and want to start debugging my firmware!

Thanks,

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

Quote:

these are set HI in code (when the avr is working)

You need some 10K pull-ups on those _CS lines - should be possible to piggy-back these onto the current PCB?

The other common error is to get the layout of the 6/10 pin ISP header wrong. The pictures in the manual show it looking down from above.

Cliff

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

Hey thanks for the help. But now I have more problems..

When I try to verify the signature, it only works at 4kHz, when I go above, nothing works and I get a "Failure" when I try and do anything. Why does this work at 4kHz and nothing higher? I am using an external clk (above 8Mhz) in my fuse bits. This doesnt work so well because you can only use isp above 5kHz. Can anyone help me out a little or help me narrow the area to troubleshoot. Could it be my xtal?

Thanks,
Kylee

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

Quote:

Why does this work at 4kHz and nothing higher?

Sounds like a ground/noise/cable length or similar problem

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

hmm..im looking on the scope and when I increase the isp freq to 56kHz, I can see sclk (which is at 56k, as it should) and miso is outputting data, but it still gives me this error. I am wondering why the data is going into the uC at the correct freq. but I still get this error. I only have one gnd on my board, which I am powering separately from the stk 500. There could very well be a noise problem but I am not sure, my signals are a bit noisy, but im not sure if its too noisy. Grr frustrating! Why doesnt it allow programming under 5kHz!

Edit: The error message doesnt show up until after the data has been, could this mean the uC is not sending back a command that says "got the data" on mosi.. this could mean the uC is fried..?

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

ISP Program 1 FLASH byte in assembly code Atmel 328

Is there such a thing?

for the Atmel 328 Product

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

You appear to be talking about SPM being used for "bootloader" programming rather than a physical ISP device (the subject of this thread)

BTW it's not possible to update a single byte as programming can only switch 1 bits to 0 bits and to switch any bits from 0 to 1 an entire page (typically 32, 64 or 128 bytes) must be erased and reprogrammed. So if only a single byte is to be changed the other 31, 63 or 127 must be read first and programmed back afterwards.

Each page has a 10,000 erase cycle limit.

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

Hello,some chips like the AT90USB82 have a usb interface and a boot loader program preloaded in factory.does this solves the "chicken and egg" problem?
From the docs it seems that it uses by default the internal clock that is not valid for the 48MHz pll clock signal required by the usb module.

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

Quote:

does this solves the "chicken and egg" problem?

Yes it does (a pre-loaded bootloader always will).

But I think you are wrong about "internal clock". I'd be guided by Dean (abcminiuser) if I was you but as far as I know, for USB timing accuracy, the chip must have a 12MHz crystal that the internal PLL then winds up to 48MHz

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

The USB AVRs need an external 8MHz or 16MHz crystal source. The U4s at least can also run in a limited manner in Low Speed USB mode on the internal 8MHz RC oscillator, but I can't remember if the others support that.

Atmel ships the USB AVRs from the factory with a bootloader installed and the fuses set for an external crystal, from what I've seen.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

In the documentation says:
The device is shipped with internal RC oscillator at 8.0 MHz and with the fuse CKDIV8 programmed,
In the AT90USB82/162 product, the Clock Multiplexer and the System Clock Prescaler can be
modified by software.

Does this means that the boot loader can program the chip to use a external clock source (crystal)of any valid frecuency and setup it correctly?

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

Quote:
Does this means that the boot loader can program the chip to use a external clock source (crystal)of any valid frecuency and setup it correctly?

There are no AVRs in which you can switch between internal and external clock sources in code. But you can change the pre-scaler in code to affect whatever clock is selected.

Regards,
Steve A.

The Board helps those that help themselves.

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

Quote:
There are no AVRs in which you can switch between internal and external clock sources in code.

Well, the new ATtiny4/5/9/10 have the CLKMSR (Clock Main Settings Register) for this purpose:
Quote:
These bits select the main clock source of the system. The bits can be written at run-time to
switch the source of the main clock. The clock system ensures glitch free switching of the main
clock source.

And of course there is the xmega.

Regards
Sebastian

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

Quote:

In the documentation says:
The device is shipped with internal RC oscillator at 8.0 MHz and with the fuse CKDIV8 programmed,
In the AT90USB82/162 product, the Clock Multiplexer and the System Clock Prescaler can be
modified by software.

I'm 90% certain that paragraph is incorrect, and I think I remember going over this before here with someone else asking the same question. I'm sure at the factory they're set like that, but when they load the DFU bootloader onto each one they switch it to use an external crystal instead - at least, that's how the one I placed on a board myself was configured.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

would hex code written and compiled for at90s2313 work on attiny2313 if not please explain thanks alot
sonhai

Pages