2010年10月10日 星期日

ISO JTAG ISP programmer

ISO JTAG ISP programmer
JTAG header pinout:
1: TCK
2: GND
3: TDO
4: VCC
5: TMS
6:
7: VCC
8:
9: TDI
10: GND
ISP Programming header pinout:
1: SCK
2: GND
3: MISO
4: VCC
5: RESET
6:
7: VCC
8:
9: MOSI
10: GND


News
20081204 - Documentation ready.
20081125 - Started porting documentation from Andrew's website
20090630 - Several errors were corrected. ratkymarcell

What is ISOJTAGISP
The IsoJtagISP is an optically isolated usb programmer for Atmel AVR's that combines a JTAG programmer/debugger and an ISP programmer. In JTAG mode it is fully compatible with Atmel's 'JTAG ICE', and can be used any way the AVR product can, including programming and debugging with AVR Studio.In ISP mode it is compatible with the AVR910 Application note, and can be used from AVR Studio via the AVR Prog program to program devices compatible with ISP programming.
I
'd also like to recommend AvrOspII for programming in ISP mode, it's much more user friendly and has better device support than AVR Prog.

It has the benefits of usb connection (great for laptops without serial ports) and is completely isolated from the target micro. This protects your valuable computer from mis-wiring of the target board, with my previous programmer I blew up a serial port on old laptop, a usb port on new laptop and 2 usb-serial cables, before designing my original IsoJTAG programmer.

The IsoJtagISP is electrically identical to the IsoJTAG, the pcb layout has simply been optimized. The ISP programmer has been implemented completely in firmware. The firmware consists of a bootloader to load the atmel JTAG firmware from AVR Studio, and the ISP firmware, which is based on the AVR910 application note programmer, which I ported to the JTAG hardware and the ATmega16. The bootloader effectively dual-boots between the JTAG and ISP software.

The Bootloader header from the IsoJTAG is now used to select between JTAG and ISP modes. When in JTAG mode the programmer is receptive to JTAG firmware upgrade for the first few seconds of power while the activity led if flashing. Run AVRPROG is this time to upgrade. When in ISP mode run AVRPROG at any time to program the target micro.

Hardware Schematic














Bill of Materials
Description
Designator
Quantity
Value
Capacitor Electrolytic
C7
1
100uF
Capacitor
C8, C9, C11
3
220nF
Capacitor
C10
1
220nF
Typical GaAs LED
D1
1
LED 3mm red
Typical GaAs LED
D2, D3
2
LED 3mm green
Header, 3-Pin
ISP
1
3 pin header
Header, 5-Pin, Dual row
JPJTAG
1
5×2 headers
Resistor
R1, R2
2
1k 0603/1608
Resistor
R3
1
1k
Resistor
R4, R5, R6
3
10k 0603/1608
Resistor
R7, R9, R11, R14
4
470R
Resistor
R8, R10, R12, R13
4
470R 0603/1608
Microcontroller
U1
1
ATmega16, TQFP
USB-Serial
U2
1
FT232-RL
Optoisolator
U3, U4, U5, U6
4
6N137S
Ribbon Cable Connector 5-Pin, Dual row, Right Angle
JP1
1
Male
USB Jack

1
USB B Socket
10 way ribbon cable

15-30cm

2×5 pole ISP connector for the cable

2

 PCB















 Keep in mind that the pcb here has a very fine pitch, the usb chip in particular has pads with only 
0.25mm between them. If you don't have a method of making a board (other then asking a professional board house to do it - expensive) consider getting our eBook, which details how we make the boards here.

Firmware
The firmware is written in AVR studio with WinAVR installed. The bootloader is written in C, the ISP firmware is written in gcc assembler.

If you want to rebuild it for a different frequency crystal (only tested at 7.3728MHz, 8MHz and 12MHz) open the project file in AVR Studio, look in crystal.h. If your frequency is already listed as a define at the top of the file, uncomment out your speed and comment all the other freq defines. If your speed isn't there then add a new define line for your speed, and open up crystal_calc.xls from the source folder (excel spreadsheet, I use openoffice). Change your speed in there, and copy the block in the spreadsheet down the bottom of crystal.h. You should now be able to recompile the project.

The patching code is only enabled when the value is set to something other than 7372800, which is the original default setting. The only problem I've found when running at a different cystal is that a serial port speed of 115200 often doens't work (depending on particular frequency). In normal operation this isn't an issue, I've never found a need to change the port speed at all from the default (19200) except for a bug in avr studio, that can result in synchronization errors. I'll discuss this in detail later.

Assembly
Building
Many of the parts for this programmer can be sourced at your local electronics shop. The difficult items are likely to be the 7.3ish crystal, the usb chip and the micro. Any of the ATmega16's in the tqfp44 package will work here.

The 6N137S Opto-Isolators can be replaced with 6N137 version (non-surface mount) if you can't find the 'S' ones. Both parts are the same size and shape, except that the non-surface mount one has straight pins to go through a pcb, but a quick bend with pliers and trim to size will make them work perfectly well. If you find another opto in the same package that is sold as a high speed opto, you can check the datasheets for both and compare, there are probably plenty of other devices that can work. Note that basic optos generally don't work because they are too slow.

Flahing the programmer
The biggest barrier to building this programmer is programming the onboard micro. I originally designed it for myself, and as I was already using a jtag programmer I used that to program the micro for this. The 10 pin header in the middle of the board is for this purpose.

If you already have a serial or parallel ISP style programmer it can be used to program the micro, but it's up to you to tack wires onto the pcb to do so. The pins required are the reset line and some of the lines going to the opto's. I assume that if you have one of these programmers you also know which pins to conenct it to.
As mentioned earlier the board is designed to use my IsoJtagISP firmware. Once the bootloader has been programmed the fuses need to be set appropriately. Check with your programming software to find out how to do this.

If you are building V2.1 and above, without a crystal, the important fuses are „external clock”, „boot-reset”, „boot-size 1024 words” In Avr Studio it looks like this (for no crystal):






















If you don't have any means of programming the micro drop us an email at sem@sch.bme.hu and we should be able to send you a programmed micro for the cost of the micro and postage.

Drivers
Once the board's finished and the micro's programmed , the next step is to get the drivers installed. Use a jumper (like used on pc motherboards) to set the „J I” jumper to J (for JTAG). Plug the programmer into your pc with the usb lead. The power led should come on. You will need the VCP driver for the ftdi usb chip available here. I've had reports from one user that his Windows 2000 computer occasionally has a 'blue screen' error when the programmer is plugged in while booting. I haven't been able to reproduce this problem myself, but if you have issues simply make sure the programmer isn't plugged into your computer while it is booting, or contact FTDI for assistance as the driver is their software.

FT232R Settings
If you're building without a crystal you will need to program the ft232r chip to send out the clock for the micro. Luckily this is easy, as FTDI provide a program to do this over the serial port. So plug in the programmer, download MProg from the sources section above, run the program, then find read and parse in the menus to check that it finds the programmer. As long as it does, open up the template that's in the mprog folder, and you should be able to go to program in the menus to flash the settings into the ft232r chip. It should now be ready to go, so unplug and replug the programmer, windows will re-detect it as an isojtagisp.

Port Settings
Once the driver's loaded you have to make sure it is running a low enough com port that AVR Prog can detect it. For this it needs to be between COM1 and COM4. To do this go to device manager by clicking on start menu, go to run, and type (or copy&paste) „devmgmt.msc” . With the programmers usb plugged in go to „Ports (COM & LPT)” and there should be a „USB Serial Port” in the menu (hopefully only one of them, if there is more try re-plugging the programmer a couple of times to identify which one is it). If the com port in brackets after the name isn't either COM1, 2, 3 or 4 right click on it and go to properties. Go to the „port settings” tab and click the „Advanced” button. The first item in this dialog lets you change the port that the virtual com port is using. Hopefully you don't have too many other real or virtual com ports in use, if any of 1-4 are free select them, or select one that says it is „in use” if there isn't an item in the ports menu of device manager currently running on that number. Once that is done unplug the programmers' usb and re-plug it in. If you're not using windows older than xp or have problems later you may need to reboot your computer as well.

Once that's done start up AVR Studio. Cancel out of any project wizard or anything else that comes up when it starts.

Uploading the JTAG ICE Firmware
       If you flashed the programmer with a firmware with preloaded JTAG code, this you can skip this step.
If the selected mode is JTAG, you get a chance to update the JTAG firmware at power-on. With no JTAG firmware on the programmer it will stay in this state indefinitely, but after the first firmware is uploaded, you will only get a few seconds in the future.

Unplug the programmer, and then re-plug it in and while the activity led of the programmer is flashing go to 'tools' menu, 'AVR Prog…'. You should now get the AVR Prog programming dialog come up. If it gives an error 'no supported board can be found' you've got a problem. Try unplugging and re-plugging the programmer and/or unplug any other usb serial devices if you have them and try again. If still no-go, check the com port it is running on again, and check the programmer pcb carefully for faults and try reprogramming the bootloader and the fuses again.

Once you've got the programming dialog up, program the micro it with Upgrade.ebn which can usually be found in C:\Program Files\Atmel\AVR Tools\JTAGICE. Hit program and wait for it to finish. This will take some time, 5 to 10 minutes. It should finish without an error and then hit exit. Occasionally for me I get a box pop up saying „flushing” in between programming and verifying, it can be ignored so hit ok. If it comes up with an error it's not the end of the world. Try programming again and get in touch with us if it error's again.
All done.

