Title: EGR 277 Digital Logic
1Lab 8 EGR 270 Fundamentals of Computer
Engineering
EGR 270 Fundamentals of Computer
Engineering Presentation for Lab 8 Introduction
to the MicroStamp11 and 68HC11 Assembly Language
Programming
Instructor Paul Gordy Office H-115 Phone
822-7175 Email PGordy_at_tcc.edu
2Lab 8 EGR 270 Fundamentals of Computer
Engineering
MicroStamp11 The MicroStamp11 is a
microcontroller or microprocessor. It is built
by Technological Arts and is based on the
Motorola 68HC11 microcontroller.
The MicroStamp11 is about the size of a postage
stamp!
Technological Arts states that the MicroStamp11
is the worlds smallest microcontroller module.
3Lab 8 EGR 270 Fundamentals of Computer
Engineering
- Docking Module
- The MicroStamp11 is attached to a docking module
so that it can be connected to a - serial cable for downloading programs,
accepting keyboard inputs, and displaying outputs - breadboard for interfacing with circuits
4Lab 8 EGR 270 Fundamentals of Computer
Engineering
MicroStamp11 Features (reference
www.technologicalArts.com)
5Lab 8 EGR 270 Fundamentals of Computer
Engineering
- Memory
- There are two types of memory
- ROM (Read-Only Memory) used to store permanent
programs and data. Data stored in ROM is not
erased when the MicroStamp11 is powered down, so
programs that you save will still be in memory
the next time you use the device. The
MicroStamp11 has either 8k, 32k, or 64k of ROM,
depending on the version of the MicroStamp11
purchased. - RAM (Random Access Memory) used as a scratchpad
to store variables during the execution of a
program. Data stored in RAM is lost when the
MicroStamp11 is powered down. The MicroStamp11
has only 256 bytes of RAM.
Clock and Data Transfer Rate The MicroStamp11 is
a digital synchronous device, meaning that all
instructions are executed in synchronization with
a hardware clock. The MicroStamp11 is available
with either 8MHz or 9.8304 MHz (Turbo version)
clock. Data can be transferred to the
MicroStamp11 via the serial cable at either 9600
baud (bytes/second) or 38400 baud (Turbo version).
6Lab 8 EGR 270 Fundamentals of Computer
Engineering
Power Source The 68HC11 is powered by a 5V DC
source. If a voltage of greater than 5V was
connected to the microcontroller, it might be
destroyed. The MicroStamp11 has a voltage
regulator on the board to protect it.
- Operational Modes (sliding switches)
- The MicroStamp11 has two modes of operation. The
modes are selecting by using - the sliding switches on the side of the
MicroStamp11 module. The modes are - Boot mode used when programs are downloaded to
the MicroStamp11. Slide the two switches
together to place the MicroStamp11 in boot mode. - Run mode used when programs are run by the
MicroStamp11. Slide the two switches apart to
place the MicroStamp11 in run mode.
7Lab 8 EGR 270 Fundamentals of Computer
Engineering
MicroStamp11 Module
Assembler and Simulator We will program the
MicroStamp11 using 68HC11 assembly language.
Refer to class notes for details on assembly
language programming. We will assemble programs
using the Mini IDE assembler. We can also
simulator programs using the Wookie simulator.
Refer to the handout Example Mini IDE
Assembler and Wookie Simulator available on the
instructors web page.
8Lab 8 EGR 270 Fundamentals of Computer
Engineering
Downloader A program named MicroLoad is provided
with the MicroStamp11 in order to download
compiled C programs (S19 files) into the
MicroStamp11.
9Lab 8 EGR 270 Fundamentals of Computer
Engineering
- Input/Output Ports on the MicroStamp11
- The majority of the pins on the MicroStamp11 (see
diagram below) are used for input and output so
that we can communicate with the microcontroller.
The input/output pins are arranged into two
ports with the names - PORTA (8 pins PA0 through PA7 corresponding
to pins 1-8) - PORTD (6 pins PD0 through PD5 corresponding
to pins 15-20)
10Lab 8 EGR 270 Fundamentals of Computer
Engineering
- Logical Value and Direction
- The pins on each port have two distinct states
- Logical State
- Logical 0 or LOW (0V)
- Logical 1 or HIGH (5V)
- Direction (the pin might be used as an input or
as an output) - IN (0)
- OUT (1)
- If a pin is configured as an output, then it acts
like a 0V or 5V source (depending on the logical
state) that can be applied to external circuits
or devices connected to the pin. - If a pin is configured as an input, then it acts
like a HIGH resistance load and the MicroStamp11
can read the logical state of the pin applied by
external circuits or devices connected to the
pin.
11Lab 8 EGR 270 Fundamentals of Computer
Engineering
PORTD PORTD is a bi-directional register, so each
pin may be configured as an input or as an
output. The direction is controlled by the
direction register DDRD.
Example
DDRD (bit5 bit0)
PORTD (bit5 bit0)
Result PD0, PD1, PD3 PD4 are inputs. PD2 PD5
are outputs.
PORTD and DDRD Addresses (see Table 4-1) In
assembly language, we can set or clear bits in
DDRD and PORTD by storing values at their memory
addresses. For the MicroStamp11 PORTD address
0008 DDRD address 0009
12Lab 8 EGR 270 Fundamentals of Computer
Engineering
PORTA PORTA has only two pins (PA3 and PA7) that
are bi-directional. It also has three pins
(PA0-PA2) that are always configured as inputs
and three pins (PA5-PA7) that are always
configured as outputs. Two bits in the hardware
control register PACTL are used to control the
direction of PA3 and PA7.
Example
PACTL (bit7 bit0)
PORTA (bit7 bit0)
Result PA7 set as an input. PA4-PA6 always
outputs. PA3 set as an output. PA0-PA2 always
inputs.
PORTA and PACTL Addresses (see Table 4-1) PORTA
address 0000 PACTL address 0026
13Table 4-1 Register and Control Bit Assignments
(reference MC68HC11D3.pdf) The table below is
used to determine memory address and bit
positions for various 68HC11 registers. Some key
items are highlighted.
14Table 4-1 Register and Control Bit Assignments
(continued)
15Table 4-1 Register and Control Bit Assignments
(continued)
16Lab 8 EGR 270 Fundamentals of Computer
Engineering
Example Set PD2 (Perhaps to turn ON an LED
connected to pin 18 on the MicroStamp11). Note
that the memory addresses for PORTD and DDRD from
Table 4-1 are used. LDAA 04 Set the
direction of PD2 to output (i.e., DDRD bit 2
1) (Note that this also configures all
other PORTD pins as inputs) STAA 09 Store
value at address for DDRD (09) LDAA 04 Set
the value of PD2 to 1 (HIGH) STAA 08 Store
value at address for PORTD (08)
17Lab 8 EGR 270 Fundamentals of Computer
Engineering
- Memory
- When working with microcontrollers and their
limited memory, it is important to be aware what
memory addresses are available for - 68HC11 registers
- Storing data
- Storing programs
- A memory map is often used to illustrate
different sections of memory. Different
microcontrollers have different amounts of
memory. Note that some memory addresses are used
to access RAM and others are used to access ROM. - RAM (Random Access Memory)
- Used for temporary storage of program data and
register contents - This information is lost when power is turned
off to the MicroStamp11 - Most MicroStamp11s have only 256 bytes of ROM,
although the 64K Max - MicroStamp11 is available with an additional
32kB of external RAM. - ROM (Read-Only Memory) or EEPROM (Electrically
Erasable Programmable ROM) - Used to store programs (i.e., S19 files that
are downloaded). - This information is NOT lost when power is
turned off to the MicroStamp11 - The MicroStamp11 is available with 8kB, 32kB,
or 64kB of EEPROM. - The MicroStamp11s to be used in lab have 32kB
of EEPROM.
18Lab 8 EGR 270 Fundamentals of Computer
Engineering
Memory Map for the MicroStamp11 (32k Turbo)
19Lab 8 EGR 270 Fundamentals of Computer
Engineering
MicroStamp11 Sample Program 1 Turn on an LED
connected to PA6 Note that classroom examples
often ignore some of the practical issues that
must be covered in lab, such as knowing specific
memory addresses for a given microcontroller,
setting reset vectors, etc. Discuss the example
below in detail.
20Lab 8 EGR 270 Fundamentals of Computer
Engineering
MicroStamp11 Sample Program 2 Blink an LED
connected to PA6 on and off
21Lab 8 EGR 270 Fundamentals of Computer
Engineering
7-segment displays A 7-segment display is made up
of seven LEDs configured to display the decimal
digits 0 through 9. There are two types of
7-segment displays 1) common anode (all anodes
at 5V) 2) common cathode (all cathodes at
ground) Common cathode displays Common cathode
displays require active-HIGH outputs. When the
output of the decoder or MicroStamp11 is HIGH for
one segment, 5V is connected to the anode. Since
all cathodes are grounded, the segment lights.
22Lab 8 EGR 270 Fundamentals of Computer
Engineering
Common anode displays Common anode displays
require active-LOW outputs. When the output of
the decoder or MicroStamp11 is LOW for one
segment, 0V is connected to the cathode. Since
all anodes are connected to 5V, the segment
lights.
23Lab 8 EGR 270 Fundamentals of Computer
Engineering
- Truth table for common anode displays
- For a common anode display (0 segment ON, 1
segment OFF) - Fill out the binary value for each segment
- Determine the corresponding values for PORTD and
PORTA
24Lab 8 EGR 270 Fundamentals of Computer
Engineering
Lab 8 The primary tasks in Lab 8 are Program
1 Connect a current-limiting resistor and an
LED to PA6. Enter, assemble, download, and run
MicroStamp11 Sample Program 2 (shown earlier in
this presentation) which will cause the LED
connect to PA6 to blink on and off. Program 2
Connect a common-anode 7-segment display (with 7
current-limiting resistors) to the outputs
PD0-PD5 and PA6 as illustrated below. Write a
program to count out the digits of your SSN or
EmplID in a continuous loop with about a 1 second
delay between counts. See next page for more
details.
(Discuss the details of Program 2 in lab)