introduction to the 68hc11

5
 egisters microprocessor does its work by moving data from memory into its internal egisters, processing on it , and then copying it back into memory. These registers re like variables that the rocessor uses to do its computations. There are two different types of registers: ccumulators, and index registers. ccumulators are used to perform most arithmetic operations , like addition, ubtraction, or performing logical and bit operations (and , or , invert). Resu lts of uch operations are often laced back into a register; for example , an instruction may add something to the  A" register and place the sum back into that same register. It is for this reason hat the name ccumulator is appropriate for these register types: they accumulate the results of n-going computations. ndex registers are used to point at data that is located in memory. For example , n the add operation just described , the addend (the number getting "added in" to he sum) might be ndexed by the "X"' register , meaning that the X register is being used to indicate he address of the data in memory. igure 5 shows the "programmer's model" of the registers of the 68HC11. he 68HC11 has two accumulators , labeled A and B. Each are 8-bit registers: hey hold one byte of data. he general-purpose index registers are the X and Y registers. These are 16-bit egisters and are most commonly used to address data in memory. he A and B registers can be used together as a 16-bit arithmetic register , in hich case they are named the D register. As indicated in the diagram , the A egister forms the "high bits ," r most significant digit , in this mode. he Stack Pointer , or SP register , is used to store the location of the  program tack . The stack, which is explained in detail later , is used for temporary storage f data, and to store the eturn address before a subroutine is called. he Program Counter , or PC, is used to keep track of the current instruction being xecuted. The PC is automatically incremented as the microprocessor proceeds hrough the instruction stream.

Upload: tarunag72801

Post on 07-Apr-2018

234 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to the 68HC11

8/6/2019 Introduction to the 68HC11

http://slidepdf.com/reader/full/introduction-to-the-68hc11 1/5

 egistersmicroprocessor does its work by moving data from memory into its internal 

egisters, processing on it, and then copying it back into memory. These registersre like variables that therocessor uses to do its computations. There are two different types of registers:ccumulators, and index registers.ccumulators are used to perform most arithmetic operations, like addition, ubtraction, or performing logical and bit operations (and, or , invert). Results of 

uch operations are oftenlaced back into a register; for example, an instruction may add something to the

 A" register and place the sum back into that same register. It is for this reasonhat the nameccumulator is appropriate for these register types: they accumulate the results of n-going computations.ndex registers are used to point at data that is located in memory. For example, n the add operation just described, the addend (the number getting "added in" tohe sum) might bendexed by the "X"' register , meaning that the X register is being used to indicate

he address of the data in memory.igure 5 shows the "programmer's model" of the registers of the 68HC11.

he 68HC11 has two accumulators, labeled A and B. Each are 8-bit registers:hey hold one byte of data.he general-purpose index registers are the X and Y registers. These are 16-bit

egisters and are most commonly used to address data in memory.

he A and B registers can be used together as a 16-bit arithmetic register , inhich case they are named the D register. As indicated in the diagram, the A

egister forms the "high bits,"r most significant digit, in this mode.he Stack Pointer , or SP register , is used to store the location of the  programtack . The stack, which is explained in detail later , is used for temporary storagef data, and to store theeturn address before a subroutine is called.he Program Counter , or PC, is used to keep track of the current instruction beingxecuted. The PC is automatically incremented as the microprocessor proceeds

hrough the instruction stream.

Page 2: Introduction to the 68HC11

8/6/2019 Introduction to the 68HC11

http://slidepdf.com/reader/full/introduction-to-the-68hc11 2/5

 

he 68HC11 chip includes many features that often must be implemented with hardwarexternal to the microprocessor itself. Some of these features include:

y  serial line input and output

y  analog to digital convertersy   programmable timersy  counters

his section explains how to use these advanced features of the 68HC11.

egister Block 

he 68HC11 uses a particular area of memory to interface with the special fu nctions. Thisrea of memory is called the register block and is located from addresses $1000 to $103F.

he general method of controlling the various features of the chip is by reading andriting data to the different registers in the register block. Sin ce the register block isapped into memory, the typical 68HC11 instructions for reading and writing data to any

rea of memory are used to interact with these registers.

lock Diagram of 68HC11

igure 9 shows a simplified block diagram of the 68HC11 architecture. This diagramepicts the 68HC11 in "single chip" mode

hen scanning the diagram, notice that some of the ports have arrows running inoth directions (ports A, C, and D). These ports are bidirectional , meaning that

hey can be used for ither input or output.ach port contains eight data bits, making it equivalent to one byte of data. Eachata bit is ma pped to a  physical  pin on the micro processor  package. This meanshat when data isritten to a particular output port, that data a ppears as voltage levels on the real 

ins connected to that  port. In this way, the 68HC11 can interface with external

evices.n many cases, ports may contain a mixture of pins used for either input or output.n other cases, particular pins in a port are dedicated to a specific function.

ollowing is a brief description of each port on the diagram. The rest of thisection explains how to use each port in detail.

Page 3: Introduction to the 68HC11

8/6/2019 Introduction to the 68HC11

http://slidepdf.com/reader/full/introduction-to-the-68hc11 3/5

.hi i i it l, i i ti l t that i l t ial ti and  nt

i it . The ti ers  an  e  sed t enerate  avef  rms f varying f requencies;he ounters can  e used to count cer tain events li e r ising edges of signal on the nput lines.ort B.

his is a digital por t that may  e used f or  output only.ort .

his is a digital, idirectional por t. Its def ault state is f or  input.ort D.

his is a idirectional por t dedicated to ser ial input and output f unctions. Two of 

hese pins are used f or  communications with a host computer .ort E.his is the analog input por t.

otorol rchitecture

he Mi t module i built around the Motorola 68HC mi ro-controller IC In

rder to program the MicroStamp11, you'll need to have a closer look at the 68HC11'srchitecture. The 68HC11's basic architectural blocks are shown in f igure 3. This f igure

xplicitly shows the per i pheral subsystems in the Motorola 68HC11 micro-controller and

t shows which pins those subsystems are tied to.

Fi ure 3: 68HC11 Architecture

rom f igure 3, we see that the 68HC11 has a number of pins. Some of these pins are used

o control the micro-controller's operating mode, clock logic, special interrupts, or power.

he major ity of the pins, however, have been organized into four 8-bit input/out put por ts.

hese por ts have the logical names PORTA, PORTB , PORTC, and PORTD. It is through

hese four por ts that the 68HC11 channels most of its interactions with the outside wor ld.

s mentioned ear lier, a micro-controller is of ten distinguished by the fact that itsnput/out put devices are directly mapped into RAM. This is also true of the I/O por ts in

he 68HC11. The logical names for the I/O por ts are associated with absolute addresses in

Page 4: Introduction to the 68HC11

8/6/2019 Introduction to the 68HC11

http://slidepdf.com/reader/full/introduction-to-the-68hc11 4/5

. ,xample, is set to a high logical level, then that logic level directly sets the value in theort's hardware register. Since that hardware register is mapped directly into the micro -ontroller's address space, a program can then directly r ead that register's value byccessing memory.

he I/ ports and other device pins are connected to special subsystems in the 68HC11.he subsystems shown in figure 3 are briefly described below:

y

 EPRO

Some versions of the 68HC11 have as much as 4 kilo -bytes of internalEEPROM. If your program is sufficiently small, then your micro-controller systemwould not need external memory chips and could be operated in single -chip mode.

y  R AM: The version of the 68HC11 in your MicroStamp11 has 256 bytes of internalR M. As mentioned above, some of these bytes are mapped into hardware registersthat are used to control the micro-controller. In reality the MicroStamp11 programmer only has 192 bytes of R AM that can be used for program variables.

y  Serial Peripheral Interface (SPI): This subsystem allows the 68HC11 tocommunicate with synchronous serial devices such as serial/parallel slave devices.

y  Serial Communication Interface (SCI): This subsystem allows the 68HC11 to

communicate with asynchronous serial devices. The SCI interface is used tocommunicate with laptop computers.y  Parallel I/O Interface: This subsystem is generally used to provide the 68HC11

with a way of writing digital data in parallel to an external device. The usual parallel device is a memory device. R ecall that the 68HC11 has a very limitedamount of internal program memory. If we need to augment the EEPROM in themicro-controller with additional memory, we use the parallel I/O interface toaddress, read, and write data to this external memory chip. When we do this weusually operate the chip in so-called expanded mode. R unning the chip inexpanded mode greatly reduces the number of I/O Ports available to the system.This is because POR TB and POR TC are connected to the memory chip and henceare unavailable for other external devices. Since the MicroStamp11 uses an externalmemory chip, it is running the 68HC11 in expanded mode and hence only POR TAand POR TD can be used by the programmer for interfaci ng with the external world.

y  Mode Selection System: This subsystem selects whether the 68HC11 runs inexpanded or single-chip mode. In single chip mode, the 68HC11 allows the user tohave complete control over all four I/O ports. In expanded mode, the 68HC 11 uses ports B and C to address, read, and write to external memory, hence the programmer can only use POR TA and POR TD. In the MicroStamp11 module, thechip is usually in expanded mode.

y  Clock logic: An important feature of micro-controllers is that they work in real-

time. By real-time, we mean that instruction executions are completed by specifiedtime deadlines. This means that the micro-controller needs a clock. The clock logicsubsystem provides the real-time clock for the 68HC11. The rate of the clock isdetermined by a crystal that is connected to the clock logic pins. The MicroStamp11has a crystal on the module, so these pins are not available to the programmer.

y  Interrupt Logic: Micro-controllers must be able to respond quickly toasynchronous events. The interrupt logic subsystems provides three pins that can beused to trigger hardware interrupts. A hardware interrupt automatically transferssoftware execution to a specified memory address in response to the hardware event(such as the pin's logic state going low). We say that this interrupt is generateda synchronously because the event can occur between ticks of the system's real -time

Page 5: Introduction to the 68HC11

8/6/2019 Introduction to the 68HC11

http://slidepdf.com/reader/full/introduction-to-the-68hc11 5/5

.respond in a timely manner to external events.

y  Timer Interrupts: This subsystem generates interrupts that are associated with aninternal timer. R emember that the 68HC11 executes instructions in step with aclock tick provided by the clock logic subsystem. With each tick of the clock, aninternal register called a timer is incremented. This timer is memory mapped to an

address in R AM with the logical name TCNT. SO at any instant you can fetch the

current count (time) on the timer by simply reading TCNT.

There are two types of interrupts associated with TCNT. An input-compare (IC)interrupt is generated with a specified input pin changes state. When the IC interruptoccurs, then the value in TCNT is stored in an input-compare register. This register is also memory mapped so the programmer ca n easily read the clock tick when theinput event occurred. Input compare events are often used to make very precisetiming measurements.

The other type of timer interrupt is called an output compare (OC) interrupt. Theoutput compare event occurs when TC NT matches the value stored in an outputcompare register. The output compar register is also memory mapped, so its value

can be easily set by the programmer. Output compare events are often used to forcethe micro-controller to respond to timed events.