First, you have to make a PCB board. You can make it by yourself using files attached at the end or you can buy ready to use JTAG PCB. Solder everything, external power supply socket is optional, use it only if you plan to connect JTAG to the external power source.
It’s good practice to place ATMega16 and MAX232 into socket. Be sure that there aren’t any shortcuts and elements have proper values.
Bill of materials
|IC1||MEGA16-P||Atmel microcontroller PDIP|
|JP1||-||Jumper 3 pins|
|X1||–||Female DB9 sub|
|X2||–||Power Jack 2.5mm|
|X3||–||IDC10 2×5 pins|
1. M1 and M2
2. Resistors Rx and diode D1
3. Capacitors Cx
4. LEDs LED1 and LED2
5. Headers and sockets Xx
JTAG can be powered from 2 sources:
1. Target board (that is debugged) via JTAG socket
2. X2 power socket
The first solution is most popular. External power is used only if your target board can not provide enough power for additional elements of JTAG board. For most users X2 socket is optional, you do not need to solder it.
There’s a simple protection against improper power supply polarization – D1 diode.
IC2 has to be MAX232A (with A at the end), that way small popular 0.1µF capacitors can be used. You can use standard MAX232 (more popular, cheaper and easy available), but remember to use 1.0µF capacitors (instead of 0.1µF).
To perform this step you need an external programmer. Use programmer of your choice, any ISP or parallel programmer is suitable. Be sure the programmer software allows you to set fuse bits and program flash memory.
If you have only ISP programmer, you can use any development board with ISP socket to program microcontroller. Replace original ATmega16 with the chip to be used in JTAG interface and program it in the usual way. After programming remove the chip.
Download attached aquaticus_jtag_m16.hex file. This is a standard HEX file accepted by all programmers. It contains bootloader and original Atmel firmware. Put your ATmega16 into programmer and flash the chip using this file. Verify it and that’s all.
Now it is time to program fuse bits.
The most important fuses are:
- OCDEN – disable on chip debug
- CKOPT and CKSELx – use of external crystal as clock source
The other settings does not really matter, but below you have description and values for all fuse bits.
|OCDEN||1||Turn off On Chip Debug, if on CPU may use more current in sleep modes, because some clock distribution subsystem are constantly powered|
|JTAGEN||1||JTAG not used here|
|SPIEN||0||A must be during SPI programming (you can’t set it to 1 (not programmed) in SPI programming mode)|
|CKOPT||1||This value is due to use of external 7.3728 MHz crystal|
|EESAVE||1||EEPROM content doesn’t have to be preserved between programming – it can be turned off (1)|
|BOOTSZ1||0||Bootloader size set to 1024 words, ie. 2048 bytes (see documentation for details)|
|BOOTSZ0||0||Bootloader size set to 1024 words, ie. 2048 bytes (see documentation for details)|
|BOOTRST||0||After reset jump to bootloader.|
|BODLEVEL||1||Brown Out Detector level – detection of power failure – not used here – turned off (1)|
|BODEN||1||Brown Out Detector level – detection of power failure – not used here – turned off (1)|
|SUT1||1||Start Up Time – set to 65 ms (it doesn’t actually matters here)|
|SUT0||1||Start Up Time – set to 65 ms (it doesn’t actually matters here)|
|CKSEL3||1||This value is due to use of external 7.3728 MHz crystal|
|CKSEL2||1||This value is due to use of external 7.3728 MHz crystal|
|CKSEL1||1||This value is due to use of external 7.3728 MHz crystal|
|CKSEL0||1||This value is due to use of external 7.3728 MHz crystal|
Note Do not set any lock bits.
Now you can remove ATmega16 chip from programmer and put it into socket on JTAG PCB.
Fuse screen shots
Here are the screen shots of the popular programs: