Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

How to disable JTAG of AVR microcontroller- (Part 24/46)

By Ashutosh Bhatt

JTAG stands for “Joint Test Action Group” which was standardized as the IEEE 1149.1 Standard Test Access Port and Boundary-Scan Architecture in 1990. JTAG is generally used in IC debugging and device programming. Atmega16 consists of one JTAG port which shares four pins with PORTC. Until JTAG port is not disabled, these pins can’t be used as normal I/O pins. This article explores the methods for JTAG disabling.

 


 

 
JTAG interface shares PC2, PC3, PC4 and PC5 of ATmega16. To use these four pins for general I/O operations, JTAG must be disabled. There are two methods for disabling JTAG: 
1. By programming
2. Using Avrdude
 
1. Programming method:
There is a register in atmega16 MCUCSR (MCU control and status register). It consists of JTD (JTAG disable) bit as 7th bit of register. JTAG can be disabled by writing 1 to this bit. 
                                    MCUCSR|= (1<<JTD);
 
This command must be written twice to disable JTAG. This is a temporary method of JTAG disabling because using this method, it is required to write the above command in every program. For permanent disabling next method can be used.
 
2. Using Avrdude:
JTAG can be permanently disabled by configuring two fuse bits, OCDEN and JTAGEN (must be disabled). This is done by using Avrdude software. The following instruction should be followed carefully to disable the JTAG 
1. Connect your microcontroller burner circuit to your system.
2. Go start>run and write “cmd”.
3. Write command “avrdude –p <microcontroller code> –c <programmer type> -t” in Command window
 
Commands                    -p                to select microcontroller
                                    -c                to select programmer type
                                    -t                 to enter in AVRDUDE’s interactive window.
 
Microcontroller code     m8                 for ATmega8
                                  m16               for ATmega16
                                  m32               for Atmega32
 
Programmer types are       bsd                for parallel port programmer (Brain Dean’s programmer)
                                       usbasp           for USB programmer (USBasp)
 
The following picture shows the output of above command.
 
Output of Commands using Avrdude Software to disable JTAG
Fig. 2: Output of Commands using Avrdude Software to disable JTAG
 
4. Write command “d lfuse” and “d hfuse” at avrdude interactive window to get values of low Fuse byte and high fuse byte.
 
Low fuse and High Fuse Byte Values on avrdude interactive window
Fig. 3: Low fuse and High Fuse Byte Values on avrdude interactive window
 
5. As shown in above picture the value of Fuse bytes is 0x89FF. This value shows that JTAG port of the microcontroller is enabled. To disable JTAG, the value of fuse bytes must be 0xC9FF.
6. To write 0xC9 in higher fuse byte the command “w hfuse 0 0xc9” is written. Lower byte will remain same.
 
Higher Fuse Byte Command to Disable JTAG in AVR
Fig. 4: Higher Fuse Byte Command to Disable JTAG in AVR
 
7. Write “d hfuse” command again to make it confirm that value is written or not.
 
Command to Confirm JTAG Value
Fig. 5: Command to Confirm JTAG Value
 
8. For terminating this window by type “quit”.

By this operation JTAG will be disabled and PORTC will work as normal I/O port. 

 

Project Source Code

###


//Program to disable JTAG of AVR microcontroller
#define F_CPU 12000000UL
#include<avr/io.h>
#include<util/delay.h>
 
int main(void)
{
int i=0;
DDRC=0xFF; // Port C as output port
PORTC=0x00;
 
/* JTAG port is enabled*/
while(i<=10)
{
PORTC=~PORTC; // toggle all bits of port C
_delay_ms(1000); //1 sec delay
i++;
}
 
/*Now diable JTAG port*/
MCUCSR|=(1<<JTD); // sendig 1 to JTD
MCUCSR|=(1<<JTD);
 
while(1)
{
PORTC=~PORTC;
_delay_ms(1000);
}
 
}
 

###

 


Circuit Diagrams

Circuit-Diagram-of-How-to-disable-JTAG-of-AVR-microcontroller

Project Components

  • ATmega16
  • LED

Project Video


Filed Under: AVR Microcontroller
Tagged With: atmega16, avr, jtag, microcontroller
 

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • PS2 Keyboard To Store Text In SD Card Using Arduino Circuit Setup On Breadboard
    How To Use PS2 Keyboard To Store Text In SD Card Using Arduino- (Part 42/49)
  • Wireless Path Tracking System Using Mouse, XBee And Arduino Circuit Setup On Breadboard
    How To Make A Wireless Path Tracking System Using Mouse, XBee And Arduino- (Part 43/49)
  • How to Make a Wireless Keyboard Using Xbee with Arduino- (Part 44/49)
  • Making Phone Call From GSM Module Using Arduino Circuit Setup On Breadboard
    How to Make Phonecall From GSM Module Using Arduino- (Part 45/49)
  • How to Make a Call using Keyboard, GSM Module and Arduino
    How To Make A Call Using Keyboard, GSM Module And Arduino- (Part 46/49)
  • Receiving SMS Using GSM Module With Arduino Prototype
    How to Receive SMS Using GSM Module with Arduino- (Part 47/49)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • Renesas delivers intelligent sensor solutions for IoT applications
  • Microchip Technology releases AVR-IoT Cellular Mini Development Board
  • Qualcomm acquires Cellwize to accelerate 5G adoption and spur infrastructure innovation
  • MediaTek’s chipset offers high-performance option for 5G smartphones
  • Nexperia’s new level translators support legacy and future mobile SIM cards

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Adaptive filters fundamental
  • Using LTspice to check Current sense transformer reset?
  • Thermal pad construction on pcb
  • lna+mixer noise figure problem
  • Reference driver for negative/above rail voltages.

RSS Electro-Tech-Online.com Discussions

  • Help diagnosing a coffee maker PCB
  • Capacitor to eliminate speaker hum
  • Identify a circuit.
  • How is this tester made?
  • undefined reference header file in proteus
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering