Skip to content

Digital Me

Electronics, Computers at leisure time

Menu
  • Home
  • Contact
  • About
Menu
JTAG connected

JTAG adapter for Arduino Micro

Posted on December 31, 2013

For the holiday season I get myself an AVR JTAGICE3. Holding the new shiny emulator and a bunch of Arduino boards, what shall I do? Of course to hop onto the all-hail Atmel Studio and ditch the toy-alike Arduino software. Reason being? Debugging Arduino code with serial console is no fun. I need my single steps, breakpoints and watches back. In fact the Arduino boards seems to be more valuable (to me) without the software. The onboard ISP connector seems to be standard and it “just works” with JTAGICE3. Well, I had this “just works” impression until I tried it on the new Arduino Micro board…

Make the story straight. The Atmel ISP connector combines SPI bus and RESET signal. SPI is used for downloading program, and RESET implements Atmel’s “debugWire” on-chip debug system. debugWire OCD is a very fancy protocol that uses only one RESET pin to debug. ATmega328p supports debugWire, and hence the ISP connector on Arduino UNO can be used for debugging. Arduino Micro uses a newer ATmega32U4 chip. Surprisingly debugWire is missing from the product datasheet, instead JTAG is listed. JTAG uses 4 I/O pins,  from Arduino Micro schematic we can see the JTAG pins (TDI/TDO/TMS/TCK) are multiplexed with analog pin A0-A3. It appears I have to sacrifice these analog pins for the JTAG interface.

JTAG pins on Arduino Micro
JTAG pins on Arduino Micro

JTAGICE3 comes with a 10-pin JTAG header, with the definition as follows:

JTAG header
JTAGICE3 JTAG Pinout

All I need to do is to make an adapter connecting these pins:

JTAG on Arduino Micro
JTAG on Arduino Micro

The actual construction is done on a perf board. I made it Arduino “Shield” type so they can be simply stacked together.

Arduino Micro JTAG Shield
Arduino Micro JTAG Shield

I admit it looks quite dangerous when stacked up 😮

JTAG connected
JTAG connected

I hook up JTAGICE3 and choose JTAG interface in Atmel Studio. And no surprise. Murphy gets me everytime! “[ERROR] No JTAG devices detected.” is the only reply I get. I Scratch my head several hours then to realize how stupid I were. Since the pins PF4-PF7 have been used as analog inputs for Arduino, how can JTAG establish connection with these pins! And the resolution is simple: connect using ISP header and enable the JTAGEN fuse bit. Now I feel the usefulness of ISP connector.

Enable JTAGEN Fuse
Enable JTAGEN Fuse

I can finally talk to ATmega32U4 using JTAG and do some debugging. The coming year will be interesting 🙂

 

7 thoughts on “JTAG adapter for Arduino Micro”

  1. embedsys says:
    January 13, 2014 at 11:02 pm

    Thank you for sharing how you made your home made Arduino Micro JTAG Shield 😉
    Your blog post has been featured in the last embedded systems weekly issue http://embedsysweekly.com/issue12-embedded-c-programming/#JTAG_adapter_for_Arduino_Micro
    I hope you’ll like it

    Reply
    1. Baoshi says:
      January 14, 2014 at 10:53 pm

      Thanks. Find many good info there. Have to subscribe.

      Reply
  2. Bill (W7AAZ) says:
    February 19, 2014 at 2:34 am

    It is also easy to make plug-in JTAG pigtail connection to Arduino 2560. And I have read that the GCC compiler can produce debug information for Studio. But I am a hardware guy and don’t know how to make the Arduino compiler produce C debugging file for Studio. In fact I don’t even know where to go in Arduino environment to change the compiler command line. Is it easy to explain this?

    Bill

    Reply
  3. Erik Larsen says:
    June 21, 2014 at 4:22 pm

    Thanx for an easy way of adding JTAG to the 10 bux Arduino micro Pro

    Reply
  4. westfw says:
    October 22, 2014 at 1:35 pm

    This is neat; I hadn’t realize that the 32u4 had JTAG. Do you feel like making your EAGLE files available?

    Reply
    1. Baoshi says:
      October 23, 2014 at 11:54 am

      Hi, I’m making that on a perf board and I afraid I do not have EAGLE design.

      Reply
  5. Livio says:
    October 19, 2016 at 8:05 am

    Thank you very much!
    Your sentence: “connect using ISP header and enable the JTAGEN fuse bit” give me the right way to solve my problem: connect Arduino Mega2560 to Atmel-ICE with JTAG.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Arduino ARM AVR Charger CNC Distance Sensor emWin ESP31 ESP32 ESP8266 FT230X GCC iPad JTAG LED Strip Makefile Maker Faire MF70 OLED Oscilloscope PCB PIR Sensor Pogo pin PWM Raspberry Pi RGB LED Rigol RTOS Saleae SEGGER Shopping SPI SSD1305 SSD1306 STM8 STM32 STM32Cube STM32CubeMX Storage TFT Tindie Tool USB Power VFD Workbench

Recent Posts

  • Arduino Redesigned – Maker UNO Review
  • Is ESP8266 I/O really 5V tolerant?
  • First sight into ESP32
  • ESP8266 MQTT client on RTOS
  • Maker Faire, Yearly Review, and Rant

Archives

  • March 2018
  • August 2016
  • December 2015
  • August 2015
  • July 2015
  • April 2015
  • February 2015
  • January 2015
  • December 2014
  • October 2014
  • July 2014
  • May 2014
  • March 2014
  • January 2014
  • December 2013
  • November 2013
  • August 2013
  • July 2013
  • May 2013
  • March 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
©2024 Digital Me | Design: Newspaperly WordPress Theme