Sei sulla pagina 1di 4

Different Poles of Three Decades Development

in Microcontrollers’ Domain
Zbynek Fedra, Member, IEEE, Tomas Fryza, Member, IEEE

Abstract—The contribution compares two realizations of II. MICROCONTROLLERS DESCRIPTION


hardware and software platforms from the microprocessor
The microprocessor 8080 or 8085 is Intel made 8-bit CPU
technique domain. The Intel 8080/8085 and Atmel AVR 8-bit
microcontrollers are taken in occur. The proposed paper released in mid-1970s with von Neumann architecture and 16-
describes the differences between simple code implementation bit address bus. This processor has six 8-bit registers (titled B,
(e.g. stopwatch) for historical microcontrollers. The properties of C, D, E, H and L); and could be combined into three 16-bit
implemented code, such as the total number of program memory register pairs (BC, DE, HL). It also has an 8-bit accumulator
occupation, the code velocity, and others will be presented as (register A), a 16-bit stack pointer (SP) and a 16-bit program
well.
counter (PC). The 8080 was followed by the compatible (but
Index Terms—Assembly, High-level languages, Microcontro-
using only 5V power supply) model of 8085 [1].
llers, Microprocessor testing, Programming, Simulation software The processor 8085 was used in several personal computers
and development boards. Probably, the most widespread
board was Intel’s SDK-85, equipped among others by CPU,
I. INTRODUCTION RAM memory of 512 B and ROM memory of 2 kB. The six
digit segmental display and key board were used as input and
T HE history of microprocessor techniques started in early
70’s when Intel Corporation introduced his first
commercial processor 4004. This processor had 4-bit CPU,
output peripheries. In ROM memory the operating system
called Monitor was implemented. Beyond the main control of
Harvard architecture with maximum clock speed of 740 kHz. the entire development board, the Monitor includes useful
From this point in history, the evolution in microprocessor subroutines, like displaying data in segmental display, reading
technique followed two lines. First had effort of the highest values from key board or delay subroutine used in Section III.
processing performance, with huge memory space. On the The development board is shown in Fig. 1.
other hand, the second evolution line contains single chip The instruction set of Intel 8080/8085 processors contains
microprocessor systems with low consumption and limited about 80 different instructions (several of them are
instruction and data memory spaces. This paper is focused subsequently modified for different registers), each with
into the second line and describes the differences of unique operation code. Most of these instructions are 8-bit
programming the device from 70’s (Intel 8085) and today’s wide, so they occupy only one address position in 8-bit wide
microprocessor technique (AVR).
The paper is divided into three main parts. The Section II
describes the development of hardware structure by
comparing the past used platform and a new one. The next
parts of the contribution, Section III and IV are focused on a
source code implementation in Intel 8085 and AVR,
respectively. Finely, the results are discussed in Section V.

The author would like to thank for the financial support of the Czech
Ministry of Education, Youth and Sports under grants no. MSM 002 163 0513
and of the Czech grant agency of Science Academy grant no. KJB 208
130 704.
Z. Fedra, Department of Radio Electronics, Brno University of
Technology, Purkynova 118, 612 00 Brno, Czech Republic (e-mail:
fedraz@feec.vutbr.cz).
T. Fryza, Department of Radio Electronics, Brno University of Fig. 1. Development board Intel SDK-85.
Technology, Purkynova 118, 612 00 Brno, Czech Republic (e-mail:
fryza@feec.vutbr.cz).

978-1-4244-2531-0/08/$20.00 ©2008 IEEE 148 HISTELCON-08


RAM program memory. The substance of a program
implementing was to encode each instruction by its own
operation code and write this code subsequently into memory
cells. This scenario was often repeated several times because
of programming error presence in the code and it was
necessary to rewrite at least tens of memory positions.
As a modern 8-bit microcontroller, the AVR type was
chosen. The AVR is an 8-bit RISC single chip microcontroller
with Harvard architecture which was developed by Atmel in
1996 [2]. The working registers are mapped in SRAM as the
first 32 memory addresses (32 general purpose registers)
followed by the 64 I/O registers. The Harvard architecture
enables simple pipelining. Most instructions take just one or
two clock cycles, making AVRs relatively fast among the 8-
bit microcontrollers. The instructions are stored in 16-bit
width Flash memory. The block structure of AVR
microcontroller is shown in Fig. 2.
While the code for the Intel 8080/8085 processors were Fig. 2. Block structure of AVR microcontroller.
mainly developed in assembly language, and followed by the
manual translation into machine language, the possibilities of
modern microcontrollers are considerably more comfortable
and effective. Although, the programming in assembly
languages is still popular between today’s 8-bit
microcontrollers’ programmers, the higher languages
(overwhelming majority of C language) are wildly using. In
addition, the programming of 16 or 32-bit processors is
unimaginable without the help of C language. The utilization
of the powerful development software tools, such as AVR
Studio, Code Warrior, IAR Embedded Workbench, and others
is inseparable for the today’s programming as well.
In the next text an implementation of a simple code of
stopwatch is tested with both microcontrollers: Intel 8085 and
AVR, respectively.

III. TESTING PROGRAM FOR INTEL 8085


For a stopwatch program, two basic code components must
be considered. First one is a delay loop producing the waiting
time tics and second one is a part for displaying an actual
time. The whole block diagram of the application is shown in
Fig. 3.

Fig. 3. Flowchart of stopwatch application.


A. Delay loop
The simplest way how to produce the delay function is a delay:
counting loop. To produce a loop time in ms, one 8-bit DCX D ; DE--
MOV A,D ; A <- D
register for counting is usually not sufficient, because of ORA E ; logical OR with accumulator
control signal frequency in units of MHz. Usually a 16-bit JNZ delay ; jump if not zero
register (or pair of two 8-bit registers) is used for
incrementation or decrementation operation. As mentioned 05F1 1B
above the delay subroutine for Intel 8085 is directly 05F2 7A
05F3 B3
implemented in Monitor operating system. The source code 05F4 C2 F1 05
and assembled code from address 05F1 (six bytes) are as
follows. The delay subroutine uses the register pair DE, thus the
maximum number of loop repetitions is 65,536. The total

978-1-4244-2531-0/08/$20.00 ©2008 IEEE 149 HISTELCON-08


duration of the delay function depends on the clock frequency
and on the velocity of the instructions execution. The
execution of each 8085 instruction could be different: the
decrement instruction DCX needs six clock periods, the move
instruction MOV needs four periods, etc. For maximum
number of repetitions (65,536), the total clock periods are
1,376,266. Assuming that fCPU=2 MHz, the maximum duration
of delay function is therefore 688 ms.

IV. TESTING PROGRAM FOR AVR

A. Delay loop
A structure of basic loop in assembly language for AVR Fig. 4. Source code compilation process.
microcontroller could be programmed in the following way
(the ATmega16 was chosen as a concrete device):

LDI R24, 0xFF ; load immediate


LDI R25, 0xFF ; load immediate
SBIW R24, 0x01 ; R24:R25--
BRNE PC-0x01 ; skip one instruction back
; if not zero

The resulted delay time depends on processor clock, tics


needed to perform one instruction and on direct constants
loaded in registers.
Each instruction in this delay loop has 16-bit OP code, so
delay loop has 8 bytes. The delay loop will take approximately
2 ms for 1,000 loop count and 2 MHz clocks.
It is good to show “manual” combination of two 8-bit
registers for education purposes. The serial sequencing of Fig. 5. Development board ATmega16.
counting registers produces only two times longer delay as
one register for decrementation like in this example: function is part of avr-libc library used in winavr project [3].
After examining the core of the function, something similar as
LDI R24, 0xFF ; load immediate our assembler code can be found. The core of function is
SUBI R24, 0x01 ; R24-- written in assembler and compiler optimization is turned off
BRNE PC-0x01 ; skip one instruction back for this part of code (to preserve proper timing). Because the
; if not zero
LDI R25, 0xFF ; load immediate delay is implemented as a count down loop, no other
SUBI R25, 0x01 ; R25-- processing can be made simultaneously. The interrupt can also
BRNE PC-0x01 ; skip one instruction back break this loop, so resulted delay time may be inaccurate.
; if not zero The on-chip timer/counter can be used for better precision
of time interval. The AVR microprocessor has usually at least
The much more effective code is with putting the registers one timer/counter unit integrated on chip. The units are 8-bit
“together”: or 16-bit and have clock prescaler to produce longer time
intervals. This modern integrated units has also many
LDI R25, 0xFF ; load immediate
loop: advanced functions like “output on compare” and PWM
LDI R24, 0xFF ; load immediate (pulse width modulation) generation. It can be produced delay
SUBI R24, 0x01 ; R24-- (interrupt) in several ms with 16 MHz, 1,024 prescaler and 8-
BRNE PC-0x01 ; skip one instruction back bit counter. It is hard to analyze the length of a compiled code
; if not zero
for delay loop in C language, because of amount of code
SUBI R25, 0x01 ; R25--
BRNE loop ; skip to loop if not zero related only to C compiler. The basic program for stopwatch
application has about 3.5 kB.
It can be produced delay in several ms with 16 MHz clock The source code is first compiled to assembly language and
signal and with a 16-bit register pair R25:R24 on AVR then translated to hex file. But the disassembler view can be
microprocessors. used for see the assembler compiled from the C source code.
In C language, some function for delay may be called. In The process of source code compilation is outlined in Fig. 4.
our case, the _delay_ms() function is the best choice. This

978-1-4244-2531-0/08/$20.00 ©2008 IEEE 150 HISTELCON-08


B. Time display TABLE I
COMPARISON OF TESTING APPLICATIONS
The first problem with time displaying is conversion of
binary data to decimal digits. The AVR microcontrollers have Parameter Intel 8085 ATmega16
no BCD (binary coded decimal) HW unit, thus the conversion Delay – size [B] 6 8
must be realized on SW layer. The first possibility is to count Delay – velocity* [ms] 10,5 2
in binary format and then convert to BCD (well known Stopwatch – size [B] 60 92 – assembly
3.5 k – C language
algorithm with adding 6), second possibility is to watch the
*Number of repetition = 1,000, fCPU=2 MHz
numbers after each incrementation process and correct them
immediately as they reach bounds of decimal part. This can be
combined with range correction for milliseconds (0-99) and V. CONCLUSION
seconds (0-59).
The performance of both microcontrollers Intel 8085 and
Each digit takes 4 bits in BCD format. One byte can carry 2
AVR ATmega16 was compared. The simple application of
digits, low nibble (4 bits) carry lower digit, and high nibble
stopwatch and delay subroutine was taken into account. Three
carry higher digit. This two-digits-per-byte encoding is called
test cases were examined: first, the total size and velocity of
packed BCD (or simply packed decimal). For incrementation
the delay subroutine. For velocity testing, the 1,000 number of
in BCD code, some correction must be made. The carry and
repetition and the clock frequency of 2 MHz were selected.
half carry (carry on 4. bit) is evaluated (after adding 6 to each
Last test case was focused into the total size of whole size of
digit) and this is used as test if number is in BCD format (if
stopwatch application. The comparison is shown in Table I.
carry is set, the number was bigger than 9 ant was not in
The whole program for ATmega16 without subroutines for
BDC) [4].
displaying and delay loop has 92 bytes (in assembly language)
There is a 7-segment 6-digits display on AVR development
and 3.5 kB (in C language). The subroutines are not counted
board realized at Department of Radio Electronics (see
because of relevant comparison with code for 8080/8085,
Fig. 5). The same segments are connected together for every
where delay and displaying is made by Monitor subroutines.
digits and each digit has own cathode. Segments are directly
connected to microcontroller; the cathodes are switched by REFERENCES
transistors controlled by microcontroller. The multiplexing of
[1] Intel. (2008, June 25). Microprocessor Quick Reference Guide [Online].
individual digits must be used for displaying whole number. Available: http://www.intel.com/pressroom/kits/quickreffam.htm#i486
The technique for multiplexing consists of switching off the [2] Atmel Corporation. (2008, June 25). AVR 8-Bit RISC [Online].
segments, activating proper cathode (digit), switching on the Available: http://www.atmel.com/products/AVR/
[3] Sourceforge. (2008, June 25). WinAVR [Online] Available:
segments, delay for small time (to let segments shine), http://winavr.sourceforge.net/
switching off the segments and continue to the next digit. [4] V. Vana, Mikrokontroléry Atmel AVR ASSEMBLER, Praha: BEN –
technicka literatura, 2003.

978-1-4244-2531-0/08/$20.00 ©2008 IEEE 151 HISTELCON-08

Potrebbero piacerti anche