Wednesday, February 10, 2016

Disabling JTAG in avr microcontroller



In this post I am going to explain how to disable JTAG. The JTAG stands for Joint Test Action Group(JTAG), Which is an international standard method for testing the microcontroller performance and delay calculations. Therefore, most of the  microcontrollers are having this facility to test and debug by the programmer. This is done by four signals namely TDI (Test Data Input), TDO (Test Data Output), TMS (Test Mode Select) and TCK (Test Clock).  It is important to know how to disable JTAG because the JTAG is enabled while the microcontroller shipping which makes the port pins occupied by the JTAG signal do not work properly. For  example, in ATmega16 microcontroller, in which the JTAG pins are occupied with PORTC. Which are  PC5, PC6, PC7 and PC8. So you cannot use this pins for any port operation. You can disable JTAG using Fuse pins but it is not a good practice. The best way is to write a “1” to JTD bit of MCUCSR register of you AVR microcontroller as shown below code.



MCUCSR = (1<<JTD); // Disables JTAG pins

MCUCSR = (1<<JTD); // Disables JTAG pins

 Sometimes you have to write this code twice for proper working

No comments:

Post a Comment