Connection diagram jtag ice atmega8. What is a JTAG programmer? Connecting to the device being debugged

1 Description

USB AVR JTAG is a tool for debugging devices based on microcontrollers AVR family from Atmel. AVR JTAG is a complete analogue of Atmel's AVR JTAG ICE, complemented by a USB interface. For getting additional information Documentation from Atmel can be used to learn how AVR Studio works with AVR JTAG.

To work with AVR JTAG, the AVR Studio program from Atmel is used. AVR JTAG supports all microcontrollers of the family that have a JTAG interface in the supply voltage range of 2.5-6 V:

  • ATmega16;
  • ATmega162;
  • ATmega169;
  • ATmega32;
  • ATMega323;
  • Atmega64;
  • ATmega128.

Support for new devices is provided by updating the AVR JTAG firmware, which is included with AVR Studio.

Figure 1 Location of connectors and indicators on the AVR JTAG board

2 Scope of delivery

The USB AVR JTAG package includes:

  • USB AVR JTAG board;
  • cable for USB connections AVR JTAG to computer;
  • cable for connecting USB AVR JTAG to the device being debugged;
  • CD with software and reference information.

3 Connection

In order for AVR Studio to automatically detect the USB AVR JTAG, you must connect the USB AVR JTAG to the computer, device you are debugging, and supply power to the USB AVR JTAG (if using external source power supply) and the device being debugged before starting AVR Studio.

3.1Connecting to a computer

USB AVR JTAG connects to standard USB port computer. The connection uses a standard USB cable(included in delivery).

3.2 Connecting to the device being debugged

To connect to the device being debugged, 6 lines are used: TCK, TDO, TDI, TMS, VTref and GND; connecting these lines is necessary for proper operation AVR JTAG with the device being debugged.

Additionally, the nSRST line can be connected to the device being debugged (used to control and monitor the microcontroller reset line). Using this signal is not necessary for debugging, however, if the microcontroller program sets the JTD bit in the MCUCSR register, the JTAG interface will be disabled and will require the USB AVR JTAG to be able to drive the microcontroller's reset line to enable it.

3.3 Power connection


Figure 3 Connecting AVR JTAG to the device being debugged

The USB AVR JTAG is powered by USB or an external DC or alternating current.

There is one problem when powering the USB AVR JTAG from USB:

  • When measuring the target voltage, an error is possible (up to 0.5 V depending on the design of the motherboard output drivers).

Therefore, if accuracy is important to you when measuring the target voltage, use an external power source.

The power source is selected using the “power” jumper.

To connect the source to the USB AVR JTAG, a socket for a D 2.1 mm plug is used.

Source polarity direct current doesn't matter.

In order for AVR Studio to detect AVR JTAG, it is necessary that the power of the USB AVR JTAG and the device being debugged be turned on before debugging begins (using the Start Debugging AVR Studio button).

Any unstabilized 6-9 V source or stabilized 9-12 V source is suitable as a power source.

  • turn on the power of the device being debugged;
  • launch AVR Studio.

4 Software update

Updating the USB AVR JTAG firmware can be done either automatically or manually.

4.1 Automatic update

Automatic update occurs if AVR Studio detects that the firmware version included with AVR Studio is greater than the USB AVR JTAG firmware version. In this case, AVR Studio displays a corresponding message and prompts you to update the firmware. If the user agrees to perform a software update, AVR Studio displays a dialog with instructions for updating the software. To update the software, follow these steps:

  • remove the “upgrade” jumper on USB board AVR JTAG;
  • click the "Ok" button in the AVR Studio dialog;
  • in the AVR Prog dialog that appears, click the "Program" button;
  • The USB AVR JTAG software update is complete.

4.2 Manual update

Manually updating the USB AVR JTAG software may be necessary if automatic update The software was interrupted for some reason (power failure, etc.). In this case, AVR Studio will not be able to detect the USB AVR JTAG, find out its software version and begin automatic software updates.

To execute manual update BY:

  • turn off the USB AVR JTAG power supply;
  • remove the “upgrade” jumper on the USB AVR JTAG board;
  • turn on the USB AVR JTAG power supply (if using an external power source);
  • run the AVR Prog program;
  • select a file with the extension .EBN for programming from the JTAGICE folder located in the folder in which AVR Studio is installed;
  • press the "Program" button;
  • after completing the firmware update, close the AVR Prog window;
  • install the “upgrade” jumper on the USB AVR JTAG board;
  • Power cycle the USB AVR JTAG.
  • Manual USB AVR JTAG software update is complete.

5 Technical specifications

1 Description

AVR JTAG is a tool for debugging devices based on Atmel AVR family of microcontrollers. AVR JTAG is a complete analogue of Atmel's AVR JTAG ICE. For more information on how AVR Studio works with AVR JTAG, documentation from Atmel can be used.

To work with AVR JTAG, the AVR Studio program from Atmel is used. AVR JTAG supports all microcontrollers of the family that have a JTAG interface:

    ATmega16;
    ATmega162;
    ATmega169;
    ATmega32;
    ATMega323;
    ATMega64;
    ATmega128.

Support for new devices is provided by updating the AVR JTAG firmware, which is included with AVR Studio.

Figure 1 Location of connectors and indicators on the AVR JTAG board

Contents of delivery

The AVR JTAG package includes:

  • AVR JTAG board;
  • mains power supply;
  • cable for AVR connections JTAG to computer;
  • cable for connecting AVR JTAG to the device being debugged;
  • CD with software and reference information.

Figure 2 Appearance boards

Connection

In order for AVR Studio to automatically detect the AVR JTAG, you must connect the AVR JTAG to your computer, the target device, and provide power to the AVR JTAG and target device before starting AVR Studio.

Connecting to a computer

AVR JTAG connects to a standard COM port on a computer. A 9-pin “straight” cable (included in delivery) is used for connection.

When AVR Studio starts, it automatically searches for devices it supports, accessing all COM ports on the computer in order. The search will stop as soon as a supported device is found. For example, if AVR Prog is connected to COM1 and AVR JTAG is connected to COM2, then AVR Studio will only detect AVR Prog. Therefore, when starting AVR Studio, make sure that the other devices it supports are disabled, or after starting AVR Studio, manually set the port to which the AVR JTAG is connected.

If the COM port to which the AVR JTAG is connected is used by other programs (for example, a terminal), then AVR Studio will not be able to detect the AVR JTAG. Please close these programs before starting AVR Studio.

Connecting to the device being debugged

To connect to the device being debugged, 6 lines are used: TCK, TDO, TDI, TMS, VTref and GND; connecting these lines is necessary for correct AVR operation JTAG with the device being debugged.

Additionally, the nSRST line can be connected to the device being debugged (used to control and monitor the microcontroller reset line). The use of this signal is not necessary for debugging, however, if the microcontroller program sets the JTD bit in the MCUCSR register, the JTAG interface will be disabled and will require the AVR JTAG to be able to drive the microcontroller's reset line to enable it.


Figure 3 Connecting AVR JTAG to the device being debugged

Power connection

The AVR JTAG is powered by an external AC or DC power supply (included). To connect the source to the AVR JTAG, a 2.5 mm jack is used. The polarity of the DC source does not matter.

In order for AVR Studio to detect AVR JTAG, it is necessary that the power of the AVR JTAG and the device being debugged is turned on before debugging begins (using the Start Debugging AVR Studio button).

  1. turn on the power of the device being debugged;
  2. turn on the AVR JTAG power;
  3. launch AVR Studio.

Software Update

Updating the AVR JTAG firmware can be done either automatically or manually.

Automatic update

Automatic update occurs if AVR Studio detects that the firmware version included with AVR Studio is greater than the AVR JTAG firmware version. In this case, AVR Studio displays a corresponding message and prompts you to update the firmware. If the user agrees to perform a software update, AVR Studio displays a dialog with instructions for updating the software. To update the software, follow these steps:

  1. click the "Ok" button in the AVR Studio dialog;
  2. in the AVR Prog dialog that appears, click the "Program" button;

The AVR JTAG software update is complete.

Manual update

Manual updating of the AVR JTAG software may be necessary if the automatic software update was interrupted for some reason (power failure, etc.). In this case, AVR Studio will not be able to detect the AVR JTAG, find out its software version and begin automatic software updates.

To perform a manual software update:

  1. turn off the AVR JTAG power;
  2. remove the jumper on the AVR JTAG board;
  3. turn on the AVR JTAG power;
  4. run the AVR Prog program;
  5. select a file with the extension .EBN for programming from the JTAGICE folder located in the folder in which AVR Studio is installed;
  6. press the "Program" button;
  7. after completing the firmware update, close the AVR Prog window;
  8. install a jumper on the AVR JTAG board;
  9. Power cycle the AVR JTAG.

Manual update of AVR JTAG software is completed.

Sometimes, a program programmed into a microcontroller does not work at all as its creator needs. Then comes the debugging stage (Debug - rid the program of crap :-) approx. author) Someone uses USART for debugging, someone attaches a microLED to their free leg, someone writes debugging data to EEPROM, etc. In a word, there are a lot of options here. But the most convenient way of debugging, in my opinion, is debugging using special devices called debuggers. The debugger will allow you to execute a program programmed into the microcontroller line by line and set breakpoints. During debugging, the programmer has access to all registers of the microcontroller. You can also use it to flash the microcontroller and change the fuses.
I present to your attention JTAG ICE debugger:

Zhitag is a good thing. But there is one small drawback. Controllers that support debugging via jtag are all controllers from Atmega16 and older. For some microcontrollers from the tiny family there is a Debug Wire debugging interface, but it seems that no one has made such a debugger on their own. The debugger circuit consists of two parts:

  1. Coordination scheme with PC
  2. The debugger itself

When choosing the first part of the circuit, everything depends on whether you have free COM or USB ports. Since I only have one COM port and it is located far under the table, I decided to use a USB port using my . For those who want to use the COM port, I also drew a diagram. The popular MAX232 chip is used as a level converter. The main disadvantage of using a COM port is the lack of power. In my version, I take 5 volts directly from the USB port, which is very convenient since there are no unnecessary wires hanging around. The signet is placed only for the second part of the diagram because I already had the usb-uart converter in stock, and I simply connected the two boards with wiring. The housing used is G1068B.

Now some technical nuances. The fuses of the microcontroller must be set as follows:

In general, in theory, the debugger should be updated from the studio, but I didn’t bother with this and didn’t update the bootloader. The firmware itself can be taken from the folder Atmel\AVR Tools\JTAGICE\Upgrade.ebn

But this firmware is in the clever EBN format, and we need HEX for the firmware. Help convert firmware to required format The EbnToHex program can. Or you can take ready-made HEX at the end of the page.

The debugger diagram is below:


If you plan to use the USB interface, then you need to exclude from the diagram all elements located inside the rectangle. And solder the TxD and RxD pins of the microcontroller to the USB-UART interface (TxD controller to RxD converter and RxD controller to TxD converter). Also, don’t forget to combine lands and food. I look forward to your feedback and questions in the comments.

When developing and debugging programs for microcontrollers, questions arise related to programming and debugging the program in a real circuit. If there are no special problems with programming AVR microcontrollers, since there are many circuits for “pouring” firmware into a crystal, one of the simplest such circuits is a circuit called “five wires”, then there is no such rich choice when debugging a program.

To debug a program, it is possible to use only two options - a software simulator and an in-circuit JTAG emulator-programmer. A software simulator, as a rule, cannot take into account all the operating features of the circuit, such as external influences, joint operation with other devices, etc. With JTAG hardware programmer-debuggers, it becomes possible to step-by-step debug a program directly in the microcontroller itself installed directly into the circuit, view and change all registers of the microcontroller, set breakpoints and, of course, in-circuit programming of the microcontroller. But the cost of the original AVR JTAG ICE MkII produced by Atmel fluctuates around 300 euros, and its analogue AVDRAGON mass-produced, it costs about 3,000 rubles, which is very expensive for people who create devices on AVR microcontrollers “for themselves.”
But fortunately we managed to create a clone of the original AVR JTAG ICE, which costs significantly less than the original and allows programming and debugging of AVR microcontrollers with a JTAG interface.

Fig 1. Basic electrical diagram clone AVR JTAG ICE

The electrical circuit diagram is shown in Fig. 1. The basis of this JTAG is the DD3 AVR ATMega16 microcontroller. The DD2 MAX232 chip acts as a converter of the RS232 interface to TTL UART levels. The DD1 chip is designed to protect the input and output circuits of the DD3 microcontroller and match the voltage of logic levels when using external power.

JTAG power can be taken from the power circuits of the device being debugged through the fourth contact of vTref XP3, and can also be used externally through the XP1 and XP2 connectors. External voltage can be in the range from 7 to 15V. When using an external power source, the vTref pin of the XP3 connector does not need to be connected.
LED HL2 displays the presence of power, HL1 is the JTAG operating mode.

JTAG is connected to the microcontroller being debugged via a standard ten-pin connector. The connection diagram of which is shown in Fig. 2.


Fig 2. Connection diagram of AVR JTAG ICE to the device being debugged

There are several options for BootLoader bootloaders for JTAG firmware, but in my opinion, the most successful option was made by Vitaly Krotevich (Vit). Its bootloader most closely replicates the proprietary one and allows you to update the JTAG firmware directly from AVRStudio without rebooting the JTAG and entering programming mode via BootStart. If you do not plan to update the JTAG firmware, then the bootloader can not be flashed, but only “fixed” original firmware from .

To “hardwire” the bootloader into JTAG, you can use the AVReal, PonyProg, STK200, “five wires” programmer, or any other available and compatible with AVR ISP. The programmer is connected to the ISP programming connector XP4. Firmware file JTAG_ICE.hex.

An example of fuse programming is shown in Figure 3.


Fig 3. Setting fuses for AVR JTAG ICE

An example of AVR JTAG ICE operation is shown in Figure 4. As an example, the ATMega128 signature was read


Figure 4. Reading the ATMega128 microcontroller signature using AVR JTAG ICE


Fig 5. Image of the top layer of the PCB trace, with applied elements


Fig 6. Image of the bottom layer of the PCB trace, with applied elements

Photos of the finished device:

P.S. The circuit diagram and trace of the printed circuit board were developed by the author of the article, the bootloader was used by Vitaliy Krotevich (aka Vit), the firmware was from the original AVRStudio.

The following sources were used when writing this article:
1 http://onembedding.bialix.com/files/jtag_vit/
2. Official AVR JTAG ICE User Guide JTAGuserguide.pdf

Download firmware, files printed circuit boards you can below

List of radioelements

Designation Type Denomination Quantity NoteShopMy notepad
DD1 Buffer IC, driver

CD74AC244

1 To notepad
DD2 RS-232 interface IC

MAX232

1 ST232BD To notepad
DD3 MK AVR 8-bit

ATmega16

1 ATmega16-16PI To notepad
DA1 Linear regulator

LM78L05

1 To notepad
VD1, VD2 Rectifier diode

SM4007PL

2 To notepad
VD3 Zener diode

BZX55C5V1

1 SMBJ5.0A To notepad
VD4, VD5 Schottky diode

SM5819PL

2 To notepad
HL1, HL2 Light-emitting diodeKR-3216-22 To notepad
C1, C2, C4-C6, C9-C13, C16 Capacitor0.1 µF10 To notepad
C3 1 To notepad
C7 Electrolytic capacitor470 µF 10 V1 Tantalum To notepad
C8 Capacitor1200 pF1 To notepad
C14, C15 Capacitor22 pF2 To notepad
R1 Resistor

36 kOhm

1 To notepad
R2 Resistor

150 kOhm

1 To notepad
R3-R6 Resistor

10 kOhm

4 To notepad
R4, R10 Resistor

4.7 kOhm

2 To notepad
R9, R11-R15 Resistor

200 Ohm

7 To notepad
R16 Resistor
  • The official programmer produced by Atmel costs approximately 300 euros(without delivery and customs clearance). A cheaper option - you can find unofficial “clones” for about $150 .
  • The option is even cheaper, but requires effort, because... from the "do it yourself" category:
    on the web through a search engine ( clone AVR-JTAGICE mkII) you can easily find a diagram with the programmer firmware accompanied by assembly instructions.

Programmer characteristics

  • Full support for JTAG programming, also supports ISP and DebugWire interfaces.
  • Connection to PC is carried out with via USB 1.1 or RS-232 interface
  • Breakpoints at program memory and data memory addresses
  • All operations and breakpoints are executed in real time
  • The voltage supplied to the circuit being debugged is 1.8-5.5 V
  • The external power supply voltage is 9-12V, the debugger can also be powered from a USB port

Programmer AVR-JTAGICE3

Official programmer for Atmel microcontrollers of the AVR family that support the JTAG debugging and programming interface.

I think for debugging AVR microcontrollers in the AVR Studio 5 environment is best choice. By the way, I couldn’t find any unofficial clones. If anyone knows, please let me know in the comments to the page.

When I started using it, I experienced some difficulties using it - it seemed that it was terribly buggy, and I had to constantly reboot AVR environment Studio to make it come to life.

In principle, everything turned out to be simple - you shouldn’t try to perform any other actions with the programmer while debugging is running, for example, calling up a window with fuse settings. Over time, I got used to it and use it without any problems.

Among the advantages, I will highlight its small dimensions (compared to its predecessor AVR-JTAGICE mkII) and versatility - in addition to the JTAG interface, aWire, SPI and PDI are also available.

One of the difficulties is its cost. I think that it is quite decent - about 15,000 rubles through official dealers in Russia.

Programmer characteristics:

  • Supports JTAG, aWire, SPI and PDI interfaces
  • 3 hardware breakpoints and 1 maskable
  • Symbolic debugging of complex data types
  • Up to 128 software breakpoints
  • Supports microcircuits with supply voltages from 1.8 to 5.5V
  • High speed (downloading 256KB program ~14 sec. (XMEGA via JTAG) interface)
  • USB powered.

AVR-JTAG-USB programmer

This programmer is used for Atmel microcontrollers of the AVR family that support the JTAG debugging and programming interface. This programmer is a clone of the original Atmel programmer. It is produced by Olimex and it differs from the official more favorable price(approximately 4,000 rubles through official dealers in Russia, and naturally, it can be cheaper directly from abroad), at the same time, it is quite reliable in terms of functionality and I had no complaints while working with it. Operates and is powered from the computer's USB port.

The only feature that is worth paying attention to in advance is that when used as a development tool, AVR Studio will only work under AVR Studio 4. If you are going to work on AVR Studio 5, then it is absolutely useless for debugging, because not supported. Therefore, for the fifth version I bought another programmer - AVR-JTAGICE3.

Programmer characteristics

  • Programming of all AVR microcontrollers with JTAG interface support;
  • Target voltage 3.0 - 5.0V;
  • Powered by USB interface;
  • JTAG connector is compatible with Atmel 2x5 pin JTAG connector;
  • Compatible with Atmel AVR STUDIO for programming, real-time emulation, debugging, step-by-step program execution, setting breakpoints, memory dump, etc.;
  • Full emulation of all analog and digital functions;
  • Full programming support via JTAG port;
  • Update via AVR STUDIO;
  • The USB interface connector is type “A”.

Contents: AVR-JTAG-USB programmer/emulator.
For operation, you may need a USB cable “AA” - SCUAA-1