Skip to content

JTAG debugger interface


I needed an option to debug code running on the microcontroller with attached LCD and switches. It was not possible to debug in the simulation mode of AVR Studio. I found a very detailed description how to build, test and use an easy to assemble JTAG interface on the Aquaticus page which works with the AVR Studio (also with WINAVR).

Here their schematics:

Aquaticus JTAG schematics

Different to their instructions I used the code from the following article for the primary bootloader of the Mega16 placed in the JTAG circuit.Testing the bootloader works this way: after you power up the processor program flow jumps to special area called bootloader. Bootloader prepares microcontroller to receive control commands and data through serial port (RS232, 19200, 8N1), this way we can send flash ATMega16 using serial port, it’s easy and good solution. A disadvantage is that you loose some FLASH space for bootloader (in most cases this can be omitted). Important: JP1 jumper must be short-circuited in position 1-2, this way CPU jumps to bootloader, else (2-3 position) normal code (not bootloader) is executed. You can check communication with bootloader with simple terminal connected do serial port, try to send S character or V character. Below you can see the effect, white background means sent character:

terminal connected to bootloader

terminal connected to bootloader

After this test was successful I continued with the testing described in Aquaticus article. For their test I build the simple device shown on their page with only ATMega16 (a Mega8 can’t be used because it has no JTAG support).
When you buy a new processor it has the JTAGEN fuse bit programmed, to be sure I programmed it once again along with OCEN bit (this stage may not be necessary).

I connected signals TCK, TDO, TMS, TDI with appropriate CPU pins, connect VCC to VTREF and optionally NSRST with CPU reset. If you do not power interface externally, connect 5V to VSUPP pin! The test circuit was connected to the JTAG interface with 10 wire cable. My first JTAG interface almost worked instantly – I only forgot to connect VTREF signal, after correction AVR Studio stopped nagging that the power supply is not connected.

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: