Micro beginner ==> 1. ISP
Diese Seite in Deutsch (extern):
Lecture 1: A ISP programming interface
To understand microprocessors one needs to access the processor's internal components
via a programming interface. With that, one can
- Components and mounting
Without this programming interface nothing goes, the processor sleeps and does absolutely
- transfer program code to the processor, or
- delete this program code,
- select the clock source for clocking the device,
- transfer data to the EEPROM inside,
- read internal program code and EEPROM content, and
- protect the chip against reading of its content.
In these lectures programming is performed within the readily
mounted electronic systems. This is called "In-System Programming" or ISP.
This shows what is needed:
This has immense advantages: the final electronic system works immediately after
programming, no further and unnecessary interfaces or systems are between you and
the microprofessor and limit or modify your connection with the processor. Bye
bye complicated cable orgies, such as with an STK500 or an Arduino. The current
supply of the electronic system is not affected at all.
The ISP interface of the AVR works in all device types in the same manner, no matter
if the device has six or 96 pins. If your application system does not allow to
access the three portpins used for the ISP interface just switch to the next
larger device, change a few lines of your software to adapt to the new type and
program this into the new device in your electronic system.
If you built in the six pin ISP plugin into your system, you can easily re-program
the device. No need to unmount the processor or to solder new connections.
In this chapture we are learning to access the processor within the system and to read
its device identifier. The other possibilities to change the chip's properties are
demonstrated in brief.
1.2.1 The programming device
Many different programming devices can be used. I use an ancient AVR-ISPmkII of ATMEL.
This is a handy device, provides the desired six pin ISP connector and works perfectly
with ATMEL's Studio. The following examples were all prepared with that. It is not
available in ATMEL's store any more, so you'll have to switch to one of the many clones
The cheapest choice is to use a serial programmer that emulates a STK500 programming
board. Communication between the STK500 and the Studio was over a RS232 serial interface,
using a serial port between COM1 and COM4. The communication protocol was published
by ATMEL, so can be emulated by a board. As computers nowadays have no RS232 serial
communication interfaces any more, you can use an USB-to-Serial interface cable. This
installs on Windows and emulates a serial COM port over USB. But make sure it installs
on a low COM port number. Please note that on whatever USB port you plug the cable to,
Windows follows its own rules on which COM port it will install the serial port to.
It should be anything from COM1 to COM4, so the Studio finds a STK500 there.
An emulated STK500 can program many devices but not any. The devices used here are
clearly part of the STK500 choices, so can be programmed with any STK500 clone.
Because my AVR ISP MK II has, in the meantime, given up I use a cheap Diamex
USB-to-6pin programmer, which works fine and reliably.
1.2.2 The programming hardware
The supply of the system is performed by an AA four-pack rechargeable battery, with
1.2 V each. As AVRs are optimized to require very low current, a line power
supply would be overdone. If
there are many practical alternatives for that as long as your supply provides
between 4.5 and 5.5 V (lower voltages are not practical for the later lectures
that use a 5V LCD) at a current of at least 20 mA.
- you do not have a four-pack rechargeable battery (and you dont like the idea
of buying one),
- you do not like this type of packs in general (e.g. because having four of
such does not give you control over each of it),
- you are not able to charge such a package, because your charger charges 1.2V
devices only, you do not have an adjustable power supply or a power transistor,
two silicon diodes and two resistors to construct your own homemade charger,
- you have a power supply providing 5V and you prefer using this
Charging can of the four pack be done like this:
To the left, the simplest charger is shown. If the battery is completely empty,
leave the resistor and the battery for ten hours on the DC source. Not much
To the right, a more exact constant load charger is shown. It provides roughly
80 mA constant current and can be operated on any DC source between 7.5
and 15 V. Please load for not more than 10 hours.
The necessary hardware to access the AVR is shown here.
Via the three pins MOSI, MISO and SCK the communication between the programming device
and the AVR is done. The AVR enters programming mode if the RESET pin (pin 1 of the
ATtiny13) goes to low (which the programming device initiates via the RST line of
the 6-pin ISP). Without active programming this pin is tied to the positive operating
voltage with a resistor of 10 k, allowing the processor to do his work.
Between the positive and negative supply voltage, near to the processor's supply pins,
a ceramic capacitor of 100 nF blocks high-frequency peaks that result from the
processor's rectangle switching internals.
The pins of the processor are named with the active function that is used here. Each
pin has additional names, depending from its use and function. Pins can change their
function only if programmed to do so.
With this simple hardware we can communicate with the AVR and can access its internals.
The rechargeable battery pack
This is the rechargable battery pack used. If you use batteries that are not rechargeable,
use only three of those. You can use anything that provides between four and five Volts.
The ISP6 plug
The ISP plug is a two-row by three pins each male connector. For the use on a breadboard
an adapter is necessary.
This adapter has to be self-mounted. For this a 3-by-4 wide piece of a printed circuit
board with isolated eyes is cutted. On the soldering side a 2-by-3 plug connector is
attached and soldered (with plugs only as deep in the whole as necessary so that soldering
is still enabled). On the other side of the board two 3-pin plug connectors are soldered
in and the neighboring eyes are soldered together as shown.
The 10k resistor
Those here are two different types of resistors. In the upper part a carbon film, in
the lower part a metal film resistor with 10 k is shown. The color coding of the
rings is demonstrated.
The 100 nF ceramic capacitor
This here is such a capacitor.
The 8 pin socket
Into this socket the microprocessor can be plugged in.
This is the microprofessor, even though it does not look alike. In the package many
hardware is sleeping and can be attached to its eight legs, which are numbered in an
unconventional way (left picture). At least pin 1 can be found easily, because it has
several markings. First of all a small triangle is printed near this leg. Second, a
small pit can be seen there. And third a small notch is on the side of the chip that
holds leg #1. With those characteristics it is nearly impossible to plug in the chip
the wrong way.
Of course, the processor does not fit into the socket above. His legs do not exactly
point downwards but a little bit to the side. To correct this one can correct the
four legs by pressing the chip cautiously on a hard surface and to move the four pins
of each side slightly inwards. If you do not do that the risk is high that the legs
are bent during pressing the chip into the socket. That means danger to the life of
Mr. Professor and it is very funny to straighten those legs without loosing parts or
all of them and then to move the whole chip to the recycling bin.
This is a part of the breadboard. A breadboard is an experimental or devellopper system.
Pins of components can directly be plugged into the holes and are contacted. The board
allows to test electronic systems and the software before the whole goes into mass
production (which is never the case with the systems we build in the upcoming lectures).
The green lines show which holes are interconnected (in the lower part of the picture
only five connections are shown. The upper two rows are for the supply voltage, the
lower columns for components. From that it is clear why the ISP6 plugin had to be
altered: the separation line in the middle of the board lines is two rows from each
side and in the component area such a two-row plug would be short-circuited.
Mounting goes as follows:
Leaving out single steps in that row (especially steps 4 and 6) ends in error messages.
To debug those errors you will have to redo those steps, so why not doing those from the
- Place the ISP6 plugin and the IC socket on the board.
- Wire supply and direct connections.
- Place and wire all other components (resistor, capacitor).
- Check all connections between the ISP plugin and the IC socket using a multimeter
in resistor measurement mode.
- Connect the supply (rechargeable battery pack) with the supply lines of the
- With the multimeter in DC measurement mode check that pin 4 of the IC socket is
connected to GND or Minus of the battery pack und pin 8 with VCC or plus. Similiary
check that on the ISP6 plugin on pins 6 (GND, Minus) und 2 (VTG, Plus). Check that
voltage and polarity is correct.
- Then push the ATtiny13 into the socket. Now plug the the programmer into the USB
(check that the JUNGO driver is loaded correct) and connect with ISP6. The
control lamp of the programmer should turn to green if the voltage is correct.
The following pictures show the stages of mounting.
So the mounting of all components looks like. The supply and the ATtiny13 are not yet
in place to do the testing.
The rechargeable battery pack adds voltage, but still without the tiny and the programmer.
Now check polarities and voltages to not kill the Tiny with over-voltage or reverse
Now anything is complete and the AVR-ISPmkII is plugged in. The green LED signals that he
is correctly connected to the USB plug and that the voltage on the ISP6 plugin is
correct. A red LED would signal that something is wrong.
Now, what to do if you dont have and you dont get an AVR-ISPmkII? The answer is
simple: take anything else that you get a programmer
If you have the latest of the latest operating systems which does neither support
access to a serial RS232 nor your USB interface: consider stepping back in time
and rather use something useful.
- with a 6-pin standard programming interface on it to connect that with your
breadboard (nearly all programmers have that, if yours has a 10-pin KANDA
interface only you have to homebrew a 10- to 6-pin adapter), and
- that understands
- a usual ATMEL USB-Interface for programming with the Studio such as an
AVR dragon, or
- a serial RS232 interface that either is an STK500 or just acts like
one and connects either to the Studio (either RS232 or via an USB/RS232
interface, make sure that the interface installs on COM ports between
1 and 4) or supports any other programming software such as AVRdude, or
- an antique parallel interface programmer (make sure that your computer
has such a parallel interface), together with AVRdude, or
- that supports ATtiny13(A) and ATtiny24(A), which are not the latest
controllers and are supported by most programmers.
Now one can start the experiments and the access to the interior of Mister Professor.
To access the interior of the professor we need some software. One gets this for free from
ATMEL if we search there in the
8-bit section for "Studio", but only under Windows. Check that your harddisk
has lots of free space, because the software elephant requires well over one Gigabyte.
The following examples were produced using version 4 of the studio, an older version of
that. It works similar to versions 5, 6 or 7 (at least for our purposes). Right at the
beginning of a project select "Assembler".
So the Studio looks right after start: it requests to generate a new project. We select
an assembler project, select a meaningful name for that, let the Studio generate a
source file with the same name in the selected folder and go to the Next button.
We select the simulator as platform and as device an ATtiny13.
For the exploration of the internals the tools menue is decisive.
After plugging the programmer to an USB jack we select within the tools menue
"Program AVR" und "Auto Connect" and hope the programmer is identified
If the USB jack is correctly identified and the programmer has told the Studio that he is
an AVR-ISPmkII, the tools window opens. In that window we select the tab "Main".
Here several selections have to be made. In the field "Device and Signature Bytes"
we select ATtiny13, but do not yet press the button "Read Signature". First
we read in the result field what the software tells us about its result.
Then we ensure that in the "Programming Mode and Target Settings" the
ISP mode is selected and that the ISP frequency is below 300 kcs/s (if not: press
button "Settings" and adjust the frequency. The we can read the signature bytes
of the chip.
This is the report of the programmer. It has read the signature, compared the result with
the ATtiny13 and comes to the conclusion that the signature is correct. Anything works
well and all functions correct.
If not then this or a similar error message comes up. We then enter error message debug
mode and measure voltages, connections and act like described above.
To just have a view on the fuses of Mister Professor, we select the tab
"Fuses". We should not change something here because unwanted changes can have
the consequence that nothing goes any more and any access to the chip vanishes. Who wants
to already know at this point what the fuses do takes a view into the Device Databook
of the ATtiny13 (to download under this address, 176 pages).
This here hides behind the tab "Lockbits": the switches to disable reading
out the flash storage. Those can only be overwritten if the whole storage is cleared
(using the button in tab "Main"). Perfect software protection.
So far the internals of Mister Professor. More later on.
©2017 by http://www.avr-asm-tutorial.net