You've now got a fully operational jtag programmer for working with avr micro's. For further information on how to use it I suggest looking for documentation on the 'AVR JTAG ICE' on atmel's website and on avrfreaks. In JTAG mode you can program and debug any of atmel's micro's that have onboard jtag programming. Remember the power-on boot wait in jtag mode, when it's first plugged in to usb you have to wait for the activity led to stop flashing before the jtag is ready to use.
   Be sure to reboot the programmer before panicing why it wouldn't work :)

Usage
AVR Studio
In AVR Studio you can use „Tools –> AVR Prog” to program AVR's in ISP mode. This is kind of a hack, and I intend to develop a plugin for AVRDUDE (which supports this programmer, along many) so that it would integrate nicely into AVR Studio.
JTAG mode is supported natively by AVR Studio, just select JTAG ICE from the programmer menu.

Pinouts
When you make your circuit with a micro on it (the target micro) add a 10 pin IDC style header to the circuit and wire it to the target micro's pins as labelled in the pinouts below (ie. pin 1 of the prog header goes to the TCK pin of the target micro, which is pin 21 on a mega16).
One of each of the VCC and GND pins can be left unconnected, as long as you have one of each powered. This can simplify pcb layout significantly in some cases.

 You MUST connect the VCC and GND pins, as the optocouplers are powered by the target board!
 This is NOT the standard ISP pinout used by Atmel!
JTAG header pinout:
1: TCK
2: GND
3: TDO
4: VCC
5: TMS
6:
7: VCC
8:
9: TDI
10: GND
ISP Programming header pinout:
1: SCK
2: GND
3: MISO
4: VCC
5: RESET
6:
7: VCC
8:
9: MOSI
10: GND
Supported devices
From AVR Studio:
AT90S1200
AT90S2313
AT90S4414
AT90S4433
AT90S2333
AT90S8515
ATmega8515
ATmega8515 BOOT
ATmega103
ATmega603
ATmega128
ATmega128 BOOT
ATmega64
ATmega64 BOOT
AT90S2323
AT90S2343
ATtiny12
ATtiny15
ATtiny19
ATtiny28
ATtiny26
ATmega161
ATmega161 BOOT
ATmega163
ATmega83
ATmega163 BOOT
ATmega83 BOOT
AT90S8535
ATmega8535
ATmega8535 BOOT
AT90S4434
AT90C8534
AT90C8544
ATmega32
ATmega32 BOOT
ATmega16
ATmega16 BOOT
ATmega8
ATmega8 BOOT
ATmega169
ATmega169 BOOT

Notes
Use the J | I header to select JTAG or ISP mode. In the absence of a jumper, JTAG mode will be selected. After changeing the programmer mode, it needs to be rebooted.

In JTAG mode, the device emultes the JTAG ICE mkI To use the ISP programmer, go to AVR Prog from AVR Studio, Tools menu.

As the ISP programmer header pinout is not the same as Atmel's standard, an adapter can be used to change the pin order.

Known issues and bugs
The Synchronization Problem
There is an annoying quirk when running the programmer on non-standard frequencies that can't handle the top serial speed, 115200Kb/s, such as 8Mhz and 12MHz. For some reason in AVR Studio, when you run the jtag ice programming util (to set fuses, lock bits, etc.) if the page it first comes up with is fuses, lockbits or board, avr studio momentarily changes the port speed to 115200 and the programmer drops out, leaving you with a synchronization error. If it starts up on the program, advanced or auto page it's fine though, and stays at the selected speed (default 19200). So if you get a synch error, simply select one of the ok pages (program, advanced or auto), close te jtag ice window, and start it again. Then it works fine. As long as you get into a habit of just leaving the jtag ice screen on one of the ok pages it's never an issue. I've sent an email to Atmel to try to get this issue sorted out, as there is no good reason for their software to change the port speed like that.

Another Synchronization Problem
You will not be able to program in either JTAG or ISP mode under AVR Studio 4.14 and 4.14sp1 due to a bug. AVR Studio does not take under consideration the selected port speed, and will always try to use baud 115200 for communicating with the device. Because of the nonUART frequency of the ATMEGA in the programmer, this will lead to desynchronization. I have already contacted ATMEL on this issue, and they have promised this will be fixed in the next version.

Copyright and licensing
ISOJTAGISP has been designed by Andrew Leech. We at the „Schönherz Elektronikai Műhely” only maintain the documentation for the programmer. The documentation is based on Andrew's website, some old stuff have been removed, and things have been neated up.

The licencing terms from Andrew Leech:
As all the plans are here, you're more than welcome to do with them anything you like for **personal** use.
The programmer and documentation will not be used for commercial purposes (including but not limited to selling units you've built) without my (Andrew Leech) express permission.

Just to clear thing up, you're more than welcome to build these and then use them to develop products for sale, but you can't sell the actual programmers or any part of the programmer design/firmware.

Downloads

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。