Aquaticus

Projects for geeks

How to build

27 Nov 2006

PCB

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.

Components

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

Part Value Device
C1 22pF Capacitor
C2 22pF Capacitor
C3 0.1µF Capacitor
C4 0.1µF Capacitor
C5 0.1µF Capacitor
C6 0.1µF Capacitor
C7 100nF Capacitor
C8 100nF Capacitor
C9 100nF Capacitor
C10 10µF Polarized Capacitor
D1 1N4148 Diode
IC1 MEGA16-P Atmel microcontroller PDIP
IC2 MAX232A RS232 Transceiver
JP1 - Jumper 3 pins
LED1 - LED 3mm
LED2 - LED 3mm
Q1 7.3728 MHz Crystal
R1 10kΩ Resistor
R2 150kΩ Resistor
R3 1kΩ Resistor
R4 1kΩ Resistor
R5 4.7kΩ Resistor
R6 1kΩ Resistor
R7 36kΩ Resistor
X1 Female DB9 sub
X2 Power Jack 2.5mm
X3 IDC10 2×5 pins

Soldering order

1. M1 and M2
2. Resistors Rx and diode D1
3. Capacitors Cx
4. LEDs LED1 and LED2
5. Headers and sockets Xx

External power

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.

MAX232

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).

Programming ATmega16

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.

Flash

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.

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.

Name Value Details
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: