ELE604 Student Guide
ELE604 Student Guide
May 2, 2013
2 Edit Date: February 12, 2013
Contents
1 Introduction 1-1
1.0.1 About this document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.0.2 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.0.3 Found a Mistake? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.1 What is ELE604 Sensors and Measurement? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.2 The Design Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1.3 Learning Objectives and Pedagogical Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1.3.1 Course Learning Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
3
4.5 More Examples of Sample Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
5 Grading 5-1
Bibliography 13-9
There is nothing more important than your safety. It is more important than the design. It is more important
than your marks. There are four main dangers in the lab:
Electrocution Many of the tools are connected to AC mains (110 or 220 VAC). Be careful when using these
devices. Always know where the Emergency Shut-off is. It’s typically a big red button on the wall. Look
for it!
Burns Watch where you put the soldering iron. It can easily burn your skin. Put the iron back into its holder
when it is not in your hand. Never set it down on the lab bench!
Fumes Solder smoke is bad for you! When soldering, turn on the table-top vents. Ensure that it is close
enough to your soldering iron to pull fumes away from you.
Projectiles When cutting wires, fragments can fly into your eyes. Wear glasses or goggles and, if possible and
safe, use your hand as a shield around the cutting tool (like a side-cutter). Don’t worry about looking
stupid. You’ll look even worse with wire sticking out of your eye.
Figure 1: Damage to hands from electrocution. (Cadaver images courtesy of Brosz and Associates)
These are real dangers. In the first lab session, Mr. Jim Koch will go over lab safety with you. If you have
any questions or concerns, please do not hesitate to ask. If you feel that a method or procedure is unsafe or
could be made safer, please bring it to our attention.1
1
Thanks to Wikipedia for the images: http://en.wikipedia.org/wiki/Hazard_symbol
9
10 Edit Date: February 12, 2013
Notes on Changes to the ELE 604 Lab &
Documentation
We want to provide you with the best learning experience for instrumentation systems design. In that light
we’ve watched trends outside of Ryerson and paid attention to internal feedback from students, staff and faculty.
ELE 604 has undergone changes almost every year since it first ran in 2009 because of this.
In 2011 we updated ELE604 to the 9s12-based Esduino system from Technological Arts, replacing the 8-bit
68HC11 board that had previously been used. The Esduino has a reduced component count, uses a 16-bit
processor and conforms to the ground-breaking Arduino form factor. In 2012 we updated the course, yet again,
so that students could use C rather than Assembler to program their Esduino-based instrumentation systems.
Bonus tasks were added to most labs in 2012, as well.
There will be some adjustments made over the course of the semester and in future years based on the
feedback from you, the students. We are open to hearing about your experiences and will do our best to
improve as we go along.
Documentation may change without notice (although we’ll do our best to give sufficient notice). Please keep
an eye out for the latest revision of this document.
11
12 Edit Date: February 12, 2013
Chapter 1
Introduction
1.0.2 Acknowledgements
This material is based on Dr. Mike Kassam’s original ELE744 “Electronics and Instrumentation” lab, and was
brought into ELE604 during its introduction in 2008/9 as a bridge between ELE504 and ELE744. Between
2009 and 2010 the Freescale HC11-based hardware was phased out and replaced with the Freescale 9s121 . I
would like to thank the faculty and staff who were involved in this transition, including Dr. Vadim Geurkov,
Mr. Ken Clowes, Mr. Nipin Malhotra, Dr. Andy Ye and Mr. Jim Koch. Mr. Jamil Jivraj provided feedback
on the course. Mr. Ron Wong did much of the underlying work to get the “Esduino” system integrated into
the course. Mr. Thomas Behan provided feedback and resources with a variety of hardware components. Mr.
Carl Barnes at Technological Arts provided much technical support and was very attentive to our feedback and
requests. Ms. Mehrnaz Shokrollahi capably introduced me to the HC11-based IPB in the first two years of
ELE604.
The course will cover the theory and principles of sensors and transducers (electrical, chemical and
mechanical). The topics covered include transduction techniques, linear/non-linear signal processing,
low noise amplifiers, instrumentation amplifiers, data converters. There will be small design projects
for the labs to reinforce sensor/transducer interfacing.
This document describes the work that students do with respect to “small design projects... to reinforce
sensor/transducer interfacing”.
1
The 9s12 is also referred to as the HCS12 or MC9S12
1-1
1.2 The Design Process
The typical Canadian engineering curriculum is designed to give you a taste of the engineering design process
in third year, preparing you for the design-centric courses in fourth year. ELE 604 is focused on providing you
with a meaningful design experience in that context. In Fig. 1.1 you will see the basic steps that you take.
You start by reading the project requirements and/or the specific lab requirements. Then you prototype
a solution to the problem at hand, testing it as required. If the test succeeds, or if you run out of time, you
generate a report. If it doesn’t work and you have more time you create a new prototype and test again.
This design process is tried-and-true, both in school and in industry. In ELE604 you get to try it out in a
hands-on way.
1. Produces a variety of documents using appropriate format, grammar, and citation styles for technical and
non- technical audiences; Cites evidence to construct and support an argument (7a)
2. Uses technical knowledge, design methodology, and appropriate design tools and related resources (4a).
Distinguishes between different design steps and carries out steps; Analyzes/evaluates progress of design.
(4c)
3. Develops further knowledge of uses of modern instrumentation, data collection techniques, and equipment
to conduct experiments and obtain valid data (5a)
4. Applies statistical procedures; Verifies and validates experimental results; Assesses accuracy/precision of
results (5b)
5. Lists current tools for analysis, simulation, visualization, synthesis, and design, and is competent in using
them; Understands the accuracy/limitations of tools and verifies the results’ credibility (5c).
2.2 Preamble
Although the evolution of the microcontroller began in late 1970s and early 1980s with the Intel 8048 and 8051
[10, 6], and the Motorola 6800-based 6801 [4] and, later, the 68HC11 [8] its cost outweighed the advantages at
first for use in high-volume smart instrumentation. With the advent, and rapid development, of high-density
CMOS based Integrated Circuit (IC) technology, the microcontroller has emerged as one of the fundamental
building blocks in electronics technology. In most modern instrumentation designs, digital signal processing and
control are increasingly replacing some of the traditional forms of analog signal processing/conditioning. This
has generally resulted in flexible product designs that tend to be reliable and cost-effective for mass production,
to have increased functionality on significantly smaller packaging footprints, and to be easily scalable. In tandem
with the microcontroller evolution, the CMOS technology has also led to the emergence of a host of “smart” IC
based sensors and transducers (e.g. accelerometer, pressure, force, temperature, humidity, position, proximity,
flow, etc.) giving designers perhaps a broader latitude to create sophisticated product designs.1
For today’s engineers, the myriad of IC based analog and digital devices in the marketplace has resulted in an
increased blurring of the line between traditionally analog and digital based instrumentation, thus demanding
confidence and proficiency in their abilities to apply knowledge to conjure up “neat” engineering solutions that
would most likely entail blending and integration of analog circuits and digital signal processing, high-density
and high-speed devices, smart transducers, effective PCB grounding/layout techniques, and so on. In such
instrumentation designs, optimization and trade-offs between microcontroller (or DSP) resources and analog
signal processing/ conditioning circuitry to meet product requirement specifications can often be daunting.
Thus, the main thrust behind this Major Project is to expose middle-level students to make effective design
and implementation choices (and trade-offs) to create an intelligent instrumentation that potentially embodies
state-of-the-art digital (e.g. microcontroller, smart sensors, etc.) and traditional analog (e.g. passive sensors,
stable amplifiers, signal conditioners, A/D, compensation networks, etc.) circuitry for a Cantilever Beam load
cell application used in industries like Aerospace, Automotive, Construction, etc.
1
Much of this material was originally written by Dr. Mike Kassam for ELE744 and, later, for ELE604. The original source for
this chapter was “ELE604 Sensors and Measurements Major Laboratory Project” by Dr. M. Kassam & Dr. J. Smith, Ryerson
University 2009
2-1
2.3 Jargon & Vocabulary
PWM Pulse-Width Modulation
Duty Cycle In a series of pulses, the duty cycle is the percentage of time that these pulses are “high” (generally
5 Volts) versus the period of the signal. So if a complete period is 0.5 seconds and the pulse is high for
0.1
0.1 seconds, the Duty Cycle (or Duty Factor) is 0.5 100% = 20%.
Strain Gauge also known as a strain-gage. This is a piece of metal attached to some substrate material under
test. As it bends the gauge will deform.
Stress Amount of force per unit area. Its units are the same as pressure. Symbol: σ.
Modulus of Elasticity A description of the tendency of an object’s deformation as force is applied. Units
are the same as pressure. Symbol: E.
Microcontroller This is similar to a microprocessor except that it is designed with more features to sense
and actuate (i.e. to control) a task, like home temperature regulation or firing a spark plug in car. A
microprocessor is more general in nature.
2.4 Background
In aircraft, it is often desirable to continuously sense and monitor stress points [11] along the wing span, and
the resultant deflection or inclination angle relative to its unstressed or resting longitudinal axis. The principles
behind such types of measurements can be demonstrated and implemented using a simple cantilever beam setup
as shown in Figure 2.1. For simplicity, the measurement of stress on the beam is limited to a single point and
the deflection angle, θ as depicted in Fig. 2.2. Brief summaries of stress and angle measurement principles are
given below, and the students are urged to review the lecture material, suggested reference articles and sensor
datasheets to gain further insights.
6F L
σ= (2.1)
W t2
where σ is the stress, F is the applied force, L is the distance from the gauge to the applied force, W is the
width of the cantilever, and t is the thickness of the cantilever (see Fig. 2.2). Stress (σ) is expressed in Newtons
per square meter. The applied force is measured in Newtons. The related equation for strain is
σ
= . (2.2)
E
Figure 2.2: Cantilever beam under load (Courtesy Dr. Mike Kassam)
Since σ is in Newtons per square meter, and E, the Modulus of Elasticity is also, strain is unitless ratio. This
shows that the Stress (σ) at a given point is directly proportional to the applied force magnitude, F and the
force distance, L (or the bending moment F L); and indirectly proportional to the beam width, W and the
square of the beam thickness, t. With all distance measurements in meters and the force in newtons, the Stress
(σ) will be found in units of newtons per square meter. Since modulus of elasticity, E in newtons per square
meter is known for the beam material, this allows the Strain () in meters per meter to be calculated. Once
this is accomplished, the resulting increase or decrease in the resistance of the strain-gauges can be determined.
Conversely, if the strain-gauge characteristics (e.g. GF , Ro , etc.) and resistance changes are known, then the
Strain () can be easily determined from the strain-gauges resistance changes, and from which both the Stress
(σ) and F can be calculated using the beam’s Eand dimensional values, respectively. As can be noted from
the equations, when the product (W t2 ) related to the dimensional Modulus of the beam is assumed relatively
unchanged and the applied force, F is known, then the Stress/Strain values linearly increase from zero (at
the force application point) to their maximum values at the fixed pivot point, allowing extrapolation of the
Stress/Strain along the cantilever beam from just a single measurement.
Students are encouraged to investigate similar techniques used in designs of load cells or force transducers.
A robust circuitry incorporating bridge amplifiers, bridge balancing and temperature compensation techniques,
proper signal conditioning and interface need to be designed to ensure accurate and repeatable measurements
of very small changes in the strain-gauge resistances converted to D.C. voltages.
Figure 2.3: The Futek LBB200 load cell. We use the FSH00889, with 4.5 N capacity. (Courtesy of Futek)
Figure 2.4: Inclination from vertical orientation of the MEMSIC 2125 device. The gravity vector, g is shown,
as are the vertical (y) and horizontal x references. (image courtesy of Dr. Mike Kassam)
2
stiction: “static friction”. This is the friction that holds an object in place against a surface prior to it moving. It’s observable
when you have a non-moving object on a horizontal surface (like a box on a table) and you push on it. The coefficient of friction
is relatively high and will hold the box in place until you reach a certain force threshold. At this point the box will start to move,
and you’ll discover that you do not need to push as hard to keep in moving. This is because the coefficient of dynamic friction is
lower than that of static friction (stiction).
• Robust analog signal processing and conditioning circuitry for the strain-gage measurements and conver-
sions to ensure accuracy, resolution and repeatability.
• Computational and resource efficient algorithms for the tilt-angle measurement with desired resolution
and update rate.
• Well designed software structure and efficient use of the 9s12 architecture resources to implement an
integrated solution for simultaneous “real-time” measurements and display of Stress, Force and Tilt-angle
parameters.
• Use of proper measurement techniques to establish Accuracy, Repeatability, etc. characteristics of the
strain-gage sensor (refer to lecture material and Textbook).
2.5.2 Specifications
The end-of-semester final project must be able to perform some very specific functions. They are listed below.
Your data-logging device will resemble the conceptual view shown in Fig 2.5.2a. This can take many different
forms, such as the example shown in Fig. 2.5.2b.
(a) Conceptual View (b) An example implementation
Figure 2.5: A conceptual view (a) of what your instrumentation system might look like from the outside (image
courtesy of Dr. Mike Kassam), versus an actual student implementation (b).
1. On Power-up, the names of the lab partners should appear on the LCD.
2. If the button is pressed twice, in quick succession, the LCD should show if the force and angles are in
“safe” or “dangerous” zones. No LEDs should be flashing. This should continue unless the user presses
the button once (to exit).
3. If the button was not pushed, or if the user has exited the other mode, the “Angle” LED should light-up
& flash indicating angle measurement in progress. The LCD display should display Angle in “real-time”,
as shown in Fig. 2.5.2a.
4. For Force selection, the user momentarily presses the Push-button once to light-up & flash the “Force”
LED, indicating Force measurement. The LCD display should display Force in “real-time”, as shown in
Fig. 2.5.2b.
5. When the user presses the Push-button again, only the “Force & Angle” LED is turned on and flashing,
with “real-time” display of the parameters, as shown in Fig. 2.5.2c.
6. When the user presses the Push-button again, the cycle reverts to displaying Angle.
7. If, at any point, the user presses the button for ten seconds or more the system should begin streaming
data to a PC where it can be read by Matlab. The LCD should display that PC communication is in
effect.
Figure 2.6: Some of the operations to display. (images courtesy of Dr. Mike Kassam)
Angle Using a separate test-jig, angle range should cover tilt of 0◦ to 180◦ (in a contiguous manner) from the
horizontal, with minimum resolution of 0.2◦ . The “dangerous” zone is 160◦ or more.
Deterministic “real-time” Update Rate Update or refresh rate for all measured values ≤ 30 msecs.
Cantilever Beam: Test jig on each lab bench has the strain-gage sensors and resistors mounted on the can-
tilever beam (from Futek), configured as a full bridge
Load Cell / Strain-Gauge Gauge is pre-mounted on 17-4PH Stainless Steel; GF = 2.0; Ro = 1000 Ω.
Voltage Reference The stable bridge excitation voltage should be set to 10V d.c. using the 10V Voltage
Reference IC provided in your Kit.
Microcontroller Technological Arts 9s12 Esduino board: Refer to Datasheets and Lab Manual.
Pushbutton
LED
switch(es)
Digital Digital
input output
Accelerometer 9s12 LED
ADC SPI
LED
External Voltage
reference LCD Display
Figure 2.7: This is the suggested block diagram for the complete system.
• ELE604 Course Text: “Principles of Measurement Systems by John Bentley, Prentice Hall, 4th Edition,
2005
• “ Microelectronic Circuits”, Sedra and Smith, 5th edition, Oxford University Press, 2003.
• “Electronic Angle Measurement”, Circuit Cellar, Issue 179, June 2005, www.circuitcellar.com
• “Pieces of the Puzzle” & “Measuring Gage Factor”, The Mechanics www.vishay.com/brands/measurements_
group/guide/notebook/e5/e5.html
• “Cantilever Bending Beam Load Cell” Specifications from Futek Advanced Sensor Technology Inc., www.
futek.com
• Datasheets for the strain-gauge, IA amplifiers, voltage reference, etc. can be found on the ELE604 Course
website.
• Populate and solder the microcontroller’s main components, fully test the microcontroller board and 9s12
operations, and the embedded Serial Monitor. Understand the architecture resources of the 9s12 (e.g.
Input Capture, Output Compare, Analogue to Digital Converter, Timers, Interrupt structure, etc.) to
formulate a proper software structure solution for the instrumentation requirements.
• Design, implement and test the push-button switch and the LEDs, together with your source-code to
monitor the switch and drive the LEDs,
• Develop a detailed high-level flow chart or pseudo-code for your software structure. Keep in mind that
while it is prudent to test the Strain-gage and accelerometer sensors independently, your software structure
should take into account the requirement of concurrent measurements in “real-time”. Dedicated in-code
algorithm and table-look-up schemes need to be used to meet the “real-time” specifications.
• Develop the interface and algorithms for the Tilt-Angle measurement (refer to the Lab Assignment Sheet).
Use the test-jig provided in the Lab to test your design, and make the appropriate measurements to validate
the specifications.
• From your design analysis, use MapleSim software package to capture and simulate your designs for the
various analog signal processing/conditioning circuitry required to reliably measure the Force (and stress)
on the Cantilever beam (refer to the Lab Assignment Sheet). Familiarize yourselves with the finer details
of the cantilever beam test jig supplied in the Lab. Compare the simulated results with your theoretical
analysis & predictions. Generate and plot all the relevant signals.
• Once the Angle and Force (or Stress) functions are independently tested, your source-code should be
evolved to integrate both sets of measurements to realize the full functionality of the instrumentation.
Make appropriate measurements to your integrated design to validate compliance to the desired specifi-
cations.
• Prepare a formal technical report as per the guidelines provided. One formal report per Lab group is
required (limited to maximum of 12 pages, not including source code, references, and Appendix)
2.9 Schedule
The schedule is outline in Fig. 2.8.
Note: Failure to submit and/or demonstrate the above deliverables as scheduled will result in an automatic
zero mark for each of the missed milestone. No exceptions.
2-11
will be used for design. enhancements implemented. Final
6,8 Strain Gauge test Pre-lab: Prepare Milestone 2 4 Hours n/a source-code version to be
documentation. compiled/assembled during the
demo. A printed copy to be
Lab: In Week 6, implement and test submitted to Lab Instructor. Submit
analog circuitry design for strain- Milestone 4 in week 13: Show final
gage, and then interface to schematic, algorithms (including
microcontroller. Implement S/W to flow-chart) and test results. Wrap
provide FORCE function per up design in Week 14.
specifications. Undertake the
measurements to characterize the Post-lab: Hand in Milestone 5 (Final
strain-gage sensor & circuitry. Report) by email to TA by last day
Continue to work on integrating of classes at 11:59pm (i.e. before
FORCE & ANGLE functions per final exams). Only one formal report
specifications. In Week 8, per group is required (following
The load cell is effectively a pre-packaged strain gauge mounted on a cantilever (bending) beam. We will be
going over strain gauge theory in the class. At this point it is sufficient to say that the resistance of the load
cell’s strain gauge changes as the beam bends. You can use this to determine a relationship between the force
applied to bend the beam and the changing voltage that is output by the load cell.
The test jig is set up to permit you to hang small masses off of it. Do not overload it beyond the capacity (as
detailed by the TAs and technical staff).
The Accelerometer
The MEMSic accelerometer is described in the previous chapter. Additional information can be found in the
Appendix and online. Given that the part is sold by Parallax, there is a surprising amount of online resources
for you to examine.
You will provided with a test jig that will permit you to rotate the accelerometer in a vertical plane. You will
attach your own accelerometer to this test jig, which includes a protractor for visually estimating the angle.
3-1
3.1.3 The Microcontroller
Introduction
Microcontrollers are useful devices for creating embedded systems – engineered products that interact with us
in often mundane but eminently useful ways. The next time you use a public toilet (see Fig. 3.3) and it flushes
itself you can thank the microcontroller embedded in it.
In the late 1990s a series of 8bit HC11 microcontroller boards were introduced into the EE and COE
curriculum at Ryerson [9]. These 8bit devices were best-in-class for teaching a series of courses involving
embedded microprocessors and microcontrollers. Even our colleagues in Mechanical Engineering are using
these HC11s! However, starting in 2009, we began to look for alternatives since Freescale had categorized the
HC11 as “not suitable for new designs”. After examining a number of options (ARM, AVR, PIC, 8051, etc.) the
“NewRyeMicro” committee realized that the HC11’s descendant, the Freescale 9s12, was the superior choice.
Like the HC11 before it, the 9s12 is designed for automotive and industrial use, but the lessons-learned are
notable: better debugging methods, smaller chips, tighter integration of onboard modules, true 16bit operation,
onboard flash, etc. Many of the support components required for useful operation of the HC11 are no longer
needed, or are found onboard the 9s12. Plus, many of our in-house technical and teaching resources could be
easily adapted to the new processor.
2. Local resources. The 9s12 board we use, the Esduino, is designed, manufactured and supported by a
Mississauga-based company. We’ve had in-person meetings with the designer, Mr. Carl Barnes, and he
has been very responsive to our needs. Stores like Creatron stock the Esduino and support components.
3. Form-factor. The AVR-based Arduino has been a game-changer in the hobbiest market3 . It is immensely
popular and has spawned the development of countless main and application (“shield”) boards. We are
leveraging the Arduino’s physical layout with the Esduino, allowing you to use most Arduino shields with
your project, if you so choose.
4. Local education. Most of you already have a background on the 9s12 from COE538. While it’s not a
prerequisite, it is certainly advantageous here.
5. Real-world use. The 9s12 is found in many automotive applications, where hard real-time operation is
required. The next time you fire-up your BMW or Mini Cooper it could be a 9s12 running your engine.
1
The 9s12 microcontroller is 4MHz, but is 25MHz when phase-locked-loop (PLL) is activated. It’s 25MHz when running under
Codewarrior “Load” - serial monitor
2
ARM texts: http://www.keil.com/books/armbooks.asp
3
For an excellent explanation for why the Arduino changed the microcontroller market refer to http://blog.makezine.com/
archive/2011/02/why-the-arduino-won-and-why-its-here-to-stay.html
PIC The 16-bit versions fixed architectural problems in the original 8-bit PICs. The 16-bit are also more
prototype friendly than the 32-bit versions due to DIP packaging.
8051 These 8-bit processors are sold by a number of different companies and have been around since the 1980s.
AVR These 8- and 32-bit micros are very popular with hobbyists, in large part due to the Arduino boards.
ARM Hugely popular in high-end embedded systems like cellular telephones. These 32-bit systems generally
need an operating system and are not for beginners.
PowerPC Like ARM, these are 32-bit, and are not recommended for beginners. They’re found in the XBox
360 and Wii, as well as in automotive applications.
Coldfire Originally descended from the Motorola 68000 family (think Amiga and earliest Macintosh comput-
ers), these are 32-bit, and are not recommended for beginners.
HC08 These are smaller, less powerful (8-bit) Freescale processors often found in automotive applications.
The 9s12 strikes a good balance between power, cost and development resources. You will be able to use
it for ELE604, as well as other courses like the fourth year Engineering Design Project (ELE700/800). It will
also provide you with the right framework for using other microcontrollers and microprocessors, like the PIC
or ARM, in the future.
In future designs work, you should be open to all microcontroller options. Most are just as capable to
perform basic tasks as the others. Most have the same hardware features (UARTs, timers, ADCs) as the
others. The differences are subtle and should be examined with care.
9s12 History
1. Motorola 6800 (8-bit; 1974 [4, 7])
Resources
2. http://uhaweb.hartford.edu/jmhill/suppnotes/
6. Courseware: http://www.freescale.com/webapp/sps/site/overview.jsp?nodeId=06258A2580257B
3.1.4 Circuits
Circuits will be prototyped on “breadboards”. This means that the design can be easily modified and tested
without having to solder. The breadboards provided in your lab kit can be taped to the small printed circuit
“proto” boards that are Esduino compatible. So you can even test the circuit while it is mounted on the
Esduino. Then, if you appropriate, you can remove the breadboard and directly solder to the protoboard.
The LCD board, for instance, will be made of a soldered protoboard without prototyping on a breadboard
first. You will also attach switches and LEDs to this protoboard.
We use Codewarrior to program the 9s12. Most of you will have taken COE538, in which the 9s12 has been
introduced. The variant of the 9s12 that we use is similar but has a slightly different memory structure. There
are also fewer pins and resources on this version of the chip. A number of guides for using Codewarrior and
Assembler are found in the Appendix. A short introduction on how to get set up is found in the next chapter.
4
The HCS12 family includes the 9s12 parts, the first being the MC9S12DP256. [13]
Figure 3.1: Each lab bench is supplied with key tools: (a) A variable power supply, capable of ± 15 VDC
output, (b) a function genertor for providing 5VDC pulses to your microcontroller, (c) a multimeter for testing
resistance and (primarily DC) voltage signals and power lines, (d) an oscilloscope for examining time-varying
voltages, and (e) a soldering iron and ventilator.
MC9S12C32
Block Guide
> Clock generation > Provides high performance using cost-effective S12ATD10B8CV2 HCS12 10-bit 8-channel Analog to
reference crystals Digital Block Guide
> Reset generation
S12BDMV4 HCS12 Background Debug (BDM)
> Reduces generated noise Block Guide
> Phase-lock loop (PLL) clock
frequency multiplier > Reduces power consumption S12BKVD1 HCS12 Breakpoint (BKP) Block Guide
> Limp home mode > Easily able to implement real-time clock S12CPUV2 HCS12 CPU Reference Manual
S12CRGV2 HCS12 Clock Reset Generator
> Real-time interrupt Block Guide
Target Applications > Watchdog S12ECT16B8CV1 HCS12 16-bit 8-channel Enhanced
Features Benefits Capture Timer Block Guide
> Automotive applications 8-bit or 16-bit Pulse Width Modulation (PWM)
High-Performance 16-bit HCS12 CPU Core S12EETS4KV2 HCS12 4K EEPROM Block Guide
> Industrial control > 6-channel, 8-bit or 3-channel, 16-bit PWM > Efficiently implement motor control, battery S12FTS256KV2 HCS12 256K Flash Block Guide
> 25 MHz bus operation at 3.3V to 5V for > Opcode compatible with the 68HC11 charging or digital-to-analog (DAC) functions
40 ns minimum instruction cycle time and 68HC12 > PWM supports center-aligned or S12IICV2 HCS12 I2C Block Guide
left-aligned output S12INTV1 HCS12 Interrupt (INT) Block Guide
> C-optimized architecture produces extremely
compact code > Separate control for each pulse width S12MEBIV3 HCS12 Multiplexed External Bus
Overview and duty cycle Interface (MEBI) Block Guide
On-Chip Debug Interface
Freescale Semiconductor’s HCS12 family of > Programmable clock select logic with a wide S12MMCV4 HCS12 Module Mapping
> Single-wire background debug mode > Real-time emulation of MCU functions at full Control (MMC) Block Guide
range of frequencies
microcontrollers (MCUs) is the next generation operating voltage and frequency range with no S12PWM8B8CV1 HCS12 8-bit 8-channel Pulse-Width
> On-chip trace buffer with nine flexible trigger limitations like traditional emulators > Fast emergency shutdown input Modulator Block Guide
of the highly successful 68HC12 architecture. modes and multiple hardware breakpoints
> Real-time in-circuit emulation and debug One Serial Communications Interface S12SCIV2 HCS12 Serial Communications
Using Freescale’s industry-leading, 0.25 µs Flash, > Non-intrusive emulation without expensive and cumbersome Interface Block Guide
box emulators > 8192 prescaler option > Asynchronous communication between the S12SPIV2 HCS12 Serial Peripheral Interface
the MC9S12C32 is part of a pin-compatible MCU and a terminal, computer or a network Block Guide
> Read/write memory and registers while of MCUs
family that scales from 32 KB to 128 KB of running at full speed S12VREGV1 HCS12 Voltage Regulator Block Guide
> Exact baud rate matching
Flash memory. The MC9S12C32 provides an > Bus state analysis without the expense of a
upward migration path from Freescale’s traditional emulator One Serial Peripheral Interface
68HC08, 68HC11 and 68HC12 architectures Network Module > Up to 6.25 Mbps > High-speed synchronous communication Cost-Effective Development Tools
between multiple MCUs or between MCU For more information on development tools, please refer to
for applications that need large memory, many > One MSCAN module implementing the CAN 0 > Programmable bit rate up to 1 Mbps and serial peripherals the Freescale Development Tool Selector Guide (SG1011).
A/B protocol
peripherals and high performance. > FIFO receive approach superior for Up to 58 Input/Output (I/O) Lines M68MOD912C32 MC9S12C32 MCU module board;
• Five receive buffers per module with FIFO event-driven networks $24.95 stand-alone MCU board in a 32-pin
storage scheme > Programmable pull-ups/pull-downs > Reduced system cost DIP form factor
• Three transmit buffers per module with > Dual drive capability > Ability to tailor application for minimum EMC M68DKIT912C32 MC9S12C32 demo kit that
internal prioritization or high current loads $49.95 includes docking board,
M68MOD912C32 and
Integrated Third-Generation Flash Memory power supply
> In-application reprogrammable > Flexibility to change code in the field Application Notes and Engineering Bulletins M68DKIT912C32-E Universal Power supply included
> Self-timed, fast programming > Efficient end of line programming $64.95
AN2206 Security and Protection on the HCS12 Family
• Fast Flash page erase—20 ms (512 bytes) > Total program time for 128 KB code is less M68EVB912C32 Evaluation board for development
AN1280 Using and Extending D-Bug12 Routines $150 and evaluation of MC9S12C32
than five seconds
• Can program 16 bits in 20 µs while in AN2255 MSCAN Low-Power Applications application code
burst mode > Reduces production programming cost
HCS12 CPU M68EVB912C32E Universal Power supply included
through ultra-fast programming AN2287 HCS12 External Bus Design
> 3.3V to 5V Flash program/erase/read $170
> No external high voltage or charge pump AN2302 EEPROM Emulation for the MC9S12C32
SCI > Flash granularity—512 byte Flash erase/ M68CYCLONEPRO HC08/HCS08/HC12/HCS12
32 KB Flash required
2 byte Flash program BCANPSV2.0 Bosch Controller Area Network (CAN) Version 2.0 Protocol Standard $499 stand-alone Flash programmer or
> Virtual EEPROM implementation, Flash array in-circuit emulator, debugger, Flash
SPI > Flexible block protection and security usable for EE extension HCS12CFAMILYPP HCS12 C-Family Product Proposal programmer; USB, serial or Ethernet
interface options
2 KB RAM 10-bit Analog-to-Digital Converter (ADC)
Vreg USBMULTILINKBDM Universal HCS08/HCS12 in-circuit
3.3V to 5V > One 8-channel ADC > Fast, easy conversion from analog $99 emulator, debugger, and Flash
Internal Bus
inputs like temperature, pressure Package Options 48-Pin LQFP programmer; USB PC interface
ATDO > 7 µs, 10-bit single conversion time; scan and fluid levels to digital values 0.5 mm Pitch
10-Key Wake-Up 10-bit, 8-ch. mode available for CPU processing Part Number Package Temp. Range 7 mm x 7 mm Body
80-Lead QFP/LQFP CWX-H12-SE CodeWarrior™ Special Edition for
IRQ Ports MC9S12C32CFA 48 LQFP -40˚C to +85˚C
0.65 mm Pitch Free HCS12 MCUs; includes integrated
Timer Module MC9S12C32VFA 48 LQFP -40˚C to +105˚C 14 mm x 14 mm Body development environment (IDE),
Timer MC9S12C32MFA 48 LQFP -40˚C to +125˚C
> 8-channel timer, each channel configurable as > Flexible, programmable linker, debugger, unlimited
16-bit, 8-ch. MC9S12C32CPB 52 LQFP -40˚C to +85˚C 52-Pin LQFP
DBG12 either input capture or output compare timer system 0.65 mm Pitch
assembler, Processor Expert™
MC9S12C32VPB 52 LQFP -40˚C to +105˚C
10 mm x 10 mm Body auto-code generator, full-chip
MC9S12C32MPB 52 LQFP -40˚C to +125˚C
> Simple pulse width modulation simulation and limited C compiler
1 x CAN MC9S12C32CFU 80 QFP -40˚C to +85˚C
PWM (PWM) mode
2.0 A/B 8-ch., 6-ch./16-bit, 3-ch. MC9S12C32VFU 80 QFP -40˚C to +105˚C
> 16-bit pulse accumulator MC9S12C32MFU 80 QFP -40˚C to +125˚C
Learn More: For more information about Freescale products, please visit www.freescale.com.
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names
are the property of their respective owners. This product incorporates SuperFlash® technology licensed from SST.
© Freescale Semiconductor, Inc. 2005
Document Number: MC9S12C32FS
REV 1
Figure 3.2: The promotional datasheet for the 9s12 variant used on the Esduino
(a) AED and Ticket Machine (b) Toilet (c) Car (d) Legged Robot
Figure 3.3: Applications of embedded systems: (a) an Automated External Defibrillator and transit ticket
machine, (b) an automated toilet, (c) a car and (d) a robot.
PP5/KWP5/PW5
PM0/RXCAN
PM1/TXCAN
PM2/MISO
PM4/MOSI
$0000 1K Register Space
PM5/SCK
PS0/RXD
PS1/TXD
PAGE MAP
PM3/SS
VDDX
$03FF Mappable to any 2K Boundary
VSSX
VSSA
$0000
$0400
48
47
46
45
44
43
42
41
40
39
38
37
PW0/IOC0/PT0 1 36 VRH
$3FFF Mappable to any 2K Boundary
$4000
PW1/IOC1/PT1 2 35 VDDA
PW2/IOC2/PT2 3 34 PAD07/AN07
$3E
PW3/IOC3/PT3 4 33 PAD06/AN06
VDD1 5 32 PAD05/AN05
$8000
$8000 VSS1 6 MC9S12C-Family 31 PAD04/AN04
MC9S12GC-Family PAD03/AN03
16K Page Window PW4/IOC4/PT4 7 30
EXT 2 * 16K Flash EEPROM Pages PPAGE
IOC5/PT5 8 29 PAD02/AN02
$BFFF
IOC6/PT6 9 28 PAD01/AN01
$C000
$C000 16K Fixed Flash EEPROM
IOC7/PT7 10 27 PAD00/AN00
MODC/BKGD 11 26 PA0
$3F
$FFFF
$FF00 BDM PB4 12 25 XIRQ/PE0
13
14
15
16
17
18
19
20
21
22
23
24
$FF00 (If Active)
$FFFF VECTORS VECTORS VECTORS $FFFF
The figure shows a useful map, which is not the map out of reset. After reset the map is:
$0000 - $03FF: Register Space
$0800 - $0FFF: 2K RAM
Flash Erase Sector Size is 512 Bytes
(a) Memory
Figure 1-5 MC9S12C32 and MC9S12GC32 Map
User Configurable Memory Map (b) Pin Layout
Figure 3.4: The memory map and pin layout of the MC9S12C32 processor used on the Esduino. From [?]
Figure 2-3 Pin Assignments in 48 LQFP for MC9S12C-Family
32
54
PT3
PT7
PT6
PT2
PT1
PM5
PM2
PAD07
PAD06
DIG1
DIG0
PT0
Select between PS0/PS1
J14 US JB4
GND J3 and PM0/PM1 assignments
[J9][J10]: [Xbee Option]
>
<
D2
+5V
J1
for DIG0 and DIG1 pins
D13
D12
D11
D10
D9P
D8
D7
D4
Plug ADXB here for XBee Interface U4
GND
DTR
SX UX
UX SX
AREF
PT4 PM3 S M
(3V/5V compatible). SPI [J11] BDM IN:
DIG11
PWM D6
PWM D5
<TX US J6 C17
D2 JB2
1 PWM D3
GND J15 DI PM4 PT5
JB8
[J6]: SPI peripheral connector Standard 6-pin Background
RX > ADXB +5 JB3
SPI signals, Output Enable, +5V, J10 Esduino Debug Mode connector for
SCK
PP5
JB1
BDM IN
and Ground are all brought out to www.TechnologicalArts.com advanced debugging use
SS* R5 J11 LOAD
VIN C6
this convenient connector for easy OE* J5 JB6 SW1
USB [SW1 and JB6]:
interfacing to SPI peripherals DO C5 MAN
PB4 R1
G C7
When JB6 set to MAN, use SW1 to
[JB1]: 5V Source Selector PWR PE7 select Serial Monitor mode.
D3 C10
AUTO RUN
PE4
1-2 (lower): 5V from USB Y1 When JB6 set to AUTO, Serial
U1
R6 D1 PA0 R3
J8
3-9
2-3 (upper): 5V from U1 via VIN C1 C11 PM0 Monitor mode must be controlled
+
J9 Y2 JB5 PM1
[D1]: Power indicator LED by host via DTR line on serial port.
R2 3V 5V J7 AN7
J12 C16 VDD VRH AR
AN6
C15 C14 JB7
[J7] PB4, PE7,PE4,PA0: C9 [J8] PM0 - PM1:
U3
Four bonus Digital pins. RESET +
VIN
AN0
AN1
AN2
AN3
AN4
AN5
GND
GND
J4
SW2
REV. 1 J13
[U3]: 3.3V regulator (800 mA max.) transceiver to implement a
CAN interface.
PAD00
PAD01
PAD02
PAD05
PAD03
PAD04
Figure 3.5: The Esduino functionality is displayed here. Layout (Rev 1) courtesy of Technological Arts.
Suppliers
Digi-Key
Electro Sonic
Future Electronics
Jameco
Mouser Electronics
NEWARK
A-1 Electronics Parts 196 North Queen Street (416) 255-0343 www.a1parts.com
Mississauga
North East
Toronto
Hardware Stores
Polytechnic Hardware 131 Dundas Street East, Toronto (416) 350-7272
Hobby Shops
John's Hobbies 2188 Danforth Ave, Toronto (416) 421-1850 John's Hobbies
Panther Hobbies & Trains 2580 Wharton Glen Ave., Mississauga (905) 848-0743 www.pantherhobbies.com
North Star Hobbies 2200 Dundas Street East, Mississauga (905) 566-4758 www.northstar-hobbies.com
Efston Science 3350 Dufferin Street, Toronto (888) 777-5255 www.eScience.ca
Back to Index
Figure 3.6: Supplier list, provided by Mr. Jim Koch on his website.
While you undertook 9s12 programming in Assembler in your COE538 class, in ELE604 we encourage you to
mix-and-match Assembler and C. The basic structure of your code, as well as aspects that are not time-critical
should be developed in C, while time-critical components should be targetted for Assembler programming.
1. Start up Codewarrior.
(a) Select the derivative: HCS12 − > HCS12C Family − > MC9S1232
(b) Select the default connection: HCS12 Serial Monitor
4. Select C
A tutorial for Codewarrior (and C programming) can be found in Appendix P, starting on page P-1
4-1
A tutorial on using the Serial Monitor for interacting with the 9s12 can be found in Appendix N, starting
on page N-1.
On the lab PCs in ELE306 and ELE307 the default “COM Port” is 3. While the PCs run Linux you can
access Codewarrior through the Windows VMWare virtual machine.
; ∗ PROGRAM DESCRIPTION :
; ∗ A p u s h b u t t o n w i r e d f r o m PT1 ( i . e . DIG5 on E s d u i n o ) t o Ground will
; ∗ t u r n o f f on−b o a r d LED D2 ( on PM5) w h i l e p r e s s e d .
; export symbols
XDEF Entry , Startup ; e x p o r t ’ Entry ’ symbol
ABSENTRY Entry ; for a b s o l u t e a s s e m b l y : mark t h i s as application entry point
; Include d e r i v a t i v e −s p e c i f i c d e f i n i t i o n s
INCLUDE ’ d e r i v a t i v e . i n c ’
; v a r i a b l e / data section
; code section
ORG ROMStart
Entry :
Startup :
; remap t h e RAM & ; EEPROM h e r e . S e e EB386 . p d f
ifdef HCS12 SERIALMON
; s e t r e g i s t e r s at $0000
CLR $11 ; INITRG= $ 0
; s e t ram t o end a t $3FFF
LDAB #$39
STAB $10 ; INITRM= $ 3 9
mainLoop :
b r s e t PTIT , #%00000010 , LEDON ; if switch is open t h e n t u r n on LED
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
;∗ Interrupt Vectors ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
ORG $FFFE
DC.W Entry ; Reset Vector
• Assembler examples: check the Appendix. One of which is an example of programming Interrupt Services
Routines (ISR).
• C examples: http://support.technologicalarts.ca/docs/Esduino/Code/C/CW/
Now connect a USB cable between a USB port on your PC and the USB interface module you are using. Win-
dows should report a new device has been found and proceed to initialize it.
BDMPods/ConfiguringVirtualCOMports.pdf)
will see one entitled USB Serial currently using it.
Port, with the assigned COM port
number identified in brackets.
4-4
To work with most of the tools you are likely to use with microcontrollers, the COM port should be 1, 2, 3, or 4.
If it is higher than COM4, you’ll probably want to change it. Do this by right-clicking the line USB Serial Port
and select Properties from the popup menu.
Click OK, and if Windows warns you about a duplicate, ignore the warning and click Yes. Click OK and then
OK to the port settings. Then close the Device Manager window. If you want to confirm the port change has
indeed been made, click on Device Manager again and check the listed Ports. Now close the System Proper-
ties window.
At this point, you are ready to use the virtual COM port in any application!
Note that, if you unplug the USB device and plug it back in later, Windows will still remember the COM port
assignment, so you won't need to go through this procedure again.
wwwwww..TTeecchhnnoollooggiiccaallAArrttss..ccoomm
!eevv.. 00
Int. Serial
0xF77F
0xF7FF
0xF800
0x0400
0x3800
(SW2 on Esduino
must be set
to "Load")
0x0FFF
0x0800
0xC000
0xFFFF
0x03FF
0xFF00
0x8000
0x0000
Immediately after Reset
Int. Vectors
2kB RAM
EEPROM
EEPROM
Registers
(16kB)
(16kB)
Flash
Flash
Figure 4.2: You will have to assign different parts of the code to different locations in memory. “Scratch”
variables will be placed in RAM, the main code will be stored in Flash EEPROM, as will the interrupt vector
table. Control registers are located in teh first 1kByte of memory. The RAM is found starting at $3800. Flash
EEPROM is set to start at $4000. The code is modeled after ex. 11-18 in [12] while the memory model for the
MC9s12c32 is from [1, p. 32]
Grading
Each component of the lab has a particular weight (with respect to your lab grade) associated with it:
Milestone 1 5%.
Milestone 2 25%.
Milestone 3 25%.
Milestone 4 15%.
Milestone 5 15%.
5-1
5-2 Edit Date: February 12, 2013
Chapter 6
Week 1: No Labs!
There are no labs in the first week of school. However, you should find a lab partner (two partners per group)
and buy the lab kit. One lab kit is to be purchased per group. Please see Mr. Jim Koch for the purchase.
6.1 Checklist
The following is a checklist of things that you are expected to do during this week:
6-1
6-2 Edit Date: February 12, 2013
Chapter 7
7.2 Overview
In this lab you will familiarize yourself with the measurement system (or “Data Acquisition System”) that will
form the basis of all lab work this semester. To this end, you will program the 9s12-based Esduino board to
flash it’s onboard LED at a specific frequency. You will then measure the duration of these pulses and calculate
the average and standard deviation of these measurements. The Esduino is shown in Fig. 7.1.
Prior to underaking the above, you will go over the semester’s lab schedule. A discussion of lab safety will
be held. You will also be given an overview of the equipment in the lab. The lab kit, that you should have
purchased with your partner earlier, will be discussed from a general perspective.
The main design goals and suggested methodologies will then be introduced. A review of reporting re-
quirements (IEEE standard format, issues related to plagiarism in report writing, as well as coding) will be
undertaken.
7-1
7.3 Background Information
You are expected to become familiar with lab safety, the design goals, the components and equipment which
you will be using over the course of the semester. This first lab is designed to help with this.
In terms of lab safety, there are chemical, electrical and physical hazards. Some are discussed in introductory
part of this manual. Given that you will sometimes work outside of standard lab hours, and therefore be
unsupervised, it is important that you take responsibility for being pro-active with safety.
The Esduino board, as explained earlier in a previous chapter, is based on the AVR-based Arduino system.
However, because the 9s12 is different than the AVR Atmega, it is important to have a clear understanding of
what functionality is offered on each of the headers of the Esduino. In terms of the input/output assignment of
pins on the Esduino board you need to become familiar with the various “ports” on the 9s12 chip. Many of the
Port T and Port M pins are made available on the “north” end of the Esduino, as shown in Fig. 7.2. Port T is
most often used for digital devices that have particular timing characteristics (like flashing LEDs at particular
frequencies, or measuring the time between a user pressing a switch). Many of the Port T pins are found on
headers J1 and J3 of the Esduino. Port AN is the analogue input port; most of its pins can be found on header
J2 (with Analogue reference on J7 and J3) on the “south” end of the board.
Codewarrior (originally a Canadian product!) is offered for free by Freescale. It is suitable for both Assembly
and C programming of the 9s12 Esduino board. You used it to program an HCS12 microcontroller board in
the Assembly language. In ELE 604 you will do most of your work in C, with some Assembler in certain places.
Codewarrior has components that permit the “host” Windows computer to connect to the “target” Esduino in a
number of ways, including through a USB cable. When using the USB cable, Codewarrior will communicate to
the Esduino via a small program that resides at the end of Flash EEPROM memory called the “Serial Monitor”
[16]. You can access this mode via the “debug” button in Codewarrior1 .
5. Make sure that your Esduino is working by having it flash its LED
6. Measure pulse period of Esduino LED (including average and standard deviation)
1. Established preliminary plan of microcontroller pin allocation on J1, J2, J3, J4 headers on the Esduino.
(a) Hand-in your wiring plan to the TA in the first 30 minutes of the lab. Make sure your name is on
the paper.
1
The debug button looks like a bug on top of a green triangle
PAD07
PAD06
to/from Host
DIG1
DIG0
[JB8] PS/PM SELECT:
PM5
PM2
PT3
PT7
PT6
PT2
PT1
PT0
Select between PS0/PS1
J14 US JB4
[J9][J10]: [Xbee Option]
GND J3 and PM0/PM1 assignments
SX UX
+5V
UX SX
for DIG0 and DIG1 pins
AREF
D2
GND
D9P
D13
D12
D10
>
<
D11
Plug ADXB here for XBee Interface
J1
D8
D7
D4
PWM D6
PWM D5
1 PWM D3
DTR U4
PM3
PT4 M
(3V/5V compatible).
S
<TX US J6
SPI
D2 JB2 DIG11 [J11] BDM IN:
J15 C17
GND PM4 PT5 Standard 6-pin Background
JB8
DI
[J6]: SPI peripheral connector RX >
BDM IN
ADXB
SPI signals, Output Enable, +5V, J10 +5
Esduino JB3 Debug Mode connector for
PP5
and Ground are all brought out to
SCK JB1
www.TechnologicalArts.com advanced debugging use
SS* R5 J11 LOAD
this convenient connector for easy OE*
VIN
J5
C6
JB6 SW1 [SW1 and JB6]:
interfacing to SPI peripherals DO
USB
C5 MAN
G
PB4 R1
C7
When JB6 set to MAN, use SW1 to
[JB1]: 5V Source Selector PWR PE7
AUTO select Serial Monitor mode.
C10 RUN
1-2 (lower): 5V from USB PE4
D3
Y1
U1
When JB6 set to AUTO, Serial
PA0
2-3 (upper): 5V from U1 via VIN R6 D1
C1 C11
R3
J8 PM0 Monitor mode must be controlled
by host via DTR line on serial port.
+
J9 Y2 JB5 PM1
[D1]: Power indicator LED 3V 5V J7 AN7
J12 R2
C16 VDD VRH AR
AN6
[J7] PB4, PE7,PE4,PA0: C15 C14 JB7
[J8] PM0 - PM1:
RESET
U3 C9
GND
GND
Four bonus Digital pins.
AN0
AN1
AN2
AN3
AN4
AN5
VIN
+
3V3 5V Two bonus Digital pins;
J2
SW2
J4
REV. 1 J13 may be used with an external
[U3]: 3.3V regulator (800 mA max.) transceiver to implement a
PAD00
PAD01
PAD02
PAD05
PAD03
PAD04
CAN interface.
[J7] AN6 - AN7:
[SW2]: Reset button [JB5]: 3V/5V Operation [J2] AN0 - AN1: Two bonus Analog Inputs;
1-2 (left): 3.3V Six Analog Inputs;
Power Configurations: may be used as digital
2-3 (right): 5V Any of these may be
Instead of deriving 5V to power the board from the USB Host inputs or outputs instead
connection, it can be derived from on-board regulator U1. used as digital inputs
Two different power connections are provided: J12 and J13. or outputs instead
The 2-pin J13 Molex connector is the default, while J12 is an
Order Codes:
optional barrel jack connector (2.1mm center-positive) ESD12C32 (with 9S12C32; surface-mount devices only)
compatible with most common AC-to-DC adapters. If J12 is ESD12C128 (with 9S12C128; surface-mount devices only)
present, and a voltage supply is plugged in, it will ESD12C32-KIT (ESD12C32 plus kit of through-hole parts)
automatically override J13. The applied voltage (VIN) can be ESD12C128-KIT (ESD12C128 plus kit of through-hole parts)
anywhere in the range of 7 to 15V DC. To choose VIN as ESD12C32-UR (fully assembled with 9S12C32, USB2MCU and connectors)
the source of system 5V (via regulator U1), set jumper block ESD12C128-UR (fully assembled with 9S12C128, USB2MCU and connectors)
JB1 to the 2-3 (upper) position. * Footprint and pinout are compatible with
standard Arduino-style shields; Arduino
www.TechnologicalArts.com software environment support pending. JANUARY 2011
Figure 7.2: The Esduino functionality is displayed here. The layout of the Rev 1 board is courtesy of Techno-
logical Arts.
1. Switches
2. an LCD (a display)
5. LEDs (lights)
Go over the Esduino and Freescale documentation and create a list of pins on the different ports (Port T,
Port M, Port A, etc.). Some of this information is found in Ch. 3, some in the Appendix, some in the MC9S12C
Family Reference Manual, as well as in other sources. It is your task to explore in order to find the answer(s)2 .
Accelerometer 2 pulse-width modulated outputs from MEMSIC 2125 to two digital inputs on 9s12
LCD Serial Peripheral Interface to the LCD requires SCK, MOSI and OE*.
Listing 7.1: This code will permit the LED on the Esduino board to flash at a fixed frequency
/∗ =======================================================================
∗ B a s i c LED t i m i n g / d e l a y c o d e
∗
∗ b y James Andrew Smith ,
∗ Input : Nothing
∗ O u t p u t : F l a s h i n g LED
∗
∗ PROGRAM SUMMARY: t h i s c o d e i s d e s i g n e d t o f l a s h t h e LED c o n n e c t e d t o t h e
∗ D13 p i n o f t h e E s d u i n o b o a r d . The D13 p i n c o r r e s p o n d s
∗ t o Pin 5 o f P o r t M on t h e 9 s 1 2 c 3 2 c h i p . The TCNT t i m e r
∗ i s used to provide the timing f o r the f l a s h i n g of the
∗ LED .
∗
∗ Test 1:
∗ T e s t e d on Rev 1 E s d u i n o on Oct . 2 0 , 2 0 1 1 w i t h a P&E BDM c a b l e on a . . .
∗ Mac−b a s e d P a r a l l e l s v i r t u a l m a c h i n e r u n n i n g Windows XP . ( James S m i t h )
∗ 1 . F i l e : C: \ Documents and S e t t i n g s \ A d m i n i s t r a t o r \ . . .
∗ My Documents \ P r o j e c t 2 4
∗ 2 . V i r t u a l Machine : / U s e r s / j a s m i t h / Documents / P a r a l l e l s / . . .
∗ Windows XP − M a t l a b & 9 s 1 2 . pvm
∗
∗ Test 2:
∗ M o d i f i e d and t e s t e d on Dec 2 , 2 0 1 1 t o r u n o f f s e r i a l m o n i t o r ( a s s u m i n g 25MHz
∗ i n t e r n a l c l o c k ) , u s i n g t h e same s e t u p b u t w i t h o u t t h e BDM.
2
Like any good design, there are multiple approaches. There is no single answer.
J3 J1
RX
TX
D9P
D13
D12
D10
D8
D7
D6
D5
D4
D3
D2
D11
GND
AREF
Figure 7.3: What function will be assigned to which pins on the Esduino? Hint: most will be on J1, J2, J3, J4.
The analogue pins are not listed here, but you will need to include them, too.
∗
∗
∗
∗ M o d i f i e d and t e s t e d on Dec 1 , 2 0 1 1 t o r u n o f f s e r i a l m o n i t o r ( a s s u m i n g 25MHz
∗ i n t e r n a l c l o c k ) , u s i n g t h e same s e t u p b u t w i t h o u t t h e BDM.
∗
∗ S o u r c e s : 1 . b a s e d on c o d e b y F r e d Cady ( f r o m Academic F r e e s c a l e w e b s i t e )
∗ 2 . a s s e m b l e r c o d e b y Ron Wong
∗ 3 . c o d e b y V a l v a n o ( h t t p : / / www . e c e . u t e x a s . e d u /˜ v a l v a n o / S t a r t e r f i l e s / )
∗ 4 . Pg 450 i n MC9s12C manual ( Rev01 . 2 3 )
∗
∗ C a v e a t s : You w i l l b e u s i n g t h e s e r i a l m o n i t o r ( n o t a BDM c a b l e ) t o p r o g r a m
∗ your Esduino board . Keep t h i s i n mind a s t h e s e r i a l m o n i t o r may
∗ e n g a g e t h e PLL ( P h a s e L o c k e d Loop ) and d r i v e t h e b u s c l o c k o f t h e
∗ 9 s 1 2 f a s t e r ( o r s l o w e r ) t h a n was t e s t e d h e r e .
∗
∗ ======================================================================= ∗/
// PRAGMA STATEMENTS
#pragma LINK INFO DERIVATIVE ” mc9s12c32 ”
// DEFINE STATEMENTS
#d e f i n e DELAY 500 // assume 1ms ” u n i t s ” o f d e l a y . 500=500ms
#d e f i n e ONE MILLISEC FOR TSCR2 1US 1000 // Timer : 1 0 0 0 x 1 m i c r o s e c = 1 m i l l i s e c
#d e f i n e ONE MILLISEC FOR TSCR2 333NS 3000 // Timer : 3 0 0 0 x 333 n a n o s e c= ˜1 m i l l i s e c
// INITIALIZATION CALLS
void p o r t m i n i t ( void ) ; // I n i t . P o r t M’ s PM5 f o r LED f l a s h i n g
void Timer mwait ( unsigned short msec ) ; // Timer w i l l w a i t i n 1 ms i n c r e m e n t s
void T i m e r I n i t ( void ) ; // I n i t i a l i s e t h e Timer .
/∗ − − − − − − − − − − − − − − − − − − − −
∗ MAIN FUNCTION
∗ − − − − − − − − − − − − − − − − − − − − − ∗/
/∗ I n i t i a l i s e any interrupts ∗/
EnableInterrupts ;
/∗ I n i t i a l i s e t h e Timer ∗/
Timer Init ( ) ;
/∗ DO ∗/
} /∗ w a i t f o r e v e r ∗/
/∗ −−−−−−−−−−−−−−−−−−−−T i m e r I n i t −−−−−−−−−−−−−−−
∗ i n i t i a l i z e t i m e r m o d u l e t o 1 u s ( Run Mode ) TCNT c l o c k
∗
∗ O t h e r w i s e t o 1280 ns i f u s i n g S e r i a l Monitor .
∗
∗ i n p u t s : none
∗ o u t p u t s : none
∗
∗ I f ” b u s c l o c k ” i s 8MHz , t h e n TSCR2=0 x 0 3 ( d i v i d e b y 8 )
∗ I f ” b u s c l o c k ” c l o c k i s 4MHz , t h e n TSCR2=0 x 0 2 ( d i v i d e b y 4 )
∗ R e f e r e n c e : p g 450 o f t h e MC9s12C f a m i l y manual ( r e v 0 1 . 2 3 )
∗
∗ N o t e : The E s d u i n o c r y s t a l i s 8 MHz , b u t t h e b u s c l o c k ( i n t e r n a l , ’E C l o c k ’ )
∗ i s n o t 8 Mhz b y d e f a u l t . You n e e d t o c h a n g e t h e p h a s e −l o c k e d l o o p ( PLL ) t o
∗ modify t h i s .
∗
∗ By d e f a u l t t h e E s d u i n o a p p e a r s h a v e a 4MHz b u s c l o c k ( when programmed w i t h BDM) .
∗ I n s e r i a l m o n i t o r mode i t ’ s 24 Mhz . So s e t TSCR2 a s c l o s e a s p o s s i b l e t o
∗ 1 us ( 1 . 2 8 us ) .
∗
∗ Bottom t h r e e b i t s o f TSCR2 ( PR2 , PR1 , PR0 ) d e t e r m i n e TCNT p e r i o d
∗ divide 8MHz i n t e r n a l b u s c l o c k
∗ 000 1 125 n s
∗ 001 2 250 n s
∗ 010 4 500 n s
∗ 011 8 1 us
∗ 100 16 2 us
∗ 101 32 4 us
∗ 110 64 8 us
∗ 111 128 16 u s
∗
∗ f o r a 4MHz i n t e r n a l b u s c l o c k ( E s d u i n o programmed w i t h a BDM o r i n Run mode )
∗ 000 1 250 n s
∗ 001 2 500 n s
∗ 010 4 1000 ns
∗ 011 8 2 us
∗ 100 16 4 us
∗ 101 32 8 us
∗ 110 64 16 u s
∗ 111 128 32 u s
∗
∗ f o r a 16 MHz i n t e r n a l b u s c l o c k ( Need t o a d j u s t PLL f o r t h i s )
∗ 000 1 xxxns
∗ 001 2 125 n s
∗ 010 4 250 n s
∗ 011 8 500 n s
∗ 100 16 1 us
∗ 101 32 2 us
∗ 110 64 4 us
∗ 111 128 8 us
∗
∗ f o r a 24 MHz i n t e r n a l b u s c l o c k ( E s d u i n o w i t h S e r i a l M o n i t o r i n Load mode )
∗ 000 1 4 1 . 6 7 ns 0.04167 us
∗ 001 2 8 3 . 3 3 ns 0.08333 us
∗ 010 4 1 6 6 . 6 7 ns 0.16667 us
∗ 011 8 3 3 3 . 3 3 ns 0.33333 us
∗ 100 16 6 6 6 . 6 7 ns 0.66667 us
∗ 101 32 1 3 3 3 . 3 3 ns 1.33333 us
∗ 110 64 2 6 6 6 . 6 7 ns 2.66667 us
∗ 111 128 5 3 3 3 . 3 3 ns 5.33333 us
∗
∗ R e f e r t o Pg 450 i n MC9s12C manual ( Rev01 . 2 3 )
∗ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− ∗/
void T i m e r I n i t ( void ) {
TSCR1 = 0 x80 ; // E n a b l e TCNT;
TSCR2 = 0 x03 ; // d i v i d e b y TCNT p r e s c a l e f o r E s d u i n o . TCNT a t 0 . 3 3 3 u s
PACTL = 0 ; // t i m e r p r e s c a l e u s e d f o r TCNT
//−−−−−−−−−−−−−−−−−−−−−T i m e r m w a i t−−−−−−−−−−−−−−−−−−−−−
// w a i t s p e c i f i e d number o f msec
// I n p u t : number o f msec t o w a i t
// O u t p u t : none
// a s s u m e s TCNT t i m e r i s r u n n i n g a t 1 u s
void Timer mwait ( unsigned short msec ) {
unsigned short s t a r t T i m e ;
f o r ( ; msec >0; msec−−){
s t a r t T i m e = TCNT;
// w h i l e ( (TCNT−s t a r t T i m e ) <= ONE MILLISEC FOR TSCR2 1US ) { }
while ( (TCNT−s t a r t T i m e ) <= ONE MILLISEC FOR TSCR2 333NS ) { }
/∗ − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − −
∗ F u n c t i o n : ” p o r t m i n i t ( ) ” : I n i t i a l i s e P o r t M f o r LED u s a g e
∗ − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − ∗/
void p o r t m i n i t ( void )
{
/∗ P o r t M i s s e t up t o f l a s h t h e E s d u i n o ’ s b u i l t −i n LED∗/
asm{
MOVB #32 ,DDRM
CLR PTM
}
}
7.7 Resources
1. The IEEE-style template for report writing: http://www.ee.ryerson.ca/~jasmith/courses/ele604/
docs/IEEE_trans_template_ELE604.doc
4. The Technological Arts website, http://www.technologicalarts.com/, (Tech. Arts makes the Esduino)
(a) Look under the HCS12C category as well as Course Material − > HCS12C
(b) The Microcontroller - General Principles by Fred Cady (search for “LABS12CINTRO01S.doc”)
(c) General Principals - Software Development by Fred Cady (search for “LABS12CINTRO02S.doc”)
(d) Exploring Embedded C Programming by Fred Cady (search for “LABS12CINTRO06.doc”)
(e) Serial Monitor Program for HCS12 MCUs by Jim Williams, Application Note AN2548/D [16]
(f) MC9S12C Family / MC9S12GC Family Reference Manual, #MC9S12C128 Rev 01.23 05/2007 by
Freescale Semiconductor (available as a free download online)
6. The website for the AVR-based Arduino project, http://www.arduino.cc/ (this is related to the Es-
duino).
7.8 Exploration
7.8.1 Lab Safety
Mr. Jim Koch will provide you with an overview of lab safety and etiquette. He will identify a number of safety
hazards in the lab, as well as ways that you can mitigate risk with respect to these hazards. Feel free to ask
questions of Mr. Koch, the TA or the course instructor with respect to lab safety. If you see equipment or items
that you are unfamiliar with but which you may feel pose a hazard, feel free to enquire as to their nature.
Inline Assembly
The Port M initialisation function is written using “inline assembly”, similar to the coding that you did in
COE 538. In many cases, writing your code in assembly will make it more efficient. By combining an overall
structure in C with specific function written in assembler you can achieve a good compromise between readability
/ maintainability and processing time.
2. Why are labels on the headers not the same as the 9s12 pin numbers? For instance, why is the 8th pin on
J1 labelled D7 and not PT6 on the Esduino circuit board? Hint: what AVR-based board is the Esduino
derived from?
3. Why is DELAY defined as 500 in the LED blinking code in Listing 7.1 when we want the LED to flash
once per 1000 ms?
4. What would you need to do to set the bus clock of the 9s12 to a different frequency?
5. What is the average period of the flashing LED? What is the standard deviation? Provide a screenshot
of the oscilloscope calculation or a copy of your Excel/Matlab work.
7.10 Communication
Work with your partner to
1. Hand-in your wiring plan to the TA in the first 30 minutes of the lab. Make sure your name is on the
paper.
In reporting to the TA, you will be required to provide preliminary answers prior to leaving the lab. You will
then email a PDF report to the TA with formal evidence that you were able to achieve the above items. The
PDF does not need to be long (one to two pages is sufficient) but must adhere to IEEE reporting standards.
Write your
name in the Using the IEEE Template
“header” Write
here Student ID
Title is 24 pt Times New Roman TNR font
in the
header
A subtitle which narrows the Here
scope of your project is good!
Student ID
Introduce your topic here. Put and Full
your “Thesis statement” here. Name here.
Your grade:
In the left column, your citations, language and content are evaluated. The marking is based on how well you
perform in each of those items. The individual scores are added up and written in the box below the column.
Afterwards, deductions are is made based on the factors in the right hand column. The deductions are
cumulative and can reduce your grade to 0 (minimum).
** Note: Use the IEEE Template Word document for ELE604! **
** Don’t change the template! **
** Go to www.ee.ryerson.ca/~jasmith/courses/ele604/support_docs for the template **
Page Number Mark Adjustment
- Based on length requirement. If you submit only about 75% of the number of pages you were
supposed to, your mark will be reduced by 25%.
- If you submit less than 75% of a complete page it is considered an incomplete page and is not
considered in your total page count.
- If a disproportionate amount of your article is taken up by tables, figures or quotations from other sources
your mark will be reduced accordingly. Be reasonable with your usage of figures, photos, images, diagrams,
tables and quotations. (For instance, if three-quarters of a page is taken up by a table or figures, leaving little
room for your own text, then the Page Number Adjustment will apply)
- Examples:
1) Hand in a two page project that was supposed to be four pages: your project mark will drop by
50 points.
2) Hand in a 3.5 page project instead of four pages: your project mark will drop by 25 points.
3) Hand in a four page paper, but one complete page is a table from another source, your project
mark will drop by 25 points.
8.2 Overview
You’ll recreate the heartbeat code from the previous lab prior to conducting work on the serial port. You’ll
then set up a pair of counters whose value will later be transmitted to the PC via serial communication. After
a set time you’ll flash a “finished” signal on the Esduino’s LED. These steps are essential to help debug further
operations on your microcontroller. Then, you will write a program for the Esduino which outputs a stream of
data to be read by the PC on your lab bench. You’ll need to translate integer values into ASCII characters.
Finally, transcribe a Matlab program on the PC to read the data stream and to display it in a graph, as shown
in Fig. 8.1.
8-1
Figure 8.1: This is an Esduino board transmitting data to a Linux PC running Matlab. Note the USB cable in
the bottom-left and Matlab figure in the upper-right corners.
Esduino and for reporting data from the program you’ll write? The answer lies in the 9s12c32’s “Run” and
“Load” modes, as per JB6 seen in Fig. 7.2 on page 7-3. When you move the jumper on JB6 from “Auto”
(Automatic) to “Man” (Manual), you’ll be able to tell the 9s12c32 that you wish to operate with the Serial
Monitor on (“Load” on SW1) or off (“Run”). When in “Run” mode, the code your wrote will execute and
will permit you to stream serial data to the PC but you won’t be able to use the Serial Monitor to examine or
debug it – you’ll have to rely on LEDs and other external debugging tools. This is why the heartbeat LED is
so important.
Please note that when the Serial Monitor is running, the internal clock of the 9s12c32 will be at 24 MHz.
When you operate in “Run” mode, it will operate at 4 MHz. The reason is that the Phase Locked Loop (PLL)
module is engaged by the Serial Monitor to increase the frequency, but the PLL must be explictly called in your
own code in order to get it above 4MHz.
The internal clock of the 9s12c32 is important for many reasons, including:
• It affects the TIM timer module and, hence, code that relies on TCNT, for instance.
Eclk
BR = (8.1)
16 ∗ [SCIBDH SCIBDL]
where BR is the Baud rate, Eclk is the internal clock frequency in Hz and [SCIBDH SCIBDL] is he 16-bit
value of these two registers, converted to Decimal from Hex or Binary. What would SCIBDH and SCIBDL
need to be if BR was 19200 baud and the Eclk was 4 MHz? You’ll need to know this for your lab.
You will need to get software on the PC to recognize and decode the serial data from your microcontroller.
Matlab is the main application that we will focus on. Matlab contains routines for speaking to serial devices2
such as the Esduino The Matlab serial routines are discussed here:
• For advanced examples, refer to Matlab Instrument Control Toolbox here: http://www.mathworks.com/
products/instrument/hardware/serial.html
Prior to testing your code in Matlab, you will want to verify that your microcontroller is sending serial
data correctly. This is usually done using a dedicated terminal program, such as RealTerm (on Windows) or
minicom (on Linux). When using the Linux machines in the ELCE Department, the Esduino will be detected at
“/dev/ttyUSB0” (that’s a zero at the end). So replace references to “COM8” or other Windows Communications
Ports with the Linux device name.
RealTerm (http://realterm.sourceforge.net/) is a very capable serial terminal program for Windows.
It’s much better than HyperTerm, and it’s free! Use it to test out the serial output from your Esduino first.
An example screenshot for RealTerm is found in Fig. 8.2.
Once you’ve established that serial communication is occuring in RealTerm or minicom, you’ll want to
implement the following commands in Matlab (change “COM8” for “/dev/ttyUSB0” if you are on a Linux
machine in the Department):
>> a=serial(’COM8’); % Use Device Manager (Windows) to verify this port. Assign to ‘a’
>> set(a,’BaudRate’,19200); % Set the speed to match the code running on Esduino.
>> fopen(a); % Open the ‘‘file’’ for ‘a’.
>> a % Report what is going on with this ‘file’
Communication Settings
Port: COM8
BaudRate: 19200
Terminator: ’LF’
Communication State
Status: open
RecordStatus: off
Read/Write State
TransferStatus: idle
BytesAvailable: 10
ValuesReceived: 40
ValuesSent: 0
2
The serial routines in Matlab permit you to connect very complex instruments, like oscilloscopes, power supplies, etc.! This
would be really useful for automated testing systems in industry.
>> out=fscanf(a); % Wait for serial data to arrive. (waits for a Carriage Return?).
>> fclose(a) % close the ‘a’ file
>> delete(a) % delete the ‘a’ file
>> clear a % clear the variable, too.
>> out % What did Matlab capture on the serial port? It’s stored in ‘out’
out =
This is whatever the Esduino is spitting out via the SCI module onto the serial port of the PC
• Develop familiarity with the Serial Communication Interface (SCI) of the 9s12c32
• Understand how to enable Matlab to read raw ASCII character data from a serial port
• Develop an understanding for the sequence of verifiable steps that are recommended for establishing
communication between a microcontroller and a remote display terminal (PC)
• understand how to switch the 9s12c32’s memory-resident serial monitor off in order to run a program that
utilises the SCI.
• Display a graph in Matlab representing all of the time and data values streamed from the Esduino to your
TA. Include a labelled version in your report.
• Screenshot of your datastream in RealTerm or equivalent terminal program, included in your report
• A flashing LED “heartbeat” demonstrated to the TA, at the frequency specified in Section 8.7.1
• Summarize your results in a short, IEEE-style report, as per the instructions in the Communication
section
Review the SCI (Serial Communication Interface) registers for the 9s12c32, as per the manual. What registers
need to be adjusted to change the transmission rate? How is it affected by the 9s12c32’s internal bus
clock?
8.7 Exploration
The following are the tasks that youa re to undertake in this lab session.
Test and demonstrate to your TA. Have TA record your successful completion of this portion of the lab.
• Download your code using the Serial Monitor. Do not run it.
• Make sure Jumper JB6 is set to “Man”, and not to “Auto”. (see Fig. 7.2 on page 7-3)
• Plug in power to Esduino. Press reset (SW2 of Fig. 7.2 on page 7-3)
Does the LED still flash? If not, check JB6 and SW1. Is it running at the right frequency? Remember the
internal clock has been reduced to 4MHz! Still no serial data? Unplug the serial line and recheck your code
with only LED/Timing intact.
If the LED was working fine, configure RealTerm for 19200 baud, Stop/Start bits, No parity, hardware flow
control off. Select the right serial port, too (typically 3 or 5). Click “Open” and “Change” as shown in Fig. 8.2
on page 8-4. Then reset Esduino and check for characters in RealTerm.
Test and demonstrate to your TA. Have TA record your successful completion of this portion of the lab.
2. What is the difference in function between the Serial Monitor and a Background Debugger Module (BDM)?
Answer in less than 30 words.
3. Draw a block diagram which shows the flow of information between the PC and the 9s12c32 chip on your
Esduino. To be included are: PC, Esduino Board, 9s12c32, SCI module, USB2MCU, USB cable, USB
port, Matlab.
• Section 1: determine and implement a method for running the serial interface between the Esduino and
Matlab at a baud rate above 19200 baud. (10% bonus to this week’s grade)
• Section 2: Plot individual data points on a Matlab graph immediately as they arrive via the serial
communication routines. No significant lag should be perceivable by the TA. (10% bonus to this week’s
grade)
• Sections 3 and 4: Demonstrate reception of serial data by the microcontrolller from the PC by flashing
the Esduino’s LED a fixed number of times: five times for the ASCII ’A’ character and ten times for the
ASCII ’B’ character. (10% bonus to this week’s grade)
In each case you must demonstrate the functionality to the TA during the lab and you must include a copy
of your source code in your report.
8.10 Communication
Work with your partner to
1. Demonstrate all of the demonstratable items to the TA prior to the end of the lab
• Title
• Author list (with names and student IDs) below the title
– What is the lab about? Don’t just copy the lab description (that’s plagiarism!). Write it in your
own words.
– Reference books, tech manuals, etc. that are useful for your lab.
– Each paragraph should describe a different component of the lab that you undertook.
– What hardware and software was used in each section. What did you do with them?
– Give “hard” numbers here as part of your results. Graphed results should be here, too.
– As part of the discussion, ask yourself what the results tell you about the operation of your Esduino
board as a Data Acquisition System. Was the gathering of one piece of data particularly hard? If so,
describe that and how it relates to the values your got – reference your data and the figures by saying
“as seen in Figure XX and Table YY.” Look at the “Post-Lab Reflection” in the lab description.
Does it give you ideas for further discussion?
• Skill Questions
– include a copy of your source code. Submit the text file separate from your document.
A marking guide / rubric is found at the end of this chapter. Use it as a guideline for fulfilling the
requirements for the document that you are to submit to the TA.
Your grade:
In the left column, your citations, language and content are evaluated. The marking is based on how well you
perform in each of those items. The individual scores are added up and written in the box below the column.
Afterwards, deductions are is made based on the factors in the right hand column. The deductions are
cumulative and can reduce your grade to 0 (minimum).
** Note: Use the IEEE Template Word document for ELE604! **
** Don’t change the template! **
** Go to www.ee.ryerson.ca/~jasmith/courses/ele604/support_docs for the template **
Page Number Mark Adjustment
- Based on length requirement. If you submit only about 75% of the number of pages you were
supposed to, your mark will be reduced by 25%.
- If you submit less than 75% of a complete page it is considered an incomplete page and is not
considered in your total page count.
- If a disproportionate amount of your article is taken up by tables, figures or quotations from other sources
your mark will be reduced accordingly. Be reasonable with your usage of figures, photos, images, diagrams,
tables and quotations. (For instance, if three-quarters of a page is taken up by a table or figures, leaving little
room for your own text, then the Page Number Adjustment will apply)
- Examples:
1) Hand in a two page project that was supposed to be four pages: your project mark will drop by
50 points.
2) Hand in a 3.5 page project instead of four pages: your project mark will drop by 25 points.
3) Hand in a four page paper, but one complete page is a table from another source, your project
mark will drop by 25 points.
9.2 Overview
Last week, you demonstrated how to send data from your microntroller to a PC for display. This week, you
will build the LCD board (as shown in Fig. 9.1) and test it using the code provided. The Esduino is hardware
compatible with the very popular Arduino platform. This experience will enable you to more easily explore
other Arduino-compatible application boards in your future endeavours.1
9-1
Esduino doesn’t have enough free pins to support both a parallel LCD display and all the other devices that
we need to connect to it!
uC board design The functionality described in Fig 7.2. What is the difference between Port T and Port AN
pins? How is the USB connection used?
Review LCD specifications They are found at http://www.lcd-module.com/eng/pdf/doma/dog-me.pdf
and in Appendix F.
Review SPI specifications on Esduino What does SPI stand for? What is the difference between MISO
and MOSI? What voltage levels are used on the 9s12’s SPI port? Which headers on the Esduino contain
SPI pins?
Below you will find snippets of source code that need to be incorporated into your lab project. The code
snippets don’t include any information on how to call these functions, nor how they should be inserted into
your main function. The timer setup function is not included, either. That is up to you to determine!
// S e t t h e SPI c o n t r o l r e g i s t e r s
SPICR1=0x50 ; // SPI C o n t r o l R e g i s t e r 1 , b i t 7 : I n t e r r u p t Enable , b i t 4 : MSTR
SPICR2=0x00 ; // SPI C o n t r o l R e g i s t e r 2 , b i t [ 7 : 0 ] − Disabled
/∗ S e t t h e SPI b a u d r a t e r e g i s t e r
∗ For a Baud r a t e o f 375 kHz and an i n t e r n a l b u s c l o c k o f 24MHz
∗ we n e e d t o s e t t h e d i v i s o r t o 64 ( a s p e r t h e e q u a t i o n on
∗ MC9s12C−F a m i l y manual R . 0 1 . 2 3 , p g . 4 1 9 . )
∗/
SPIBR=0x05 ; // d i v i s o r i s 2 ˆ ( 0 x 0 5 + 1 ) = 6 4 . ; BR = 2 4 0 0 0 0 0 0 / 6 4 .
}
/∗ − − − − − − − − − − − − − − − − − − −− − − − − − − −
∗ Function : spi write lcd command ()
∗
∗ i n p u t : 8− b i t ( c h a r ) v a l u e
∗ o u t p u t : commands t o LCD ( m o s t l y u n s e e n b y u s e r )
∗
∗ M o d i f i e d f r o m C−v e r s i o n o f t h e SPI w r i t i n g c o d e :
∗ www . e e . nmt . e d u /˜ e r i v e s / 3 0 8 0 8 / L e c t u r e 2 3 . p d f
∗ Assume t h a t PT3 i s t h e s l a v e s e l e c t .
∗ − − − − − − − − − − − − − − − − − − −− − − − − − − − ∗/
void s p i w r i t e l c d c o m m a n d ( char d a t a o u t ) {
i n t tmp ;
/∗ − − − − − − − − − − − − − − − − − − −− − − − − − − −
∗ Function : s p i w r i t e l c d d a t a ()
∗
∗ i n p u t : 8− b i t ( c h a r ) v a l u e
∗ o u t p u t : s y m b o l s on t h e LCD .
∗
∗ M o d i f i e d f r o m C−v e r s i o n o f t h e SPI w r i t i n g c o d e :
∗ www . e e . nmt . e d u /˜ e r i v e s / 3 0 8 0 8 / L e c t u r e 2 3 . p d f
∗ Assume t h a t PT3 i s t h e s l a v e s e l e c t .
∗ − − − − − − − − − − − − − − − − − − −− − − − − − − − ∗/
void s p i w r i t e l c d d a t a ( char d a t a o u t ) {
i n t tmp ;
Listing 9.3: LCD Initialisation code which is designed for a two-line LCD. You may need to modify the first six
steps for a three-line LCD
/∗ − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − −
∗ F u n c t i o n : ” l c d i n i t ( ) ” : I n i t i a l i s e t h e LCD w i t h a c u r s o r on t h e s c r e e n
∗
∗ Code m o d i f i e d f r o m Ron Wong ’ s m a i n v 2 . asm (2011)
∗
∗ The s e q u e n c e i s b a s e d on ” Example o f i n i t i a l i s a t i o n : 8 b i t / 5V EA DOGM163”
∗ f o u n d on p a g e 7 on dog−me . p d f ( h t t p : / / www . l c d −m o d u l e . d e / e n g / p d f /doma/ dog−me . p d f )
∗ C−v e r s i o n o f t h e SPI w r i t i n g c o d e :
∗ www . e e . nmt . e d u /˜ e r i v e s / 3 0 8 0 8 / L e c t u r e 2 3 . p d f
∗
∗ 2 L i n e DOG D i s p l a y 1 6 2 , 5 v :
∗ 9 steps
∗ −−−−−−−−−−−−−−−−−−−−−−−−
∗ 1 . $39 ( Function s e t )
∗ 2 . $1C ( B i a s s e t )
∗ 3 . $ 5 2 ( Power C o n t r o l )
∗ 4 . $69 ( F o l l o w e r C o n t r o l )
∗ 5 . $74 ( C o n t r a s t Set )
∗ 6 . $38 ( Function Set )
∗ − − − − −
∗ 7 . $0F ( D i s p l a y On)
∗ 8 . $01 ( Clear D i s p l a y )
∗ 9 . $ 0 6 ( E n t r y Mode S e t )
∗
∗ James A . S m i t h ; Oct / Dec 2 0 1 1 .
∗ − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − ∗/
void l c d i n i t ( void ) {
/∗ S t e p s 1 − 6 n e e d t o b e c u s t o m i z e d f o r e a c h EA Dog d i s p l a y ∗/
/∗ S t e p 1 ∗/
Timer mwait ( 5 0 ) ; /∗ n e e d 40 msec + a f t e r power−up ∗/
s p i w r i t e l c d c o m m a n d ( 0 x31 ) ; //
/∗ S t e p 2 ∗/
Timer mwait ( 5 0 ) ; /∗ T h i s can b e 2 msec o r less ∗/
s p i w r i t e l c d c o m m a n d ( 0 x1C ) ; //
/∗ S t e p 3 ∗/
Timer mwait ( 5 0 ) ; /∗ T h i s can b e 2 msec o r less ∗/
s p i w r i t e l c d c o m m a n d ( 0 x51 ) ; //
/∗ S t e p 4 ∗/
Timer mwait ( 5 0 ) ; /∗ T h i s can b e 2 msec o r less ∗/
s p i w r i t e l c d c o m m a n d ( 0 x6A ) ; //
/∗ S t e p 5 ∗/
Timer mwait ( 2 0 0 ) ; /∗ T h i s must b e 200 msec o r more ∗/
s p i w r i t e l c d c o m m a n d ( 0 x74 ) ; //
/∗ S t e p 6 ∗/
Timer mwait ( 5 0 ) ; /∗ T h i s can b e 2 msec o r less ∗/
s p i w r i t e l c d c o m m a n d ( 0 x30 ) ; //
/∗ S t e p s 7 − 9 a r e common b e t w e e n a l l EA DOG d i s p l a y s ∗/
/∗ S t e p 7 ( D i s p l a y On) ∗/
Timer mwait ( 5 0 ) ; /∗ T h i s can b e 2 msec o r less ∗/
s p i w r i t e l c d c o m m a n d ( 0 x0F ) ;
/∗ S t e p 8 ( C l e a r D i s p l a y ) ∗/
Timer mwait ( 5 0 ) ; /∗ T h i s can b e 2 msec o r less ∗/
s p i w r i t e l c d c o m m a n d ( 0 x01 ) ;
/∗ S t e p 9 ( E n t r y Mode S e t ) ∗/
Timer mwait ( 2 0 0 ) ; /∗ T h i s can b e 2 msec o r less ? ? ? ? ? ∗/
s p i w r i t e l c d c o m m a n d ( 0 x06 ) ;
/∗ S t e p s 10+ a r e n o t r e q u i r e d ∗/
Timer mwait ( 2 ) ; // DEBUG
s p i w r i t e l c d c o m m a n d ( 0 x33 ) ; // DEBUG
/∗ − − − − − − − − − − − − − − − − − − −− − − − − − − −
∗ Function : lcd go home ()
∗
∗ Sends t h e c u r s o r t o t h e upper r i g h t corner .
∗
∗ input : nothing .
∗ o u t p u t : p o s i t i o n s t h e c u r s o r a t ” home ”
∗ − − − − − − − − − − − − − − − − − − −− − − − − − − − ∗/
void l c d g o h o m e ( void ) {
Timer mwait ( 2 ) ; /∗ T h i s can b e 2 msec o r l e s s ∗/
s p i w r i t e l c d c o m m a n d ( 0 x02 ) ; /∗ command ∗/
}
(a) Look under the HCS12C category as well as Course Material − > HCS12C
(b) The Microcontroller - General Principles by Fred Cady (search for “LABS12CINTRO01S.doc”)
(c) General Principals - Software Development by Fred Cady (search for “LABS12CINTRO02S.doc”)
(d) Exploring Embedded C Programming by Fred Cady (search for “LABS12CINTRO06.doc”)
(e) Serial Monitor Program for HCS12 MCUs by Jim Williams, Application Note AN2548/D [16]
(f) MC9S12C Family / MC9S12GC Family Reference Manual, #MC9S12C128 Rev 01.23 05/2007 by
Freescale Semiconductor (available as a free download online)
5. The Technological Arts website, http://www.technologicalarts.com/, (Tech. Arts makes the Esduino)
6. The website for the AVR-based Arduino project, http://www.arduino.cc/ (this is related to the Es-
duino).
• What is meant by the Slave Select (or Output Enable) having a star beside it (or a bar above)?
• How many pins would be required to drive a parallel version of the EA DOG display?
• Section 1: Make the letter ‘A’ scroll back-and-forth on the first line of your LCD. (10% bonus to this
week’s grade)
• Section 2: Rewrite the spi_write_lcd_command() and lcd_init() commands in Assembler so that they
function as well as the C versons. (10% bonus to this week’s grade)
• Sections 3 and 4: Have the LCD display a character sent to the Esduino from Matlab or from a PC-based
terminal program. (10% bonus to this week’s grade)
In each case you must demonstrate the functionality to the TA during the lab and you must include a copy
of your source code in your report.
9.11 Communication
Work with your partner to
1. Demonstrate all of the demonstratable items to the TA prior to the end of the lab
In reporting to the TA, you will be required to provide preliminary answers prior to leaving the lab. You
will then email a PDF report to the TA with formal evidence that you were able to achieve the above items.
The report must be one-and-a-half to two pages in length and must adhere to IEEE reporting standards.
The email containing the report is due two days after your lab. It must be emailed to the TA by 11:59
pm on the second day after your lab.
Include the following sections in your lab report:
• Title
• Author list (with names and student IDs) below the title
– What is the lab about? Don’t just copy the lab description (that’s plagiarism!). Write it in your
own words.
– Reference books, tech manuals, etc. that are useful for your lab.
– Each paragraph should describe a different component of the lab that you undertook.
• Skill Questions
– include a copy of your source code. Submit the text file separate from your document.
A marking guide / rubric is found at the end of this chapter. Use it as a guideline for fulfilling the
requirements for the document that you are to submit to the TA.
Your grade:
In the left column, your citations, language and content are evaluated. The marking is based on how well you
perform in each of those items. The individual scores are added up and written in the box below the column.
Afterwards, deductions are is made based on the factors in the right hand column. The deductions are
cumulative and can reduce your grade to 0 (minimum).
** Note: Use the IEEE Template Word document for ELE604! **
** Don’t change the template! **
** Go to www.ee.ryerson.ca/~jasmith/courses/ele604/support_docs for the template **
Page Number Mark Adjustment
- Based on length requirement. If you submit only about 75% of the number of pages you were
supposed to, your mark will be reduced by 25%.
- If you submit less than 75% of a complete page it is considered an incomplete page and is not
considered in your total page count.
- If a disproportionate amount of your article is taken up by tables, figures or quotations from other sources
your mark will be reduced accordingly. Be reasonable with your usage of figures, photos, images, diagrams,
tables and quotations. (For instance, if three-quarters of a page is taken up by a table or figures, leaving little
room for your own text, then the Page Number Adjustment will apply)
- Examples:
1) Hand in a two page project that was supposed to be four pages: your project mark will drop by
50 points.
2) Hand in a 3.5 page project instead of four pages: your project mark will drop by 25 points.
3) Hand in a four page paper, but one complete page is a table from another source, your project
mark will drop by 25 points.
10.2 Overview
In this session you are to demonstrate to the TA a fully-functioning microcontroller, with LEDs and a switch.
You are to write and run a test program which demonstrates this. You are to submit a four page, IEEE format
report afterwards, for “Milestone 1”.
10-1
LEDs LCD PC (Matlab)
Esduino
amplifier
balancing cct
+/- 15v
Figure 10.1: Overview of the components in your system (including some you haven’t dealt with yet).
5v
D
Rc
Q1
b
Figure 10.2: Turning on an LED (D1 ) with a BJT (Q1 ). Two resistors limit current into either the base
or the collector of the BJT. The input signal is assumed to be a series of five-volt pulses coming from the
microcontroller.
(a) Do the pre-lab MapleSim tutorials and show to TA’s that they are done both MapleSim tutorials &
report on them.
(b) Undertake the Diode parameter sweep simulation in MapleSim
(c) Simulate a BJT-Driven LED to aid in design of your circuit
(d) Simulate a filter for debouncing a switch
(a) Create a design for a debounced circuit after testing in a multi-domain simulator (MapleSim)
(b) Implement three transistor-driven LEDs and one momentary switch on the LCD prototype board.
(c) Write and test code which is capable of reading the switch and lighting up the LEDs.
(d) Demonstration of functioning LEDs and switch to the TA
(e) Submit report
2. Undertake the sinusoid MapleSim tutorial in the Appendix. Hand in printouts at beginning of Week 5
lab.
10.7 Exploration
There are a number of exercises to accomplish during the labs. The simulations should be done in the first
week. The circuit implementations and programming should be done in the second week.
2. What is the value of the resistor, Rb , required which does not exceed the maximum current rating of the
9s12 digital pins but will also provide sufficient current through the collector-emitter to drive the LED.
Assume that βf ranges from 80 to 100. Assume VBE to be 0.7 v when driven on.
Once you have determined these values, implement them in simulation to confirm. Use MapleSim, Spice,
Multisim or any other appropriate simulation. Provide a screenshot of your simulation setup in your
Milestone 1 report.
1. 10 volt battery driving a resistor an an LED (an ideal diode with a knee voltage of 1.2 volts)
2. The resistor should have a Tref of 200 K, an α of 0.001 K −1 and no heat port.
3. The resistor should have two parameters: R should be ResistorV alue and T should be T emperatureV alue.
These will be varied in simulation. You will need to add these to the Parameters of the main simulation.
Do this by clicking the icon under the question mark, in the upper-left corner.
4. Set the diode to have a Vknee of 1.2 volts. Keep the other defaults.
5. Set simulation time, tf to 2 seconds, the ck45 solver, adaptive integration to true, keep the default error
tolerances, 200 plot points. Compiler is optional.
6. add a probe to measure current. You may need to add a sensor first.
7. add a probe to measure diode voltage. You may need to add a sensor first.
Imagine that your system will be exposed to a temperature other than room temperature. Conduct a
parameter search for resistances from 50 to 100 Ohms and temperatures from 250 to 400 K. First, run the
simulation directly from MapleSim, with one or two combinations of temperature and resistance. Check that
currents and voltages are about right.
Next have Maple call the MapleSim a single time, as shown in Fig 10.3. Check the output to see if voltage
and current are correct.
Next modify the supplied Maple code to call the MapleSim model multiple times, in order to sweep through
the temperature and resistance parameters. Determine the relationship between those two parameters and the
resulting current. You’ll first need to set up your parameters, like in Fig. 10.4, and then you’ll need to run a
double for loop to sweep through the parameter space, like in Fig. 10.5. Finally, you’ll plot the results, as in
Fig. 10.6.
Also, have MapleSim generate the underlying equations. Provide the equations specified as part of the Skill
Questions section.
• Sections 1 and 4: Using the Attach Equations feature in MapleSim, describe the voltage at the resistor
as a function of current. Refer to Ch. 3 of the Dunn text.
Figure 10.3: First, tell Maple where and which files to simulate. Then run the simulation specifying which
parameters to modify.
Figure 10.5: Vary each of the parameters and accumulate the resulting outputs from teh MapleSim simulation.
• Sections 2 and 3: Using the Attach Equations feature in MapleSim, describe current as a piecewise func-
tion. Refer to Example 1 of http://inst.eecs.berkeley.edu/~ee42/sp04/lectures/lecture16student.pdf
and page 42 of http://www.modprod.liu.se/MODPROD2011/1.252919/modprod2011-tutorial1-Fritzson-Modelica-Introduction.pdf for guidance. Note
that s is a variable that is dependant on both current and voltage.
Next, model the combined mechanical switch and electrical debounce filter. Modelling of this system
is tricky, since it is multi-domain (both mechanical and electrical). Traditional software such as Multisim
and Spice (electrical) or MSC.ADAMS and Working Model (mechanical) are single domain and cannot easily
accommodate systems such as this. MapleSim and Dymola use the Modelica modeling system to address this
problem.
To simulated a button press, have a 0.01 kg mass drop 1 mm onto an elasto-gap (spring-damper with a
zero-force gap) with a spring constant of 100000 N/m and a damping constant of 180 N/(m/s). The gap should
Spring
Ground
Gap
Damper
} Switch
be 1 mm. Gravity should be the standard value on Earth.1 Your model should appear something like that in
Fig. 10.8. Note that the filter is in a subsystem block, so the details are not shown.
In your Milestone report, provide a screen capture of both your MapleSim schematic / model
and a graph comparing the switch’s mechanical movement with the electrical output.
2. Provide the component equation for the LED simulation, as specified below
(a) Sections 1 and 4: Using the Attach Equations feature in MapleSim, describe the voltage at the
resistor as a function of current. Refer to Ch. 3 of the Dunn text.
(b) Sections 2 and 3: Using the Attach Equations feature in MapleSim, describe current as a piecewise
function. Refer to Example 1 of http://inst.eecs.berkeley.edu/~ee42/sp04/lectures/lecture16student.
pdf and page 42 of http://www.modprod.liu.se/MODPROD2011/1.252919/modprod2011-tutorial1-Fritzson-Mode
pdf for guidance. Note that s is a variable that is dependant on both current and voltage.
3. What is the maximum current that the 9s12 can sink or source on the digital pins?
4. How much current is drawn by the Esduino’s LED (on the D13 line)?
where Sj is the score of the j th group, and n groups have submitted bonus exercises. Bj is the code size, in
bytes, of the group’s executable code. The result is a percentage applied to the actual bonus score, found below.
• Section 1: Count the number of button presses on your switch and increment the count value on your
LCD (up to 10% bonus to this week’s grade)
• Section 2: Press a key in Matlab and have one of your new LEDs turn on. (up to 10% bonus to this
week’s grade)
• Section 3: Each time the button is pressed, have a number increment in Matlab (up to 10% bonus to this
week’s grade)
• Section 4: Have the LCD’s screen fill up with characters as long as the button is pressed. When you let
go of the button have the characters disappear slowly. (up to 10% bonus to this week’s grade)
In each case you must demonstrate the functionality to the TA during the lab and you must include a copy
of your source code in your report.
10.10 Communication
Begin preparation of the Milestone 1 documentation (four pages, IEEE format, with references). The Milestone
report is due one week after your lab at 11:59pm. You must email a PDF copy of the report to your TA
and it must include an official (signed) cover sheet. Note that you need to use the IEEE template (http:
//www.ee.ryerson.ca/~jasmith/courses/ele604/docs/IEEE_trans_template_ELE604.doc).
You are to document the simulations that you conducted in MapleSim and to discuss the result of the
implementation on your microcontroller system. Discuss why your analogue components were selected the way
they were. Also, what was the design decision that led to implementation of either poll-based or interrupt-based
servicing of the switch. Explain these design decisions.
In addition to following the IEEE format, the four-page documentation (minus appendices) must have the
following sections:
Cover Sheet This page includes:- the title of the report; authors’ names; for whom and when the report was
prepared; course name; and Statement of Declaration claiming ownership of the report content, signed by
both authors. This is the official FEAS cover sheet. (See the end of this chapter)
ABSTRACT an abstract is a short paragraph summarizing the report. One or two sentences for each of
the following items is appropriate: Objectives, Design Analysis, Procedure, Results, Conclusions and
Recommendations. Furthermore, write up your abstract first, before writing anything else. Use it to plan
your document. Note that the introduction and theory sections, as well as the skill questions should not
be mentioned here.An abstract can be thought of as an executive summary. The Corporate Executive or
your Engineering Manager may just want to read a short paragraph and to be able to put the report into
Example Abstract
This is my introductory sentence, in which I give context for my project. Objectives:
The objectives of this project were to simulate a 7kg spacecraft in the first week and to
construct and launch it in the second week. Design Analysis: To produce a launch vehicle
with the specified mass requirements, new accelerometer and rocket booster designs were
required. Procedure: MapleSim was used to simulate the flight path and incorporated the
accelerometer for feedback to drive the variable mass booster. The experimental flight test
was performed with the Esduino controller at the Ryerson launch pad located at Dundas
Square. Results: The launch vehicle crashed and burned after 7 seconds of flight, taking
out the GAP advertisement above the Eaton Centre. Conclusions & Recommenda-
tions: The control code was written in poorly optimized C that did not adhere to realtime
requirements resulting in poor flight control. A better control code, written in Assembly,
with an average control loop of 1ms ± 0.001ms is recommended next time.
Your grade:
In the left column, your citations, language and content are evaluated. The marking is based on how well you
perform in each of those items. The individual scores are added up and written in the box below the column.
Afterwards, deductions are is made based on the factors in the right hand column. The deductions are
cumulative and can reduce your grade to 0 (minimum).
Section No.
Group No.
Submission Date
Due Date
*By signing above you attest that you have contributed to this submission and confirm that
all work you have contributed to this submission is your own work. Any suspicion of
copying or plagiarism in this work will result in an investigation of Academic Misconduct
and may result in a “0” on the work, an “F” in the course, or possibly more severe
penalties, as well as a Disciplinary Notice on your academic record under the Student
Code of Academic Conduct, which can be found online at:
www.ryerson.ca/senate/current/pol60.pdf.
10-14 Edit Date: February 12, 2013
Chapter 11
11.2 Overview
This is a two-week lab. In weeks 8 and 9, you are to work on the analysis, design, and implementation of
accelerometer hardware and software. More specifically, analysis, design and implementation of accelerometer
hardware and software to display Angle as per specifications. Obtain test results. An in-person oral demon-
stration of the working device will be conducted with the TA up until Week 9. The report is due seven (7) days
after your Week 9 lab at 11:59 pm in PDF form, with signed cover page, emailed to your TA.
11-1
11.4 Exploration
Can you implement floating point mathematics on the 9s12? If so, what would the performance be, with respect
to a system like a laptop or desktop computer? What are alternatives to this that are common with embedded
systems such as the 9s12?1
1. Get Port T tested. Use simple polling and test for high and low values on the Port T pins that you will
use for the two Accelerometer outputs.
1
Hint: LUT
3. Set up a simple Interrupt Service Routine. Declaring it in your main.c file is a good idea. The recom-
mended start for the ISR (for Input Capture 2, in this case) should be something like: void interrupt 10
IC2Han(void). Note the “10”. This changes for different hardware devices or “channels”. Don’t forget
to clear the relevant flag in TFLG at the end of the ISR! Consider doing something simple in this ISR,
like flashing an LED. Note, that Codewarrior has a special command called EnableInterrupts(); that
needs to be called between the code that initialises interrupts and the main execution code in main().
4. Measure time between pulse edges in the ISR. This is tricky. Make sure to debug the previous steps first.
Here, you should use TCTLx_EDGy (where x and y can be different values) to test which edge was detected.
5. Add the second channel’s ISR. Make sure that both work separately, then together.
1. If the MEMSIC 2125 x-axis is used on the vertical, which way would you orient the device to ensure
positive values for ∆TX .
2. For the measurement of 0 degrees to 90 degrees in increments of 0.2 degrees using the xaxis output, there
would be 450 data points in a Look Up Table (LUT). If one measures the numerical value of ∆TX , then
it can be compared with an appropriate entry in the Table. Manually generate such a table for values of
∆TX in increments of 0.2 degrees.
3. Show how you would set up a second LUT that could use the “offset” (obtained after the comparison)
from the above LUT to directly reference the appropriate angle (e.g. 23.4 deg, etc.) for direct display on
the LCD.
4. Show that for the xaxis output, the ∆TX will be redundant for the two required quadrants, 0 deg. 90 deg.
and 90 deg. 180 deg. Determine how the same LUT above can then be used to also measure the angles
in the 90 deg. - 180 deg. quadrant by appropriately using the information from the yaxis output.
5. If the T2 period of 10 msec is not accurate (refer to the datasheets for information on accuracy and error),
then how would you improve your accuracy and repeatability of the angle measurements.
where Sj is the score of the j th group, and n groups have submitted bonus exercises. Bj is the code size, in
bytes, of the group’s executable code. The result is a percentage applied to the actual bonus score, found below.
• Section 1: Have Matlab graph the angular data from the Esduino and MEMSIC “live” so that points are
plotted in the graph as soon as they are received. (up to 10% bonus to this week’s grade)
• Section 2: Press a key in Matlab and have the Esduino’s display switch toggle between showing MEMSIC
angles in degrees and in radians (up to 10% bonus to this week’s grade)
• Section 3: Have the Esduino LCD display a bar graph whose bar is proportional to the angle of the
MEMSIC. It should update “live” as the MEMSIC rotates. The bar should also be able to distinguish
between clockwise and counterclockwise rotation. (up to 10% bonus to this week’s grade)
• Section 4: Mount the Accelerometer, LCD and Esduino in a protective box, with battery power. Drop it
from a height of 1 to 1.5 meters. Display the time of flight between the time it was dropped to the time
it impacted the ground.
In each case you must demonstrate the functionality to the TA during the lab and you must include a copy
of your source code in your report.
11.7 Communication
Please read the Marking Guide carefully prior to working on and submitting your work.
In Week 9 you will demonstrate your system to the teaching assistant (or before if you are ready). The TA
will ask you questions to determine your understanding of the system, as per the marking guide attached to
the end of this chapter. You will also be required to submit a four page (without appendix) written report as
part of Milestone 2, in IEEE format and as a PDF file, within seven days of your Week 9 session (emailed by
11:59pm of the seventh day, to the TA). Please use the section headings as outlined in the Marking Guide at
the end of this chapter.
In the left column, your citations, language and content are evaluated. The marking is based on how well you
perform in each of those items. The individual scores are added up and written in the box below the column.
Afterwards, deductions are is made based on the factors in the right hand column. The deductions are
cumulative and can reduce your grade to 0 (minimum).
12.2 Overview
In Week 10, implement and test analogue circuitry design for strain gauge and then interface to uC. Implement
software to provide force function per specifications. Undertake the measurements to characterize the strain-
gauge sensor and circuitry. Continue to work on integrating force and angle functions per specifications. In Week
11, demonstrate force measurement functions as per specifications and provide your measurement data analysis
on accuracy, repeatability, etc. of the sensor. Submit Milestone 3, test results, algorithms and source-code
listing.
12.5 Exploration
The circuit in Fig. 12.1 is suggested for interfacing the Futek load cell to your microcontroller. In Week 10 you
are to simulate it using MapleSim. In Week 11 you are to demonstrate a working circuit to your TA.
12-1
Figure 12.1: Suggested interface circuit to connect the Futek load cell to the ADC on your microcontroller
board. Image courtesy of Dr. Mike Kassam.
1. Build an instrumentation amplifier from three ideal op amps and a network of resistors, as per Fig. 7 in
http://www.intersil.com/data/an/an1298.pdf. Set the gain to 1000. Test that the gain does, in fact,
provide you with amplification of the difference between the two inputs.
2. Simulate the protection circuitry in Fig. 12.1, above. Use ideal diodes in MapleSim. Set the knee voltage
in these diodes to 0.7v. Ensure that you get clamping of the output signal (from the instrumentation
amplifier) of -0.7 volts (if it goes negative) and 5.7 volts if it exceeds 5.7 volts.
3. Simulate the Wheatstone bridge found in the Futek Loadcell. Assume that the three arms are set to
1000 Ohms and that the fourth arm can vary between 997 Ohms and 1003 Ohms. Ensure that the
instrumentation amplifier clamps when exceeding these boundaries.
1. a differential amplifier with a gain of between 500 and 1000 (see skill questions for more details)
2. a clamping circuit to ensure that the maximum voltage into the 9s12’s ADC doesn’t exceed 5.7 volts and
doesn’t fall below -0.7volts.
1. The potentiometer, P1 can be used to zero adjust the load cell. Under no-load, the output voltage of the
Instrumentation Amplifier (IA) should be zero.
(a) Explain how you would set up the procedure to properly zero-adjust your load cell configuration.
(b) From a robust calibration perspective, what purpose is served by adding 1K resistor to each end of
potentiometer, P1?.
(c) If the IA output is always negative (below zero) instead of the positive value required under load,
where would the possible error be in your connections?
2. If you use or change to a different test jig, would you need to zero-adjust again? Why?
3. For the Bridge and zero-adjust circuitry, why is it necessary to use the +10V voltage reference instead of
simply using the +15V power supply?
4. Referring to the IA datasheets, determine the value of RG required to set the IA gain of 1000. To obtain
close to a full scale output of 0 to 5V for the range of weight measurements specified, what should the IA
gain be?
5. During power-up, the output of the IA can temporarily saturate and swing to either +15V or 15V, and
this can seriously damage your microcontroller which is powered by a +5V supply.
(a) Analyze the protection circuitry, and show that the input to your microcontroller will be clamped
to +5.7V and 0.7V when the output of the IA is at +15V and 15V, respectively. Use the MapleSim
simulator to verify the operation of the clamping circuit. Include screenshots of your schematic and
your graphed results.
(b) Is the 1K series resistor sufficiently small relative to the input resistance of the A/D input to avoid
significant attenuation of the IA output signal? (refer to the 9s12c32 datasheets).
(c) When the IA output is at +15V and -15V, determine the value of the current that flows through
each diode, respectively. Do these diode currents fall within the maximum current permitted for the
diode you have selected? (refer to diode datasheet).
6. What is the purpose of VH and VL (Also known as VRH and VRL )inputs of the ADC of the microcontroller?
For the ADC of the 9s12, what is the smallest mass that can be accurately resolved in 8bit mode? What
about 10bit mode?
2. How did you maintain a stable Vref for your bridge and why is it important?
where Sj is the score of the j th group, and n groups have submitted bonus exercises. Bj is the code size, in
bytes, of the group’s executable code. The result is a percentage applied to the actual bonus score, found below.
• Section 1: Modify the circuit simulation so that the strain gauge arm in the Wheatstone bridge is variable.
Have a plot of the voltage coming out of the clamping circuit which shows variability of output based on
changing resistance within the bridge (to simulate loading of the load cell). As the loading changes make
sure that the clamping action is visible in the plot. (5% bonus to Milestone 3’s grade)
• Section 2: Modify the circuit simulation so that the input is a force in Newtons, which is then converted
to voltage. This voltage is then to be fed into the differential amplifier. Vary the input force from 0 to
4.5 N. What is the output voltage into the ADC? Plot it. (5% bonus to Milestone 3’s grade)
• Sections 3 and 4: Implement the bridge zero-adjust circuitry in simulation. Demonstrate that you can
adjust the zero-adjust circuitry values to compensate for an unbalanced loadcell bridge within the sim-
ulated loadcell. You must also have the instrumentation amplifier and clamping circuitry included and
functional in your simulation.(5% bonus to Milestone 3’s grade)
• Section 1: Have Matlab graph the force data from the Esduino and load cell “live” so that points are
plotted in the graph as soon as they are received. (5% bonus to Milestone 3’s grade)
• Section 2: Press a key in Matlab and have the Esduino’s display switch toggle between showing Force in
Newtons and in Kg (5% bonus to this week’s grade)
In each case you must demonstrate the functionality to the TA during the lab and you must include a copy
of your source code in your report.
12.9 Communication
You will need to demonstrate your simulations in Week 10 and your working system to the TA in Week 11. You
will then submit a standard four page written report one week after your Week 11 lab, by 11:59pm of the night
in question. You need to email the TA your PDF document, including a standard signed FEAS cover sheet.
In the left column, your citations, language and content are evaluated. The marking is based on how well you
perform in each of those items. The individual scores are added up and written in the box below the column.
Afterwards, deductions are is made based on the factors in the right hand column. The deductions are
cumulative and can reduce your grade to 0 (minimum).
13.2 Overview
In Weeks 12 and 13, work on integrating the angle and force functions, per the specifications. In Week 14,
complete demonstration of all functions per specifications. Seamless deterministic / realtime execution of
all functions, and any enhancements implemented by the final lab session. Final source-code version to be
compiled/assembled during the demo. The live demonstration, using the “Marking Scheme for Milestone 4”, is
the requirement for Milestone 4. There is nothing to hand in for Milestone 4 (i.e. there is no formal report...
the reporting milestone is Milestone 5). You are required to demonstrate the microcontroller functionality to
the TA during the scheduled lab session. There will be no extensions for the Milestone 4 demonstration.
The final lab report, Milestone 5, is to be a report on the design, development, testing and demonstration
of your sensing and measurement system. Marking will be as per the marking scheme.
13.4 Exploration
In addition to achieving the basic functional requirements you should explore different approaches to the user
experience.
The sequence of operations is described in the list below.
1. On Power-up, the names of the lab partners should appear on the LCD.
13-1
Oscilloscope test Digital volt meter Test
5 V power supply
equipment equipment
Pushbutton
LED
switch(es)
Digital Digital
input output
Accelerometer 9s12 LED
ADC SPI
LED
External Voltage
reference LCD Display
(a) Components (b) User Interface Concept (c) An example implementation
Figure 13.1: Your system should integrate the components in (a) to create a basic user interface (b) (image
courtesy of Dr. Mike Kassam). Many designs are possible. One example is shown in (c).
2. If the button is pressed twice, in quick succession, the LCD should show if the force and angles are in
“safe” or “dangerous” zones. No LEDs should be flashing. This should continue unless the user presses
the button once (to exit).
3. If the button was not pushed, or if the user has exited the other mode, the “Angle” LED should light-up
& flash indicating angle measurement in progress. The LCD display should display Angle in “real-time”,
as shown in Fig. 13.4.1a.
4. For Force selection, the user momentarily presses the Push-button once to light-up & flash the “Force”
LED, indicating Force measurement. The LCD display should display Force in “real-time”, as shown in
Fig. 13.4.1b.
5. When the user presses the Push-button again, only the “Force & Angle” LED is turned on and flashing,
with “real-time” display of the parameters, as shown in Fig. 13.4.1c.
6. When the user presses the Push-button again, the cycle reverts to displaying Angle.
7. If, at any point, the user presses the button for ten seconds or more the system should begin streaming
data to a PC where it can be read by Matlab. The LCD should display that PC communication is in
effect.
Figure 13.2: After displaying a startup screen showing the names of the two partners, The sequence of operations
to display. (images courtesy of Dr. Mike Kassam)
• All Students in all sections: A 3% bonus will be added to the Milestone 4 mark to all groups that place
their DAQ systems within a “sturdy” box that can, at minimum, reasonably protect the DAQ from objects
typically found in a student’s backpack. Cardboard or paper boxes do not qualify for a bonus.
where Sj is the score of the j th group, and n groups have submitted bonus exercises. Bj is the code size, in
bytes, of the group’s executable code. The result is a percentage applied to the actual bonus score, found below.
These can only be completed during a student’s scheduled Milestone 4 in-lab demonstration session.
• Section 1: Create a Matlab script that requests the user to place four known masses on the loadcell and
then shows the characteristic linear input-output relationship between Mass and ADC on the 9s12. (5%
bonus to Milestone 5’s grade)
• Section 2: Display live mass values in Matlab with minimal lag. Make sure that it can show mass versus
time, so that if you slowly add the mass, the curve updates to show the change over time. (5% bonus to
Milestone 5’s grade)
• Sections 3 and 4: Create a Matlab script that can automatically read the mass value on the Esduino to
determine the zero offset and command the Esduino to adjust the offset without the use of the bias circuit
potentiometer (5% bonus to Milestone 5’s grade)
In each case you must demonstrate the functionality to the TA during the lab and you must include a copy
of your source code in your report.
• Milestone 5: written report to be emailed on the last day of class before examinations (April 15 at
11:59pm)
1.
2.
ELE604 Milestone 5 Marking Guide (Final Report) 2012
Section No.
Group No.
Submission Date n/a
Due Date Last class (11:59pm)
*By signing above you attest that you have contributed to this submission and confirm that
all work you have contributed to this submission is your own work. Any suspicion of
copying or plagiarism in this work will result in an investigation of Academic Misconduct
and may result in a “0” on the work, an “F” in the course, or possibly more severe
penalties, as well as a Disciplinary Notice on your academic record under the Student
Code of Academic Conduct, which can be found online at:
www.ryerson.ca/senate/current/pol60.pdf.
Bibliography
[1] MC9S12C Family Device User Guide. Motorola Inc., v01.05 edition, February 2004.
[3] MC9s12C Family MC9s12GC Family Reference Manual. Freescale Semiconductor, rev. 01.24 edition, May
2010.
[5] S12(X) Build Tools Reference Manual. Freescale Semiconductor, August 2010.
[6] George Adams, Jr. Henry Blume, Shep Hume, Ronald Towle, John Wharton, Bob Wickersheim, Bill Wong,
, John Ekiss, and David Laws. Intel 8051 microprocessor oral history panel. Technical Report X5007.2009,
Computer History Museum, Moutain View, California, USA, 2008. http://archive.computerhistory.
org/resources/access/text/Oral_History/102658339.05.01.acc.pdf.
[7] Thomas H. Bennett, John Ekiss, William (Bill) Lattin, Jeff Lavell, and David Laws. Motorola 6800 oral
history panel. Technical report, Computer History Museum, Tempe, Arizona, March 2008.
[8] Allan Hambley. Electrical Engineering: Principles and Applications. Pearson Education, fifth edition,
2008.
[10] Henry Blume Jr., John Ekiss, Yung Feng, Barbara Kline, Howard Raphael, David Stamm, and David Laws.
Oral history panel on the development and promotion of the intel 8048 microcontroller. Technical report,
Computer History Museum, Moutain View, California, USA, 2008. http://archive.computerhistory.
org/resources/access/text/Oral_History/102658328.05.01.acc.pdf.
[11] J. C. King. Strain-gauge rosette formulae. Aircraft Engineering and Aerospace Technology, 16(2):32 – 49,
1993. http://www.emeraldinsight.com/journals.htm?articleid=1678390.
[12] Muhammad Ali Mazidi and Danny Causey. HCS12 Microcontroller and Embedded Systems: Using Assembly
and C with CodeWarrior. Pearson Prentic Hall, 2009.
[13] Motorola Inc. Motorola achieves design wins of $1 billion+ for 16-bit microcontroller family. PR Newswire,
pages 1–1, Nov. 26 2001.
[14] Freescale Semiconductor. The xgate coprocessor. Technical Report XGATECOPROCFS, Freescale Semi-
conductor, 2004.
[15] Freescale Seminconductor. Mc9s12c family mc9s12gc family reference manual. Reference Manual
MC9S12C128 Rev 01.23, Freescale Semiconductor, June 2007.
13-9
[16] Jim Williams. Serial monitor program for hcs12 mcus. Application Note AN2548/D, Freescale Semiconduc-
tor, September 2003. http://www.freescale.com/files/microcontrollers/doc/app_note/AN2548.
pdf?fsrch=1.
[17] Ron Wilson. Seeks 16-bit hc11 migration path – moto spins new mcu line. Electronic Engineering Times,
(01921541):16–16, May 27 1996. MOTOROLA INC; (Copyright 1996 CMP Publications, Inc. All rights re-
served.); May 27, 1996; English; 16; ELECTRONICS; SEMICONDUCTORS; INDUSTRIAL TECHNOL-
OGY; TECHNOLOGY; COMMUNICATIONS; 208132261; EETIDQ; Manhasset; Wilson, Ron; 10660679;
565100; 16096; ELET.
A-1
Draft 01/18/11 Jim Koch
Emergency procedures, lab rules, and engineering support contact information is posted on the lab
door.
First Aid.
• Minor cuts/burn use small kit by door, if you use supplies let engineering support know.
• Minor and up injuries, See First Aider, Dan in ENG439.
• Ryerson Medical Centre KHW 181.
• St Michael's Hospital 70 Richmond Street East
Soldering.
• The soldering tip end is very hot and will burn flesh immediately, or cause a fire if left in
contact with combustible materials.
• Only lead free solder is to be used in the lab.
• Always return the iron to the stand.
• Turn off iron when finished for the day.
• When soldering and trimming leads safety glasses are required.
• When trimming soldered leads make sure they do not fly into your eyes or equipment vents etc.
• Use the fume extractors at all times.
• Never use plumbers solder paste as it contains acid and will eat away your circuit.
1
Draft 01/18/11 Jim Koch
Lab equipment.
• Make sure the test equipment is on the correct range before taking measurements.
• Make sure the test you are about to perform does not exceed the test equipments rating.
• Report any defective or unsafe equipment to engineering support.
• Scope ground is earth ground. Green Wire in AC plug. Us caution when placing ground in your
circuit as it may short things out. If unsure, ask to borrow a differential probe which will isolate
grounds.
• Screen capture: HP/Agilent scopes, Run Windows XP, click on HP Bench Link Scope icon.
• Screen capture: Tektronix scope, type scope in the URL bar.
• If there is no power to the bench, make sure it's plugged into the floor outlet properly and that
the power bar mounted under the bench is plugged into the bench and turned on.
2
A-4 Edit Date: February 12, 2013
Appendix B
To Be Sorted Later
B-1
Freescale Semiconductor MC9S12CFAMPB
Rev. 5, 03/2006
Product Brief
MC9S12C-Family
16-Bit Microcontroller
Based on Freescale’s market-leading flash technology, members of the MC9S12C-Family deliver the
power and flexibility of our 16 Bit core (CPU12) family to a whole new range of cost and space sensitive,
general purpose Industrial and Automotive network applications. MC9S12C-Family members are
comprised of standard on-chip peripherals including a 16-bit central processing unit (CPU12), up to 128K
bytes of Flash EEPROM or ROM, up to 4K bytes of RAM, an asynchronous serial communications
interface (SCI), a serial peripheral interface (SPI), an 8-channel 16-bit timer module (TIM), a 6-channel
8-bit pulse width modulator (PWM), an 8-channel, 10-bit analog-to-digital converter (ADC) and up to one
CAN 2.0 A, B software compatible module (MSCAN12). The MC9S12C-Family has full 16-bit data paths
throughout. The inclusion of a PLL circuit allows power consumption and performance to be adjusted to
suit operational requirements. In addition to the I/O ports available in each module, up to 10 dedicated I/O
port bits are available with Wakeup capability from STOP or WAIT mode. The MC9S12C-Family is
available in 48-pin and 52-pin LQFP, and in 80-pin QFP packages (all RoHS Compliant J-STD-020C); the
80-pin version is pin-compatible with the HCS12B- and D-Family derivatives.
The C-Family includes ROM versions MC3S12C128/96/64/32/16 of all devices which provide a further
cost reduction path for applications with high volume and stable code.
1 Features
• 16-Bit HCS12 CORE
— HCS12 CPU
— MMC (memory map and interface)
— INT (interrupt control)
— BDM (background debug mode)
— DBG12 (enhanced debug12 module including breakpoints and change-of-flow trace buffer)
— Multiplexed Expansion Bus (available only in 80-pin package version)
MC9S12C-Family, Rev. 5
2 Freescale Semiconductor
Features
• Serial Interfaces
— One asynchronous serial communications interface (SCI)
— One synchronous serial peripheral interface (SPI)
• CRG (Clock Reset Generator Module)
— Windowed COP watchdog,
— Real time interrupt,
— Clock monitor,
— Clock generation
— Reset Generation
— Phase-locked loop clock frequency multiplier
— Limp home mode in absence of external clock
— Low power 0.5 to 16 MHz crystal oscillator reference clock
• Operation Frequency
— 32MHz equivalent to 16MHz Bus Speed for single chip
— 32MHz equivalent to 16MHz Bus Speed in expanded bus modes
— Option: 50MHz equivalent to 25MHz Bus Speed
— Internal 2.5V Regulator
— Supports an input voltage range from 3.3V-10% to 5.5V
— Low power mode capability
— Includes low voltage reset (LVR) circuitry
— Includes low voltage interrupt (LVI) circuitry
• 48-pin LQFP, 52-pin LQFP, or 80-pin QFP Package (all RoHS Compliant J-STD-020C)
— Up to 58 I/O lines with 5V input and drive capability
— Up to 2 dedicated 5V input only lines (IRQ, XIRQ)
— 5V A/D converter inputs and 5V I/O
• Development Support
— Single-wire background debug™ mode (BDM)
— On-chip hardware breakpoints
— Enhanced DBG12 debug features
MC9S12C-Family, Rev. 5
Freescale Semiconductor 3
MC9S12C-Family Members
2 MC9S12C-Family Members
Table 1. List of MC9S12C-Family Members
Flash ROM RAM Package Device CAN SCI SPI A/D PWM Timer I/O
48LQFP MC9S12C128 1 1 1 8ch 6ch 8ch 31
128K 0 4K 52LQFP MC9S12C128 1 1 1 8ch 6ch 8ch 35
80QFP MC9S12C128 1 1 1 8ch 6ch 8ch 60
48LQFP MC9S12C96 1 1 1 8ch 6ch 8ch 31
96K 0 4K 52LQFP MC9S12C96 1 1 1 8ch 6ch 8ch 35
80QFP MC9S12C96 1 1 1 8ch 6ch 8ch 60
48LQFP MC9S12C64 1 1 1 8ch 6ch 8ch 31
64K 0 4K 52LQFP MC9S12C64 1 1 1 8ch 6ch 8ch 35
80QFP MC9S12C64 1 1 1 8ch 6ch 8ch 60
48LQFP MC9S12C32 1 1 1 8ch 6ch 8ch 31
32K 0 2K 52LQFP MC9S12C32 1 1 1 8ch 6ch 8ch 35
80QFP MC9S12C32 1 1 1 8ch 6ch 8ch 60
48LQFP MC9S12GC32 0 1 1 8ch 6ch 8ch 31
32K 0 2K 52LQFP MC9S12GC32 0 1 1 8ch 6ch 8ch 35
80QFP MC9S12GC32 0 1 1 8ch 6ch 8ch 60
48LQFP MC9S12GC16 0 1 1 8ch 6ch 8ch 31
16K 0 1K 52LQFP MC9S12GC16 0 1 1 8ch 6ch 8ch 35
80QFP MC9S12GC16 0 1 1 8ch 6ch 8ch 60
48LQFP MC3S12C128 1 1 1 8ch 6ch 8ch 31
0 128K 4K 52LQFP MC3S12C128 1 1 1 8ch 6ch 8ch 35
80QFP MC3S12C128 1 1 1 8ch 6ch 8ch 60
48LQFP MC3S12C96 1 1 1 8ch 6ch 8ch 31
0 96K 4K 52LQFP MC3S12C96 1 1 1 8ch 6ch 8ch 35
80QFP MC3S12C96 1 1 1 8ch 6ch 8ch 60
48LQFP MC3S12C64 1 1 1 8ch 6ch 8ch 31
0 64K 4K 52LQFP MC3S12C64 1 1 1 8ch 6ch 8ch 35
80QFP MC3S12C64 1 1 1 8ch 6ch 8ch 60
48LQFP MC3S12C32 1 1 1 8ch 6ch 8ch 31
0 32K 2K 52LQFP MC3S12C32 1 1 1 8ch 6ch 8ch 35
80QFP MC3S12C32 1 1 1 8ch 6ch 8ch 60
48LQFP MC3S12GC32 0 1 1 8ch 6ch 8ch 31
0 32K 2K 52LQFP MC3S12GC32 0 1 1 8ch 6ch 8ch 35
80QFP MC3S12GC32 0 1 1 8ch 6ch 8ch 60
48LQFP MC3S12GC16 0 1 1 8ch 6ch 8ch 31
0 16K 1K 52LQFP MC3S12GC16 0 1 1 8ch 6ch 8ch 35
80QFP MC3S12GC16 0 1 1 8ch 6ch 8ch 60
MC9S12C-Family, Rev. 5
4 Freescale Semiconductor
Pin Out Explanations
MC9S12C-Family, Rev. 5
Freescale Semiconductor 5
Block Diagram
4 Block Diagram
VSSR VDDA VDDA
VDDR ATD VSSA VSSA
VDDX VRH VRH
VSSX Voltage Regulator VRL VRL
AN0 PAD0
AN1 PAD1
AN2 PAD2
DDRAD
PTAD
AN3 PAD3
VDD2 32K, 64K, 96K, 128K Byte Flash/ROM AN4 PAD4
VSS2 AN5 PAD5
VDD1 AN6 PAD6
1K, 2K, 4K Byte RAM
VSS1 AN7 PAD7
DDRT
VDDPLL IOC3 PT3
PTT
Clock and Timer
VSSPLL Reset Module IOC4 PT4
PLL Generation
EXTAL COP Watchdog IOC5 PT5
Module
XTAL Clock Monitor IOC6 PT6
RESET Periodic Interrupt IOC7 PT7
PE0 XIRQ PW0 PP0
Keypad Interrupt
PE1 IRQ PW1 PP1
System PW2
PE2 R/W PWM PP2
Integration
DDRE
DDRP
PTE
PTP
PE3 LSTRB/TAGLO Module Module PW3 PP3
PE4 ECLK (SIM) PW4 PP4
PE5 MODA/IPIPE0 PW5 PP5
PE6 MODB/IPIPE1 PP6
PE7 NOACC/XCLKS PP7
TEST/VPP
Key Int
DDRJ
PJ6
PTJ
PJ7
Multiplexed Address/Data Bus
RXD PS0
SCI
DDRS
TXD PS1
PTS
DDRA DDRB PS2
PS3
PTA PTB
RXCAN PM0
MSCAN
TXCAN PM1
DDRM
PB7
PB6
PB5
PB3
PB2
PB1
PB0
PB4
PA7
PA6
PA5
PA4
PA3
PA2
PA1
PA0
MOSI PM4
ADDR9
ADDR7
ADDR6
ADDR5
ADDR3
ADDR2
ADDR1
ADDR0
ADDR8
ADDR4
SCK PM5
DATA15
DATA14
DATA13
DATA12
DATA11
DATA10
DATA9
DATA7
DATA6
DATA5
DATA3
DATA2
DATA1
DATA0
DATA8
DATA4
Multiplexed
Wide Bus Signals shown in Bold are not available on the 52 or 48 Pin Package
Signals shown in Bold Italic are available in the 52, but not the 48 Pin Package
MC9S12C-Family, Rev. 5
6 Freescale Semiconductor
User Configurable Memory Maps
$7FFF
$8000
$8000
$BFFF
$C000
$C000 16K Fixed Flash EEPROM/ROM
$FFFF
$FF00 BDM
$FF00 (If Active)
$FFFF VECTORS VECTORS VECTORS $FFFF
The figure shows a useful map, which is not the map out of reset. After reset the map is:
$0000 - $03FF: Register Space
$0000 - $0FFF: 4K RAM (only 3K visible $0400 - $0FFF)
Flash Erase Sector Size is 1024 Bytes
MC9S12C-Family, Rev. 5
Freescale Semiconductor 7
User Configurable Memory Maps
$7FFF
$8000
$8000
$BFFF
$C000
$C000 16K Fixed Flash EEPROM/ROM
$FFFF
$FF00 BDM
$FF00 (If Active)
$FFFF VECTORS VECTORS VECTORS $FFFF
The figure shows a useful map, which is not the map out of reset. After reset the map is:
$0000 - $03FF: Register Space
$0000 - $0FFF: 4K RAM (only 3K visible $0400 - $0FFF)
Flash Erase Sector Size is 1024 Bytes
MC9S12C-Family, Rev. 5
8 Freescale Semiconductor
User Configurable Memory Maps
$7FFF
$8000
$8000
$BFFF
$C000
$C000 16K Fixed Flash EEPROM/ROM
$FFFF
$FF00 BDM
$FF00 (If Active)
$FFFF VECTORS VECTORS VECTORS $FFFF
The figure shows a useful map, which is not the map out of reset. After reset the map is:
$0000 - $03FF: Register Space
$0000 - $0FFF: 4K RAM (only 3K visible $0400 - $0FFF)
Flash Erase Sector Size is 512 Bytes
MC9S12C-Family, Rev. 5
Freescale Semiconductor 9
User Configurable Memory Maps
$8000
$8000
$BFFF
$C000
$C000 16K Fixed Flash EEPROM/ROM
$FFFF
$FF00 BDM
$FF00 (If Active)
$FFFF VECTORS VECTORS VECTORS $FFFF
The figure shows a useful map, which is not the map out of reset. After reset the map is:
$0000 - $03FF: Register Space
$0800 - $0FFF: 2K RAM
Flash Erase Sector Size is 512 Bytes
MC9S12C-Family, Rev. 5
10 Freescale Semiconductor
User Configurable Memory Maps
$8000
$8000
$BFFF
$C000
$C000 16K Fixed Flash EEPROM/ROM
$FFFF
$FF00 BDM
$FF00 (If Active)
$FFFF VECTORS VECTORS VECTORS $FFFF
The figure shows a useful map, which is not the map out of reset. After reset the map is:
$0000 - $03FF: Register Space
$0800 - $0FFF: 2K RAM
Flash Erase Sector Size is 512 Bytes
MC9S12C-Family, Rev. 5
Freescale Semiconductor 11
User Configurable Memory Maps
$8000
$8000
$BFFF
$C000
$C000 16K Fixed Flash EEPROM/ROM
$FFFF
$FF00 BDM
$FF00 (If Active)
$FFFF VECTORS VECTORS VECTORS $FFFF
The figure shows a useful map, which is not the map out of reset. After reset the map is:
$0000 - $03FF: Register Space
$0C00 - $0FFF: 1K RAM
Flash Erase Sector Size is 512 Bytes
MC9S12C-Family, Rev. 5
12 Freescale Semiconductor
Pin Assignments
6 Pin Assignments
PP6/KWP6/ROMONE
PP4/KWP4/PW4
PP5/KWP5/PW5
PM0/RXCAN
PM1/TXCAN
PP7/KWP7
PM4/MOSI
PM2/MISO
PJ6/KWJ6
PJ7/KWJ7
PM5/SCK
PS0/RXD
PS1/TXD
PM3/SS
VDDX
VSSX
VSSA
VRL
PS3
PS2
80
79
78
77
76
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
PW3/KWP3/PP3 1 60 VRH
PW2/KWP2/PP2 2 59 VDDA
PW1/KWP1/PP1 3 58 PAD07/AN07
PW0/KWP0/PP0 4 57 PAD06/AN06
PW0/IOC0/PT0 5 56 PAD05/AN05
PW1/IOC1/PT1 6 55 PAD04/AN04
PW2/IOC2/PT2 7 54 PAD03/AN03
PW3/IOC3/PT3 8 53 PAD02/AN02
VDD1 9 52 PAD01/AN01
VSS1 10 MC9S12C-Family 51 PAD00/AN00
PW4/IOC4/PT4 11 80 QFP 50 VSS2
IOC5/PT5 12 49 VDD2
IOC6/PT6 13 48 PA7/ADDR15/DATA15
IOC7/PT7 14 47 PA6/ADDR14/DATA14
MODC/TAGHI/BKGD 15 46 PA5/ADDR13/DATA13
ADDR0/DATA0/PB0 16 45 PA4/ADDR12/DATA12
ADDR1/DATA1/PB1 17 44 PA3/ADDR11/DATA11
ADDR2/DATA2/PB2 18 43 PA2/ADDR10/DATA10
ADDR3/DATA3/PB3 19 42 PA1/ADDR9/DATA9
ADDR4/DATA4/PB4 20 41 PA0/ADDR8/DATA8
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
ADDR5/DATA5/PB5
ADDR6/DATA6/PB6
ADDR7/DATA7/PB7
XCLKS/NOACC/PE7
MODB/IPIPE1/PE6
MODA/IPIPE0/PE5
ECLK/PE4
VSSR
VDDR
TEST/VPP
RESET
VDDPLL
XFC
VSSPLL
EXTAL
XTAL
LSTRB/TAGLO/PE3
R/W/PE2
IRQ/PE1
XIRQ/PE0
MC9S12C-Family, Rev. 5
Freescale Semiconductor 13
Pin Assignments
PP4/KWP4/PW4
PP5/KWP5/PW5
PM0/RXCAN
PM1/TXCAN
PM4/MOSI
PM2/MISO
PM5/SCK
PS0/RXD
PS1/TXD
PM3/SS
VDDX
VSSX
VSSA
52
51
50
49
48
47
46
45
44
43
42
41
40
PW3/KWP3/PP3 1 39 VRH
PW0/IOC0/PT0 2 38 VDDA
PW1/IOC1/PT1 3 37 PAD07/AN07
PW2/IOC2/PT2 4 36 PAD06/AN06
PW3/IOC3/PT3 5 35 PAD05/AN05
VDD1 6 34 PAD04/AN04
VSS1 7 MC9S12C-Family 33 PAD03/AN03
52 LQFP
PW4/IOC4/PT4 8 32 PAD02/AN02
IOC5/PT5 9 31 PAD01/AN01
IOC6/PT6 10 30 PAD00/AN00
IOC7/PT7 11 29 PA2
MODC/BKGD 12 28 PA1
PB4 13 27 PA0
14
15
16
17
18
19
20
21
22
23
24
25
26
XCLKS/PE7
ECLK/PE4
VDDR
VSSPLL
EXTAL
XTAL
IRQ/PE1
XIRQ/PE0
VSSR
VDDPLL
RESET
XFC
TEST/VPP
MC9S12C-Family, Rev. 5
14 Freescale Semiconductor
Pin Assignments
PM0/RXCAN
PM1/TXCAN
PP5/KWP5
PM2/MISO
PM4/MOSI
PM5/SCK
PS0/RXD
PS1/TXD
PM3/SS
VDDX
VSSX
VSSA
48
47
46
45
44
43
42
41
40
39
38
37
PW0/IOC0/PT0 1 36 VRH
PW1/IOC1/PT1 2 35 VDDA
PW2/IOC2/PT2 3 34 PAD07/AN07
PW3/IOC3/PT3 4 33 PAD06/AN06
VDD1 5 32 PAD05/AN05
VSS1 6 MC9S12C-Family 31 PAD04/AN04
48 LQFP
PW4/IOC4/PT4 7 30 PAD03/AN03
IOC5/PT5 8 29 PAD02/AN02
IOC6/PT6 9 28 PAD01/AN01
IOC7/PT7 10 27 PAD00/AN00
MODC/BKGD 11 26 PA0
PB4 12 25 XIRQ/PE0
13
14
15
16
17
18
19
20
21
22
23
24
VDDR
VSSR
RESET
XFC
XCLKS/PE7
VDDPLL
ECLK/PE4
VSSPLL
EXTAL
XTAL
TEST/VPP
IRQ/PE1
MC9S12C-Family, Rev. 5
Freescale Semiconductor 15
Package Mechanical Information
MC9S12C-Family, Rev. 5
16 Freescale Semiconductor
Package Mechanical Information
MC9S12C-Family, Rev. 5
Freescale Semiconductor 17
Package Mechanical Information
MC9S12C-Family, Rev. 5
18 Freescale Semiconductor
Package Mechanical Information
MC9S12C-Family, Rev. 5
Freescale Semiconductor 19
Package Mechanical Information
MC9S12C-Family, Rev. 5
20 Freescale Semiconductor
Package Mechanical Information
MC9S12C-Family, Rev. 5
Freescale Semiconductor 21
Package Mechanical Information
MC9S12C-Family, Rev. 5
22 Freescale Semiconductor
Package Mechanical Information
MC9S12C-Family, Rev. 5
Freescale Semiconductor 23
Package Mechanical Information
MC9S12C-Family, Rev. 5
24 Freescale Semiconductor
Package Mechanical Information
MC9S12C-Family, Rev. 5
Freescale Semiconductor 25
How to Reach Us:
Home Page:
www.freescale.com
E-mail:
support@freescale.com
Europe, Middle East, and Africa: Information in this document is provided solely to enable system and software
Freescale Halbleiter Deutschland GmbH implementers to use Freescale Semiconductor products. There are no express or
Technical Information Center implied copyright licenses granted hereunder to design or fabricate any integrated
Schatzbogen 7 circuits or integrated circuits based on the information in this document.
81829 Muenchen, Germany
+44 1296 380 456 (English)
+46 8 52200080 (English) Freescale Semiconductor reserves the right to make changes without further notice to
+49 89 92103 559 (German) any products herein. Freescale Semiconductor makes no warranty, representation or
+33 1 69 35 48 48 (French) guarantee regarding the suitability of its products for any particular purpose, nor does
support@freescale.com Freescale Semiconductor assume any liability arising out of the application or use of any
product or circuit, and specifically disclaims any and all liability, including without
Japan: limitation consequential or incidental damages. “Typical” parameters that may be
Freescale Semiconductor Japan Ltd.
provided in Freescale Semiconductor data sheets and/or specifications can and do vary
Headquarters
ARCO Tower 15F in different applications and actual performance may vary over time. All operating
1-8-1, Shimo-Meguro, Meguro-ku, parameters, including “Typicals”, must be validated for each customer application by
Tokyo 153-0064 customer’s technical experts. Freescale Semiconductor does not convey any license
Japan under its patent rights nor the rights of others. Freescale Semiconductor products are
0120 191014 or +81 3 5437 9125 not designed, intended, or authorized for use as components in systems intended for
support.japan@freescale.com surgical implant into the body, or other applications intended to support or sustain life,
or for any other application in which the failure of the Freescale Semiconductor product
Asia/Pacific:
could create a situation where personal injury or death may occur. Should Buyer
Freescale Semiconductor Hong Kong Ltd.
Technical Information Center purchase or use Freescale Semiconductor products for any such unintended or
2 Dai King Street unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and
Tai Po Industrial Estate its officers, employees, subsidiaries, affiliates, and distributors harmless against all
Tai Po, N.T., Hong Kong claims, costs, damages, and expenses, and reasonable attorney fees arising out of,
+800 2666 8080 directly or indirectly, any claim of personal injury or death associated with such
support.asia@freescale.com unintended or unauthorized use, even if such claim alleges that Freescale
Semiconductor was negligent regarding the design or manufacture of the part.
For Literature Requests Only:
Freescale Semiconductor Literature Distribution Center
P.O. Box 5405 Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
Denver, Colorado 80217 All other product or service names are the property of their respective owners.
1-800-441-2447 or 303-675-2140
Fax: 303-675-2150
LDCForFreescaleSemiconductor@hibbertgroup.com © Freescale Semiconductor, Inc. 2005, 2006. All rights reserved.
MC9S12CFAMPB
Rev. 5, 03/2006
B-28 Edit Date: February 12, 2013
Appendix C
Figure C.1: This is the parts list for the 2011 lab kit.
C-1
C-2 Edit Date: February 12, 2013
Appendix D
D-1
Low Cost Low Power AD620
Instrumentation Amplifier
TABLE OF CONTENTS
AD620 Specifications .....................................................................................3 Input Protection ..........................................................................16
00775-0-001
TOP VIEW
Excellent dc performance (B grade) Input and Output Offset Voltage ..............................................16 Ordering Guide ...........................................................................20
50 µV max, input offset voltage Figure 1. 8-Lead PDIP (N), CERDIP (Q), and SOIC (R) Packages
0.6 µV/°C max, input offset drift Reference Terminal .....................................................................16
PRODUCT DESCRIPTION
1.0 nA max, input bias current
The AD620 is a low cost, high accuracy instrumentation
100 dB min common-mode rejection ratio (G = 10)
amplifier that requires only one external resistor to set gains of
Low noise REVISION HISTORY
1 to 10,000. Furthermore, the AD620 features 8-lead SOIC and
9 nV/√Hz @ 1 kHz, input voltage noise
DIP packaging that is smaller than discrete designs and offers 12/04—Rev. F to Rev. G 7/03—Data Sheet changed from REV. E to REV. F
0.28 µV p-p noise (0.1 Hz to 10 Hz)
lower power (only 1.3 mA max supply current), making it a
Excellent ac specifications Updated Format.................................................................. Universal Edit to FEATURES............................................................................1
good fit for battery-powered, portable (or remote) applications.
120 kHz bandwidth (G = 100) Changes to SPECIFICATIONS .......................................................2
Change to Features............................................................................1
15 µs settling time to 0.01% The AD620, with its high accuracy of 40 ppm maximum
Change to Product Description.......................................................1 Removed AD620CHIPS from ORDERING GUIDE ...................4
nonlinearity, low offset voltage of 50 µV max, and offset drift of
APPLICATIONS 0.6 µV/°C max, is ideal for use in precision data acquisition Changes to Specifications.................................................................3 Removed METALLIZATION PHOTOGRAPH...........................4
Weigh scales systems, such as weigh scales and transducer interfaces. Replaced TPCs 1–3 ...........................................................................5
Added Metallization Photograph....................................................4
ECG and medical instrumentation Furthermore, the low noise, low input bias current, and low power
Replaced Figure 4-Figure 6 ..............................................................6 Replaced TPC 12 ...............................................................................6
Transducer interface of the AD620 make it well suited for medical applications, such
as ECG and noninvasive blood pressure monitors. Replaced TPC 30 ...............................................................................9
Data acquisition systems Replaced Figure 15 ............................................................................7
Industrial process controls Replaced Figure 33 ..........................................................................10 Replaced TPCs 31 and 32...............................................................10
The low input bias current of 1.0 nA max is made possible with
Battery-powered and portable equipment the use of Superϐeta processing in the input stage. The AD620 Replaced Figure 4 ............................................................................10
Replaced Figure 34 and Figure 35.................................................10
works well as a preamplifier due to its low input voltage noise of Changes to Table I...........................................................................11
Replaced Figure 37 ..........................................................................10
9 nV/√Hz at 1 kHz, 0.28 µV p-p in the 0.1 Hz to 10 Hz band,
Changes to Table 3 ..........................................................................13 Changes to Figures 6 and 7 ............................................................12
and 0.1 pA/√Hz input current noise. Also, the AD620 is well
suited for multiplexed applications with its settling time of 15 µs Changes to Figure 41 and Figure 42 .............................................14 Changes to Figure 8 ........................................................................13
to 0.01%, and its cost is low enough to enable designs with one Edited INPUT PROTECTION section........................................13
Changes to Figure 43 ......................................................................15
in-amp per channel.
Change to Figure 44 ........................................................................17 Added new Figure 9........................................................................13
30,000 10,000
00775-0-002
00775-0-003
Figure 2. Three Op Amp IA Designs vs. AD620 Figure 3. Total Voltage Noise vs. Source Resistance
Rev. G
Information furnished by Analog Devices is believed to be accurate and reliable.
However, no responsibility is assumed by Analog Devices for its use, nor for any
infringements of patents or other rights of third parties that may result from its use.
Specifications subject to change without notice. No license is granted by implication One Technology Way, P.O. Box 9106, Norwood, MA 02062-9106, U.S.A.
or otherwise under any patent or patent rights of Analog Devices. Trademarks and Tel: 781.329.4700 www.analog.com
registered trademarks are the property of their respective owners. Fax: 781.326.8703 © 2004 Analog Devices, Inc. All rights reserved. Rev. G | Page 2 of 20
AD620 AD620
AD620A AD620B AD620S1
SPECIFICATIONS Parameter Conditions Min Typ Max Min Typ Max Min Typ Max Unit
Typical @ 25°C, VS = ±15 V, and RL = 2 kΩ, unless otherwise noted. Common-Mode Rejection
Table 1. Ratio DC to 60 Hz with
AD620A AD620B AD620S1 1 kΩ Source Imbalance VCM = 0 V to ± 10 V
Parameter Conditions Min Typ Max Min Typ Max Min Typ Max Unit G=1 73 90 80 90 73 90 dB
GAIN G = 1 + (49.4 kΩ/RG) G = 10 93 110 100 110 93 110 dB
Gain Range 1 10,000 1 10,000 1 10,000 G = 100 110 130 120 130 110 130 dB
Gain Error2 VOUT = ±10 V G = 1000 110 130 120 130 110 130 dB
G=1 0.03 0.10 0.01 0.02 0.03 0.10 % OUTPUT
G = 10 0.15 0.30 0.10 0.15 0.15 0.30 % Output Swing RL = 10 kΩ
G = 100 0.15 0.30 0.10 0.15 0.15 0.30 % VS = ±2.3 V −VS + +VS − 1.2 −VS + 1.1 +VS − 1.2 −VS + 1.1 +VS − 1.2 V
G = 1000 0.40 0.70 0.35 0.50 0.40 0.70 % to ± 5 V 1.1
Nonlinearity VOUT = −10 V to +10 V Overtemperature −VS + 1.4 +VS − 1.3 −VS + 1.4 +VS − 1.3 −VS + 1.6 +VS − 1.3 V
G = 1–1000 RL = 10 kΩ 10 40 10 40 10 40 ppm VS = ±5 V −VS + 1.2 +VS − 1.4 −VS + 1.2 +VS − 1.4 −VS + 1.2 +VS − 1.4 V
G = 1–100 RL = 2 kΩ 10 95 10 95 10 95 ppm to ± 18 V
Gain vs. Temperature Overtemperature −VS + 1.6 +VS – 1.5 −VS + 1.6 +VS – 1.5 –VS + 2.3 +VS – 1.5 V
G=1 10 10 10 ppm/°C Short Circuit Current ±18 ±18 ±18 mA
Gain >12 −50 −50 −50 ppm/°C DYNAMIC RESPONSE
VOLTAGE OFFSET (Total RTI Error = VOSI + VOSO/G) Small Signal –3 dB Bandwidth
Input Offset, VOSI VS = ±5 V 30 125 15 50 30 125 µV G=1 1000 1000 1000 kHz
to ± 15 V G = 10 800 800 800 kHz
Overtemperature VS = ±5 V 185 85 225 µV G = 100 120 120 120 kHz
to ± 15 V G = 1000 12 12 12 kHz
Average TC VS = ±5 V 0.3 1.0 0.1 0.6 0.3 1.0 µV/°C Slew Rate 0.75 1.2 0.75 1.2 0.75 1.2 V/µs
to ± 15 V Settling Time to 0.01% 10 V Step
Output Offset, VOSO VS = ±15 V 400 1000 200 500 400 1000 µV G = 1–100 15 15 15 µs
VS = ± 5 V 1500 750 1500 µV G = 1000 150 150 150 µs
Overtemperature VS = ±5 V 2000 1000 2000 µV NOISE
to ± 15 V
Voltage Noise, 1 kHz 2
Average TC VS = ±5 V 5.0 15 2.5 7.0 5.0 15 µV/°C Total RTI Noise (e ni ) (e / G)2 no
1
Specification is for device in free air:
8-Lead Plastic Package: θJA = 95°C
8-Lead CERDIP Package: θJA = 110°C
8-Lead SOIC Package: θJA = 155°C
00775-0-004
20
–0.5
00775-0-014
PERCENTAGE OF UNITS
10
0 –2.0
–80 –40 0 40 80
Figure 11. Current Noise Spectral Density vs. Frequency Figure 14. 0.1 Hz to 10 Hz Current Noise, 5 pA/Div
–75 –25 25 75 125 175
TEMPERATURE (qC)
00775-0-008
INPUT OFFSET VOLTAGE (PV)
00775-0-005
Figure 5. Typical Distribution of Input Offset Voltage Figure 8. Input Bias Current vs. Temperature
100,000
50 2.0
40 10,000
1.5
FET INPUT
30 IN-AMP
1000
1.0
20
PERCENTAGE OF UNITS
0.5
10
00775-0-012
TIME (1 SEC/DIV) 10
0 0 1k 10k 100k 1M 10M
–1200 –600 0 600 1200 0 1 2 3 4 5
00775-0-015
00775-0-009
INPUT BIAS CURRENT (pA)
00775-0-006
Figure 6. Typical Distribution of Input Bias Current Figure 9. Change in Input Offset Voltage vs. Warm-Up Time Figure 12. 0.1 Hz to 10 Hz RTI Voltage Noise (G = 1) Figure 15. Total Drift vs. Source Resistance
50 1000
140 G = 1000
100
G = 100
30 120
GAIN = 10
G = 10
100
20 G=1
80
10
PERCENTAGE OF UNITS
CMR (dB)
60
GAIN = 1000 40
BW LIMIT
0 1
–400 –200 0 200 400 20
1 10 100 1k 10k 100k
FREQUENCY (Hz)
00775-0-010
00775-0-007
0
00775-0-013
Figure 13. 0.1 Hz to 10 Hz RTI Voltage Noise (G = 1000) Figure 16. Typical CMR vs. Frequency, RTI, Zero to 1 kΩ Source Imbalance
PSR (dB)
80
10
G = 10
BW LIMIT
10
60
20 0 0
0.1 1 10 100 1k 10k 100k 1M 1k 10k 100k 1M 0 100 1k 10k
00775-0-023
FREQUENCY (Hz)
00775-0-020
00775-0-017
FREQUENCY (Hz) LOAD RESISTANCE (:
Figure 23. Output Voltage Swing vs. Load Resistance Figure 26. Large Signal Response and Settling Time, G = 10 (0.5 mV = 0.01%)
Figure 17. Positive PSR vs. Frequency, RTI (G = 1−1000) Figure 20. Large Signal Frequency Response
160 –0.5
.... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ....
140 –1.0
120 –1.5
100
G = 1000
PSR (dB)
80 +1.5
G = 100
60 +1.0 .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ....
20 –VS +0.0
0.1 1 10 100 1k 10k 100k 1M 0 5 10 15 20
00775-0-018
FREQUENCY (Hz) SUPPLY VOLTAGE ± Volts
00775-0-021
Figure 24. Large Signal Pulse Response and Settling Time Figure 27. Small Signal Response, G = 10, RL = 2 kΩ, CL = 100 pF
Figure 18. Negative PSR vs. Frequency, RTI (G = 1−1000) Figure 21. Input Voltage Range vs. Supply Voltage, G = 1 G = 1 (0.5 mV = 0.01%)
–0.5
.... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ....
RL = 10k:
100 –1.0
RL = 2k:
–1.5
10
GAIN (V/V)
+1.5
RL = 2k:
1 +1.0 .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ....
00775-0-019
Figure 25. Small Signal Response, G = 1, RL = 2 kΩ, CL = 100 pF Figure 28. Large Signal Response and Settling Time, G = 100 (0.5 mV = 0.01%)
Figure 19. Gain vs. Frequency Figure 22. Output Voltage Swing vs. Supply Voltage, G = 10
AD620 6
00775-0-035
00775-0-029
0 –VS
0 5 10 15 20
00775-0-037
00775-0-032
Figure 35. Gain Nonlinearity, G = 100, RL = 10 kΩ
Figure 29. Small Signal Pulse Response, G = 100, RL = 2 kΩ, CL = 100 pF Figure 32. Settling Time vs. Step Size (G = 1) (100 µV = 10 ppm)
Figure 37. Settling Time Test Circuit
1000
100
10
00775-0-030
1
1 10 100 1000
00775-0-033
GAIN Figure 36. Gain Nonlinearity, G = 1000, RL = 10 kΩ
(1 mV = 100 ppm)
Figure 30. Large Signal Response and Settling Time, Figure 33. Settling Time to 0.01% vs. Gain, for a 10 V Step
G = 1000 (0.5 mV = 0.01% )
.... .... .... .... .... .... .... .... ........ .... .... .... .... .... .... .... .... .... ....
.... .... .... .... .... .... .... .... ........ .... .... .... .... .... .... .... .... .... ....
00775-0-034
00775-0-031
Figure 31. Small Signal Pulse Response, G = 1000, RL = 2 kΩ, CL = 100 pF Figure 34. Gain Nonlinearity, G = 1, RL = 10 kΩ (10 µV = 1 ppm)
00775-0-038
–VS
transistors. This has three important advantages: (a) Open-loop
00775-0-040
00775-0-039
The AD620 is a monolithic instrumentation amplifier based on gain related errors. (b) The gain-bandwidth product
a modification of the classic three op amp approach. Absolute (determined by C1 and C2 and the preamp transconductance)
value trimming allows the user to program gain accurately increases with programmed gain, thus optimizing frequency Figure 39. Make vs. Buy
(to 0.15% at G = 100) with only one resistor. Monolithic response. (c) The input voltage noise is reduced to a value of
construction and laser wafer trimming allow the tight matching 9 nV/√Hz, determined mainly by the collector current and base
and tracking of circuit components, thus ensuring the high level resistance of the input devices.
of performance inherent in this circuit.
The internal gain resistors, R1 and R2, are trimmed to an Table 3. Make vs. Buy Error Budget
absolute value of 24.7 kΩ, allowing the gain to be programmed Error, ppm of Full Scale
accurately with a single external resistor. Error Source AD620 Circuit Calculation “Homebrew” Circuit Calculation AD620 Homebrew
ABSOLUTE ACCURACY at TA = 25°C
The gain equation is then Input Offset Voltage, µV 125 µV/20 mV (150 µV × √2)/20 mV 6,250 10,607
Output Offset Voltage, µV 1000 µV/100 mV/20 mV ((150 µV × 2)/100)/20 mV 500 150
49.4 k:
G 1 Input Offset Current, nA 2 nA ×350 Ω/20 mV (6 nA ×350 Ω)/20 mV 18 53
RG CMR, dB 110 dB(3.16 ppm) ×5 V/20 mV (0.02% Match × 5 V)/20 mV/100 791 500
00775-0-042
RG AD620 6
R1 The reference terminal potential defines the zero output voltage
Figure 40. A Pressure Monitor Circuit that Operates on a 5 V Single Supply 1 5
and is especially useful when the load does not share a precise
VIN– 2 4 I
L ground with the rest of the system. It provides a direct means of
–VS injecting a precise offset to the output, with an allowable range
Pressure Measurement Medical ECG AD705
of 2 V within the supply voltages. Parasitic resistance should be
Although useful in many bridge applications, such as weigh The low current noise of the AD620 allows its use in ECG Vx [(V IN+ ) – (V IN– )] G kept to a minimum for optimum CMR.
I L= =
scales, the AD620 is especially suitable for higher resistance monitors (Figure 41) where high source resistances of 1 MΩ or R1 R1
LOAD
pressure sensors powered at lower voltages where small size and higher are not uncommon. The AD620’s low power, low supply INPUT PROTECTION
00775-0-044
low power become more significant. voltage requirements, and space-saving 8-lead mini-DIP and The AD620 features 400 Ω of series thin film resistance at its
Figure 42. Precision Voltage-to-Current Converter (Operates on 1.8 mA, ±3 V)
SOIC package offerings make it an excellent choice for battery- inputs and will safely withstand input overloads of up to ±15 V
Figure 40 shows a 3 kΩ pressure transducer bridge powered powered data recorders. or ±60 mA for several hours. This is true for all gains and power
from 5 V. In such a circuit, the bridge consumes only 1.7 mA. GAIN SELECTION on and off, which is particularly important since the signal
Adding the AD620 and a buffered voltage divider allows the Furthermore, the low bias currents and low current noise,
The AD620’s gain is resistor-programmed by RG, or more source and amplifier may be powered separately. For longer
signal to be conditioned for only 3.8 mA of total supply current. coupled with the low voltage noise of the AD620, improve the
precisely, by whatever impedance appears between Pins 1 and 8. time periods, the current should not exceed 6 mA
dynamic range for better performance.
Small size and low cost make the AD620 especially attractive for The AD620 is designed to offer accurate gains using 0.1% to 1% (IIN ≤ VIN/400 Ω). For input overloads beyond the supplies,
voltage output pressure transducers. Since it delivers low noise The value of capacitor C1 is chosen to maintain stability of resistors. Table 4 shows required values of RG for various gains. clamping the inputs to the supplies (using a low leakage diode
and drift, it will also serve applications such as diagnostic the right leg drive loop. Proper safeguards, such as isolation, Note that for G = 1, the RG pins are unconnected (RG = ∞). For such as an FD333) will reduce the required resistance, yielding
noninvasive blood pressure measurement. must be added to this circuit to protect the patient from any arbitrary gain, RG can be calculated by using the formula: lower noise.
possible harm.
49.4 k: RF INTERFERENCE
RG
G 1 All instrumentation amplifiers rectify small out of band signals.
The disturbance may appear as a small dc voltage offset. High
To minimize gain error, avoid high parasitic resistance in series frequency signals can be filtered with a low pass R-C network
+3V
PATIENT/CIRCUIT with RG; to minimize gain drift, RG should have a low TC—less
PROTECTION/ISOLATION placed at the input of the instrumentation amplifier. Figure 43
than 10 ppm/°C—for the best performance. demonstrates such a configuration. The filter limits the input
signal according to the following relationship:
Table 4. Required Values of Gain Resistors
1% Std Table Calculated 0.1% Std Table Calculated 1
R1 R3 FilterFreq DIFF
C1 24.9k: 0.03Hz
10k: RG HIGH- OUTPUT Value of RG(Ω) Gain Value of RG(Ω ) Gain 2 SR(2C D C C )
8.25k: AD620A PASS G = 143 1V/mV
R4 R2 G=7 FILTER 49.9 k 1.990 49.3 k 2.002
1M: 24.9k: 1
OUTPUT
12.4 k 4.984 12.4 k 4.984 FilterFreq CM
AMPLIFIER 5.49 k 9.998 5.49 k 9.998 2 SRC C
2.61 k 19.93 2.61 k 19.93
AD705J where CD ≥10CC.
1.00 k 50.40 1.01 k 49.91
499 100.0 499 100.0 CD affects the difference signal. CC affects the common-mode
–3V
249 199.4 249 199.4 signal. Any mismatch in R × CC will degrade the AD620’s
100 495.0 98.8 501.0
00775-0-043
00775-0-046
–VS
00775-0-045
–15V
– INPUT GROUND
COMMON-MODE REJECTION Figure 48. Ground Returns for Bias Currents with Thermocouple Inputs
+VS
Instrumentation amplifiers, such as the AD620, offer high – INPUT
CMR, which is a measure of the change in output voltage when RG AD620 VOUT
both inputs are changed by equal amounts. These specifications RG
+VS
100: 2
are usually given for a full-range input voltage change and a AD548 AD620 VOUT LOAD – INPUT
RG
specified source imbalance. 2
REFERENCE + INPUT REFERENCE
For optimal CMR, the reference terminal should be tied to a + INPUT –VS
–VS RG AD620 VOUT
00775-0-047
low impedance point, and differences in capacitance and
resistance should be kept to a minimum between the two TO POWER
Figure 45. Common-Mode Shield Driver SUPPLY LOAD
00775-0-049
GROUND
inputs. In many applications, shielded cables are used to
minimize noise; for best CMR over frequency, the shield GROUNDING + INPUT REFERENCE
Figure 47. Ground Returns for Bias Currents with Transformer-Coupled Inputs
should be properly driven. Figure 44 and Figure 45 show active Since the AD620 output voltage is developed with respect to the 100k : 100k: –VS
data guards that are configured to improve ac common-mode potential on the reference terminal, it can solve many
rejections by “bootstrapping” the capacitances of input cable grounding problems by simply tying the REF pin to the TO POWER
SUPPLY
00775-0-051
shields, thus minimizing the capacitance mismatch between the appropriate “local ground.” GROUND
inputs.
To isolate low level analog signals from a noisy digital Figure 49. Ground Returns for Bias Currents with AC-Coupled Inputs
environment, many data-acquisition components have separate
analog and digital ground pins (Figure 46). It would be
convenient to use a single ground line; however, current
through ground wires and PC runs of the circuit card can cause
hundreds of millivolts of error. Therefore, separate ground
returns should be provided to minimize the current flow from
the sensitive points to the system ground. These ground returns
must be tied together at some point, usually best at the ADC
package shown in Figure 46.
0.1P F 0.1P F
1P F 1P F 1P F
+
AD620 DIGITAL
AD585 AD574A DATA
S/H ADC OUTPUT
00775-0-048
OUTLINE DIMENSIONS
0.400 (10.16)
0.365 (9.27)
ORDERING GUIDE
0.355 (9.02) 5.00 (0.1968) Model Temperature Range Package Option1
4.80 (0.1890)
8 5 0.280 (7.11) AD620AN −40°C to +85°C N-8
0.250 (6.35) 8 5 AD620ANZ2 −40°C to +85°C N-8
1 0.240 (6.10)
4 4.00 (0.1574) 6.20 (0.2440)
0.325 (8.26)
0.310 (7.87) 3.80 (0.1497) 1 4 5.80 (0.2284) AD620BN −40°C to +85°C N-8
PIN 1
0.100 (2.54) 0.300 (7.62) AD620BNZ2 −40°C to +85°C N-8
BSC 0.060 (1.52) 0.195 (4.95)
0.210 MAX AD620AR −40°C to +85°C R-8
(5.33) 0.130 (3.30)
1.27 (0.0500) 0.50 (0.0196)
MAX 0.115 (2.92) BSC 1.75 (0.0688) u 45°
0.015 0.25 (0.0099) AD620ARZ2 −40°C to +85°C R-8
0.150 (3.81) (0.38)0.015 (0.38) 1.35 (0.0532)
MIN 0.25 (0.0098)
0.130 (3.30) GAUGE AD620AR-REEL −40°C to +85°C 13" REEL
0.115 (2.92) PLANE 0.014 (0.36) 0.10 (0.0040)
SEATING
PLANE 0.010 (0.25) 8° AD620ARZ-REEL2 −40°C to +85°C 13" REEL
0.51 (0.0201)
0.022 (0.56) 0.008 (0.20) COPLANARITY 0.25 (0.0098) 0° 1.27 (0.0500)
0.005 (0.13) 0.430 (10.92) SEATING 0.31 (0.0122) AD620AR-REEL7 −40°C to +85°C 7" REEL
0.018 (0.46) MAX 0.10 0.17 (0.0067) 0.40 (0.0157)
MIN PLANE
0.014 (0.36) AD620ARZ-REEL72 −40°C to +85°C 7" REEL
0.070 (1.78) COMPLIANT TO JEDEC STANDARDS MS-012AA
CONTROLLING DIMENSIONS ARE IN MILLIMETERS; INCH DIMENSIONS
AD620BR −40°C to +85°C R-8
0.060 (1.52)
0.045 (1.14) (IN PARENTHESES) ARE ROUNDED-OFF MILLIMETER EQUIVALENTS FOR AD620BRZ2 −40°C to +85°C R-8
REFERENCE ONLY AND ARE NOT APPROPRIATE FOR USE IN DESIGN
COMPLIANT TO JEDEC STANDARDS MS-001-BA AD620BR-REEL −40°C to +85°C 13" REEL
CONTROLLING DIMENSIONS ARE IN INCHES; MILLIMETER DIMENSIONS Figure 52. 8-Lead Standard Small Outline Package [SOIC]
(IN PARENTHESES) ARE ROUNDED-OFF INCH EQUIVALENTS FOR
AD620BRZ-RL2 −40°C to +85°C 13" REEL
REFERENCE ONLY AND ARE NOT APPROPRIATE FOR USE IN DESIGN.
CORNER LEADS MAY BE CONFIGURED AS WHOLE OR HALF LEADS.
Narrow Body (R-8) AD620BR-REEL7 −40°C to +85°C 7" REEL
Dimensions shown in millimeters and (inches) AD620BRZ-R72 −40°C to +85°C 7" REEL
Figure 50. 8-Lead Plastic Dual In-Line Package [PDIP]
AD620ACHIPS −40°C to +85°C Die Form
Narrow Body (N-8).
AD620SQ/883B −55°C to +125°C Q-8
Dimensions shown in inches and (millimeters)
0.310 (7.87)
PIN 1 0.220 (5.59)
1 4
REF01/REF02
REF01/REF02
suitable for a wide variety of temperature-sensing and
control applications. For new designs, refer to the ELECTRICAL CHARACTERISTICS—REF01E/REF01H
MAX6035 or MAX6143 data sheets. (VIN = +15V, TA = +25°C, unless otherwise noted.)
REF01E REF01H
Ordering Information PARAMETER SYMBOL CONDITIONS UNITS
MIN TYP MAX MIN TYP MAX
MAX TEMPCO INITIAL ERROR PKG Output Voltage VO IL = 0 9.97 10.00 10.03 9.95 10.00 10.05 V
PART TEMP RANGE PIN-PACKAGE
(ppm/°C) (mV) CODE Output Adjustment Range ∆Vtrim RP = 10kΩ ±3.0 ±6.0 ±3.0 ±6.0 %
REF01EP 0°C to +70°C 8.5 ±30 8 Plastic DIP P8-2 Output Voltage Noise enP-P 0.1Hz to 10Hz (Note 1) 20 30 20 30 µVP-P
REF01EP+ 0°C to +70°C 8.5 ±30 8 Plastic DIP P8-2 Line Regulation VIN = 13V to 33V (Note 2) 0.006 0.010 0.006 0.010 %/V
REF01HP 0°C to +70°C 25 ±50 8 Plastic DIP P8-2 Load Regulation IL = 0 to 10mA (Note 2) 0.005 0.008 0.006 0.010 %/mA
REF01HP+ 0°C to +70°C 25 ±50 8 Plastic DIP P8-2 Turn-On Settling Time tON To ±0.1% of final value 400 400 µs
REF01HSA 0°C to +70°C 25 ±50 8 SO S8-2 Quiescent Supply Current ISY No load 1.0 1.4 1.0 1.4 mA
For pricing, delivery, and ordering information, please contact Maxim/Dallas Direct! at
1-888-629-4642, or visit Maxim’s website at www.maxim-ic.com.
+5V, +10V Precision +5V, +10V Precision
Voltage References Voltage References
ELECTRICAL CHARACTERISTICS—REF01C ABSOLUTE MAXIMUM RATINGS–REF02
(VIN = +15V, TA = +25°C, IL = 0mA, unless otherwise noted.) Input Voltage Operating Temperature Range
REF02, E, H .........................................................................40V REF02E, REF02H .................................................0°C to +70°C
REF01C
REF02C ...............................................................................30V REF02C (except REF02CESA) ............................0°C to +70°C
PARAMETER SYMBOL CONDITIONS UNITS Continuous Power Dissipation REF02CESA ......................................................-40°C to +85°C
MIN TYP MAX Plastic Dip (P) (derate at 5.6mW/°C above +36°C) .....500mW Output Short-Circuit Duration
Output Voltage VO IL = 0mA 9.90 10.00 10.10 V Small Outline (S) (derate at 5.0mW/°C above +55°C) ..300mW (to ground or VIN) .......................................................Indefinite
Output Adjustment Range ∆Vtrim RP = 10kΩ ±2.7 ±6.0 %
Storage Temperature Range .............................-65°C to +150°C Lead Temperature (soldering, 60s) .................................+300°C
Output Voltage Noise enP-P 0.1Hz to 10Hz (Note 1) 25 35 µVP-P Stresses beyond those listed under “Absolute Maximum Ratings” may cause permanent damage to the device. These are stress ratings only, and functional
operation of the device at these or any other conditions beyond those indicated in the operational sections of the specifications is not implied. Exposure to
Line Regulation VIN = 13V to 30V (Note 2) 0.009 0.015 %/V
absolute maximum rating conditions for extended periods may affect device reliability.
IL = 0 to 8mA 0.006 0.015
Load Regulation (Note 2) %/mA
IL = 0 to 4mA 0.006 0.015
REF01/REF02
REF01/REF02
Turn-On Settling Time tON To ±0.1% of final value 400 µs ELECTRICAL CHARACTERISTICS—REF02E/REF02H
Quiescent Supply Current ISY No load 1.0 1.6 mA (VIN = +15V, TA = +25°C, unless otherwise noted.)
Load Current IL To specified output voltage tolerance 8 21 mA REF02E REF02H
PARAMETER SYMBOL CONDITIONS UNITS
Sink Current IS To specified output voltage tolerance 0.2 0.5 mA MIN TYP MAX MIN TYP MAX
Short-Circuit Current ISC VO = 0V 30 mA Output Voltage VO IL = 0 4.985 5.000 5.015 4.975 5.000 5.025 V
Output Adjustment Range ∆Vtrim RP = 10kΩ ±3 ±6 ±3 ±6 %
ELECTRICAL CHARACTERISTICS—REF01C Output Voltage Noise enP-P 0.1Hz to 10Hz (Note 5) 10 15 10 15 µVP-P
(VIN = +15V, TA = TMIN to TMAX, unless otherwise noted.) Line Regulation VIN = 8V to 33V (Note 6) 0.006 0.010 0.006 0.010 %/V
REF01C Load Regulation IL = 0 to 10mA (Note 6) 0.005 0.010 0.006 0.010 %/mA
PARAMETER SYMBOL CONDITIONS UNITS
MIN TYP MAX Turn-On Settling Time tON To ±0.1% of final value 230 230 µs
Output Voltage Change with Quiescent Supply Current ISY No load 1.0 1.4 1.0 1.4 mA
∆VOT (Note 3) 0.14 0.45 %
Temperature Load Current IL To specified output voltage tolerance 10 21 10 21 mA
Output Voltage Temperature Sink Current IS To specified output voltage tolerance 0.3 0.5 0.3 0.5 mA
TCVO (Note 4) 20 65 ppm/°C
Coefficient Short-Circuit Current ISC VO = 0V 30 30 mA
Change in VO Temperature Temperature Voltage Output VT (Note 7) 630 630 mV
RP = 10kΩ 0.7 ppm/%
Coefficient with Output Adjustment
_______________________________________________________________________________________ 3 4 _______________________________________________________________________________________
+5V, +10V Precision +5V, +10V Precision
Voltage References Voltage References
ELECTRICAL CHARACTERISTICS—REF02E/REF02H (continued) ELECTRICAL CHARACTERISTICS–REF02 (continued)
(VIN = +15V, 0°C ≤ TA ≤ +70°C for REF02E and REF02H, IL = 0mA, unless otherwise noted.) (VIN = +15V, TA = TMIN to TMAX, IL = 0mA, unless otherwise noted.)
REF01/REF02
REF01/REF02
REF02C
PARAMETER SYMBOL CONDITIONS UNITS
MIN TYP MAX
Output Voltage VO IL = 0mA 4.950 5.000 5.050 V
Output Adjustment
Output Adjustment Range ∆Vtrim RP = 10kΩ ±2.7 ±6.0 % 880
The REF02 trim terminal can be used to adjust the out-
Output Voltage Noise enP-P 0.1Hz to 10Hz (Note 5) 12 18 µVP-P 830
put voltage over a 5V ±300mV range. This feature
Line Regulation VIN = 8V to 30V (Note 6) 0.009 0.015 %/V 780
allows the system designer to trim system errors by set-
IL = 0 to 8mA 0.006 0.015 ting the reference to a voltage other than 5V (refer to 730
Load Regulation (Note 6) %/mA
IL = 0 to 4mA the Typical Operating Circuit). 680
Turn-On Settling Time tON To ±0.1% of final value 230 µs Adjustment of the output does not significantly affect 630
Quiescent Supply Current ISY No load 1.0 1.6 mA the temperature performance of the device. Typically, 580
TEMP VOLTAGE OUTPUT (mV)
Load Current IL To specified output voltage tolerance 8 21 mA the temperature coefficient change is 0.7ppm/°C for 530
Sink Current IS To specified output voltage tolerance 0.2 0.5 mA
100mV of output adjustment. 480
Short-Circuit Current ISC VO = 0V 30 mA Temperature Voltage Output 430
-60 -40 -20 0 20 40 60 80 100 120 140
Temperature Voltage Output VT (Note 7) 630 mV The REF02 provides a temperature-dependent output TEMPERATURE (°C)
voltage on the TEMP pin. This voltage is proportional to
the absolute temperature, and has a scale factor of Figure 1. REF02 Temperature/Voltage Output vs. Temperature
approximately 2.1mV/°C (Figure 1).
ELECTRICAL CHARACTERISTICS—REF02C Output Voltage = 2.1(T + 273)mV
(VIN = +15V, TA = TMIN to TMAX, IL = 0mA, unless otherwise noted.)
where T = Temperature in °C.
REF02C
PARAMETER SYMBOL CONDITIONS UNITS
MIN TYP MAX
Change in VO Temperature
Coefficient with Output RP = 10kΩ 0.7 ppm/%
Adjustment
_______________________________________________________________________________________ 5 6 _______________________________________________________________________________________
+5V, +10V Precision +5V, +10V Precision
Voltage References Voltage References
Typical Operating Characteristics Typical Applications
(TA = +25°C, unless otherwise noted.)
1.1mA +15V
2 2
REF01 OUTPUT WIDEBAND REF02 OUTPUT WIDEBAND
VIN 6 +10V
LINE REGULATION NOISE vs. BANDWIDTH NOISE vs. BANDWIDTH VIN VO
vs. FREQUENCY (0.1Hz TO FREQUENCY INDICATED) (0.1Hz TO FREQUENCY INDICATED) 6
VO +
76 10,000 10,000
VIN = 15V VIN = 15V 10kΩ
VIN = 15V REF01
66 TA = +25°C TA = +25°C TA = +25°C 9V 10kΩ
REF01 5
REF01/02 TOC01
REF01/02 TOC03
TRIM
REF01/02 TOC02
5 GND
56 100kΩ 10.000V +15V
1000 TRIM 4
1000
46 GND 5kΩ OP-07 -10V
9V
4 -15V
-
REF01/REF02
REF01/REF02
36
100 100
REF01/02 TOC06
R
REF01/02 TOC04
REF01/02 TOC05
SHORT-CIRCUIT TRIM
1.2 1.2
25 PROTECTION GND *
GND
500mW MAXIMUM 1.1 1.1 4
20 DISSIPATION 4 200kΩ
1.0 1.0 IOUT
15 -15V
0.9 0.9 *UP TO 10 FEET OF SHIELDED
4-CONDUCTOR CABLE.
10 0.8
0.8
REF01/02 TOC09
REF01/02 TOC07
REF01/02 TOC08
0.025 T A = TA =
20 1.1 +25°C +75°C
0.020
15 1.0
0.015
10 0.9
0.010
_______________________________________________________________________________________ 7 8 _______________________________________________________________________________________
+5V, +10V Precision
Voltage References
Pin Configurations
TOP VIEW
REF01/REF02
DIP SO
Maxim cannot assume responsibility for use of any circuitry other than circuitry entirely embodied in a Maxim product. No circuit patent licenses are
implied. Maxim reserves the right to change the circuitry and specifications without notice at any time.
Maxim Integrated Products, 120 San Gabriel Drive, Sunnyvale, CA 94086 408-737-7600 _____________________ 9
© 2007 Maxim Integrated Products is a registered trademark of Maxim Integrated Products, Inc.
D-18 Edit Date: February 12, 2013
Appendix E
MapleSim Tutorials
MapleSim is a simulation environment brought to you by the folks at MapleSoft. It is available on many
computers at Ryerson University, including the computers in the ELE604 labs. The following is a pair of short
tutorials. The first is on how to set up simple electrical system and to produce the underlying characteristic
equations. The second shows you how to create a BJT-driven LED.
E-1
MapleSim
Simple
Sine-Driven
Resistor
Tutorial
(v.
1.1)
James
A.
Smith
Overview
System
modeling
and
simulation
is
an
important
process
for
engineering.
It
permits
you
to
examine
the
effects
that
input
variables
and
component
parameters
have
on
the
behaviour
of
the
system.
How
does
a
civil
engineer
know
that
the
bridge
she
is
designing
will
be
able
to
carry
200
passenger
cars?
By
careful
modeling
of
the
bridge
structure
and
simulation
of
that
model
under
different
test
conditions.
In
the
same
way,
an
electrical
engineer
should
simulate
a
circuit
to
ensure
that
it
can,
for
example,
handle
particular
voltage
and
current
levels
(for
safety)
or
to
ensure
that
the
LED
will
shine
brightly
enough
(in
a
user
interface).
Here,
you
will
drive
a
resistor
with
an
oscillating
voltage
input
and
will
measure
the
resulting
current
flow.
While
it
is
a
trivial
circuit
to
understand
intuitively,
the
true
objective
is
to
introduce
you
to
a
powerful
modeling
and
simulation
tool:
MapleSim
by
MapleSoft.
In
later
tutorials
you
will
model
more
complex
systems.
The
intended
audience
for
this
tutorial
is
third
year
electrical
engineering
undergraduate
students
with
little
to
no
background
in
Maple
or
MapleSim,
but
with
intermediate
background
in
engineering
computer
usage.
Familiarity
with
tools
such
as
Mathworks
Simulink
or
LTSpice
is
an
asset
but
is
not
required.
Learning
Objectives
The
learning
objective
is
to
become
familiar
with
MapleSim
as
a
tool
for
electrical
modeling.
Success
Criteria
The
student
is
to
model
a
sinusoidally
driven
resistor,
creating
documentation
to
demonstrate
that
the
schematic
was
drawn,
current
and
voltage
were
plotted
and
system
equations
generated.
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc
MapleSim
Simple
Sine-Driven
Resistor
Tutorial
(v.
1.1)
James
A.
Smith
More
Resources
MapleSim
User
Guide
by
MapleSoft.
Available
online:
http://www.maplesoft.com/support/help/MapleSim/view.aspx?path=Maple
SimUserGuide%2fChapter05#extractingEquations.
Background
Information
Here,
you
will
drive
a
resistor
with
an
oscillating
voltage
input
and
will
measure
the
resulting
current
flow.
While
it
is
a
trivial
circuit
to
understand
intuitively,
the
true
objective
is
to
introduce
you
to
a
powerful
modeling
and
simulation
tool:
MapleSim
by
MapleSoft.
In
later
tutorials
you
will
model
more
complex
systems.
In
this
tutorial
you
will
be
using
three
different
components
in
this
tutorial
(four,
if
you
count
the
connecting
wires
between
parts).
Exploration
Step
1:
Open
MapleSim
The
first
step
is
to
ensure
that
you
have
access
to
MapleSim
using
either
a
student
licence
or
one
of
the
Electrical
and
Computer
Engineering
Department
lab
computers
with
MapleSim
installed.
Look
for
the
icon
shown
in
Figure
1.
Figure
1
The
MapleSim
icon
(version
4.5),
as
seen
on
a
Macintosh.
Windows
and
Linux
machines
have
similar
icons.
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc
MapleSim
Simple
Sine-Driven
Resistor
Tutorial
(v.
1.1)
James
A.
Smith
Figure
2
The
MapleSim
schematic,
including
a
sinusoidal
input
voltage
(far
left),
a
dual
current
and
voltage
probe
(middle
left),
resistor
(middle)
and
ground
(bottom
right).
You
will
need
to
select
the
source,
the
resistor
and
the
ground
from
the
menu
on
the
left
side
of
the
MapleSim
Window,
as
shown
in
Figure
3.
Drag
them
into
the
main
window.
You’ll
connect
them
together
shortly.
In
the
mean
time,
place
them
roughly
as
you
see
in
Figure
2.
Figure
3
Drag
and
drop
the
circuit
elements
from
this
menu.
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc
MapleSim
Simple
Sine-Driven
Resistor
Tutorial
(v.
1.1)
James
A.
Smith
Beware!
The
sinusoid
source
appears
with
the
positive
(“+”)
port
on
the
left
and
the
negative
(“-‐”)
port
on
the
right
when
you
insert
it.
Rotate
it
(using
CTRL-R
in
Windows
or
-R
on
a
Mac)
so
that
it
appears
as
in
Figure
2.
[Hint:
if
the
symbols
appear
too
small,
use
the
Zoom
feature
in
the
View
menu
to
take
a
close
look.]
You
now
need
to
“wire”
the
parts.
Do
this
by
navigating
the
mouse
cursor
near
the
end
of
one
of
the
parts
(e.g.
the
left
port
on
the
resistor,
as
in
Figure
4).
You’ll
see
the
port
become
a
green
circle.
Left-‐click
on
it
to
enable
the
“wire”.
Then,
move
your
cursor
to
the
right-‐
hand
side
port
of
the
sinusoid
generator.
When
you
encounter
that
port
another
green
circle
will
appear,
as
in
Figure
5.
Click
again
and
a
wire
will
“bond”
to
it.
Congratulations!
You
now
have
a
connection
between
the
resistor
and
the
sinusoid
generator.
Figure
4
Select
the
resistor's
port.
Figure
5
Wire
the
resistor
to
the
generator.
Continue attaching components until you have the circuit shown in Figure 6.
Figure
6
The
generator,
resistor
and
ground
connected
together.
Next,
adjust
the
parameters
of
each
component.
Do
this
by
left-‐clicking
directly
on
the
component.
For
instance,
if
you
do
this
to
the
sinusoid
generator
a
box
will
appear,
as
shown
in
Figure
7.
You’ll
also
notice
that
the
parameters
appear
on
the
right-‐hand
side
of
the
MapleSim
window.
Any
values
in
grey
are
default
/
guessed
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc
MapleSim
Simple
Sine-Driven
Resistor
Tutorial
(v.
1.1)
James
A.
Smith
parameters.
You
are
likely
to
want
to
change
these
when
you
make
your
own
simulations,
but
the
defaults
are
okay
for
now.
Figure
7
You
will
need
to
adjust
the
parameters
of
each
component.
Here,
we
examine
the
parameters
for
the
sinusoidal
generator.
The
peak
amplitude
(Vh)
is
1
volt,
frequency
(f)
is
1
Hz,
the
DC
bias
(Vo)
is
0
Volts.
Set
the
sinusoid
generator
to
have
a
1
volt
peak
amplitude,
no
phase
shift,
1
Hz
frequency
and
no
voltage
or
time
offset.
Set
the
resistor
to
have
a
1
Ohm
resistance
(ignore
the
temperature
parameters
and
set
the
initial
conditions
to
“ignore”
for
both
initial
voltage
and
current
by
selecting
the
“ignore”
icon
for
each).
Figure
8
The
probe
icon.
Use
this
to
measure
characteristics
of
your
system,
like
voltage
and
current
for
electrical
systems
(it
also
works
to
measure
mechanical
characteristics
if
your
system
contains
mechanical
elements.).
Next,
you
need
to
insert
a
probe
(see
Figure
8)
in
order
to
measure
current
and
voltage
in
your
circuit.
Click
on
the
icon
to
change
your
cursor
to
a
probe.
Navigate
to
the
wire
between
the
generator
and
the
resistor.
It
will
turn
blue.
Click
on
it
and
move
the
cursor
upward.
Click
again.
The
probe
is
installed.
In
the
right-‐hand
menu,
click
on
the
“current”
checkbox.
Your
circuit
should
look
like
Figure
9.
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc
MapleSim
Simple
Sine-Driven
Resistor
Tutorial
(v.
1.1)
James
A.
Smith
Figure
9
Circuit
with
probe
for
measuring
voltage
and
current.
Figure
10
Run
the
simulation
by
clicking
on
the
blue
triangle
near
the
top
of
the
MapleSim
window.
Figure
11
You
can
monitor
progress
of
the
simulation
in
the
bottom
of
the
MapleSim
window.
When
the
simulation
is
finished
a
plot
window
will
appear,
as
shown
in
Figure
12.
This
shows
you
the
current
and
voltage,
as
measured
by
the
probe
you
inserted
earlier.
You
can
modify
the
title
and
x-‐
and
y-‐axis
labels
by
double-‐clicking
on
them.
You
can
also
export
and
print
these
plots.
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc
MapleSim
Simple
Sine-Driven
Resistor
Tutorial
(v.
1.1)
James
A.
Smith
Figure
12
The
plot
window
showing
the
voltage
and
current
as
measured
by
the
probe.
If
you
click
near,
but
not
on
the
circuit
elements
in
your
schematic
the
integration
parameters
for
the
simulation
will
appear
in
the
right-‐hand
side
of
the
MapleSim
window,
shown
in
Figure
13.
Figure
13
MapleSim
integration
parameters
for
simulation.
The
details
will
be
discussed
in
a
later
tutorial.
The
defaults
are
fine
for
this
circuit.
Figure
14
Create
an
"attachment"
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc
MapleSim
Simple
Sine-Driven
Resistor
Tutorial
(v.
1.1)
James
A.
Smith
Figure
15
Select
"equations"
for
the
attachment
Figure
16
The
Maple
"Equation
Extraction"
window.
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc
MapleSim
Tutorial
1
James
Andrew
Smith
Figure
17
Alternative
and
more
compact
instructions
can
be
found
in
the
official
online
MapleSim
User
Guide,
an
excerpt
of
which
is
shown
here.
Click
on
“Main”
in
the
Model
Diagram.
Then,
click
on
“Retrieve
System”
in
“Model
Input
from
MapleSim”.
In
the
Variable
Management
section,
change
the
Main.Probe1.i
to
Current
and
the
Main.Probe1.v
to
Voltage.1
In
the
“Model
Equations”
section
click
on
“Apply
Variables
in
Variable
Manager”.
Then
select
the
“System
Equations”
radio
button.
Three
equations
will
appear
on
a
single
line:
one
for
voltage
and
two
for
current
(opposite
signs
of
one
another),
as
shown
in
Figure
18.
Figure
18
The
three
equations
for
current
and
voltage
generated
by
the
Maple
Equation
attachment
to
the
MapleSim
model.
Note
the
sign
difference
between
the
two
current
readings,
“Current(t)”and
Probe1.p2.i(t)”
Skill
Exercises
The
following
are
exercises
to
reinforce
the
material
above
and
to
demonstrate
more
advanced
skills.
They
are
relatively
straightforward
and
can
be
attempted
independently.
the first. The signs correspond to the arrow shown on the probe “lead”.
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc
MapleSim
Tutorial
1
James
Andrew
Smith
In
the
Equation
attachment,
change
the
Probe1.p2.i
variable’s
name
to
reflect
the
fact
that
it
is
simply
the
negated
version
of
the
other
current
variable.
Modify
the
resistor
value
to
permit
more
current
to
flow.
Plot
the
results
and
then
update
the
Equation
attachment
(hint:
there
is
no
need
to
create
a
new
attachment;
simply
update
the
old
attachment.)
Communication
You
are
to
hand
a
report
document
to
your
TA,
including
a
standard
(and
signed)
FEAS
cover
sheet,
a
print-‐out
of
your
MapleSim
schematic
on
one
page,
a
print-‐out
of
your
MapleSim
plots
on
another
page
and
a
print-‐out
of
the
Maple
equation
generation
pages.
Finally,
include
a
short
writeup
(under
one
page)
outlining
your
answers
to
the
skill
exercises
listed
above.
Post-‐Tutorial
Reflection
Could
you
simulate
more
complicated
models?
Does
MapleSim
have
the
ability
to
simulate
transistors,
LEDs
and
Op
Amps?
Since
a
2n3904
BJT
operates
differently
than
a
2n3906
or
a
2n2219,
where
would
you
find
the
parameters
for
these
components?
MapleSim
can
also
be
used
to
model
mechanical
systems.
What
kind
of
components
would
you
need
to
model
an
inverted
pendulum?
What
if
you
wanted
to
attach
a
motor
to
the
pendulum?
Could
this
be
done?
Additional
References
“Principles
of
Linear
Algebra
with
Maple”
by
Kenneth
Shiskowski
and
Karl
Frinkle
(http://carmine.se.edu/kfrinkle/principlesoflinearalgebrawithmaple/
and
http://ca.wiley.com/WileyCDA/WileyTitle/productCd-‐0470637595,descCd-‐
tableOfContents.html
)
“Exploring
Chaos
and
Dynamical
Systems
with
MapleSim”
by
Stephen
Lynch.
(http://www.doc.mmu.ac.uk/STAFF/S.Lynch/cover1.html
and
http://www.maplesoft.com/company/publications/articles/view.aspx?SID=19230)
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc
MapleSim
Transistor
–
LED
Tutorial
James
A.
Smith
Introduction
Here,
you
are
to
simulate
the
turning
on-‐and-‐off
of
an
LED
in
MapleSim.
You
will
modify
the
parameters
of
the
NPN
BJT
transistor
model
included
in
MapleSim
and
will
assume
that
the
diode
included
in
MapleSim
is
sufficiently
similar
to
an
LED.
The
base
of
the
BJT
will
be
driven
by
a
stepping
voltage
source.
This
is
similar
to
how
the
9s12
microcontroller
will
turn
the
BJT
(and
therefore
the
LED)
on
and
off.
You
need
to
tune
the
values
of
the
base
and
collector
resistors
so
that
they
permit
sufficient
(but
not
excessive)
current.
It
is
assumed
that
you
have
completed
the
first
MapleSim
tutorial,
in
which
you
were
to
connect
a
resistor
to
a
sine-‐generator.
This
tutorial
is
slightly
more
complicated
than
the
previous
tutorial,
however.
Important
Details
In
this
tutorial
you
will
be
designing
the
resistor
component
values
to
permit
sufficient
current
to
drive
the
base
of
the
BJT,
as
well
as
the
LED/diode.
You
will
need
to
look
up
specifications
for
the
2n3904
BJT
as
well
as
the
LED
to
determine
what
the
maximum
currents
are
that
they
will
tolerate.
Stay
well
below
those
limits!
The
simulation
will
require
some
special
attention
to
work
correctly.
For
instance,
you
will
need
to
tune
the
transistor
parameters
slightly
(they
are
given
below).
As
well,
you
will
need
to
adjust
the
“integration”
parameters
of
the
simulation.
See
details
below.
Figure
1
Example
of
a
suitable
schematic
for
the
design.
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:transistor_led_tutorial:transistor_led_tutorial_v1.doc
MapleSim
Transistor
–
LED
Tutorial
James
A.
Smith
The
diode
can
be
set
up
to
have
a
“turn-‐on”
voltage
around
1.6
volts.
What
should
the
BJT
parameters
be?
These
are
a
little
difficult
to
track
down,
so
they
are
provided
below
(courtesy
of
Derek
and
Gilbert
at
MapleSoft).
Figure
2
BJT
(2n3904)
characteristics.
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:transistor_led_tutorial:transistor_led_tutorial_v1.doc
MapleSim
Transistor
–
LED
Tutorial
James
A.
Smith
Figure
3
Run
the
simulation
by
clicking
on
the
blue
triangle
near
the
top
of
the
MapleSim
window.
Figure
4
You
can
monitor
progress
of
the
simulation
here.
Integration
Parameters
There
are
a
number
of
integration
parameters
that
will
need
to
be
tuned.
These
parameters,
when
set
“properly”
can
improve
the
speed
and
accuracy
of
your
model.
To
do
this
you
need
to
have
a
moderately
good
understanding
of
how
your
system
should
behave.
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:transistor_led_tutorial:transistor_led_tutorial_v1.doc
MapleSim
Transistor
–
LED
Tutorial
James
A.
Smith
Figure
5
Integration
parameters
for
the
model,
to
start
with.
Without
getting
into
too
much
detail,
set
the
relative
and
absolute
integration
tolerances
as
shown
in
Figure
6.
1
For
those
of
you
with
a
Mathworks
Simulink
background,
the
ODE45
integrator
used in Simulink is non-‐stiff, whereas the ODE23s integrator is stiff.
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:transistor_led_tutorial:transistor_led_tutorial_v1.doc
MapleSim
Transistor
–
LED
Tutorial
James
A.
Smith
Figure
6
Integration
parameters
after
some
adjustment.
Reporting
You
need
to
submit
a
screen-‐shot
/
print-‐out
of
your
schematic,
as
well
as
the
resistor
values
at
the
base
and
collector.
What
is
the
current
which
runs
through
the
LED/diode?
When
generating
your
print-‐outs
remember
that
you
should
display
the
parameter
names
and
values.
This
can
be
done
from
the
MapleSim
“View”
menu.
Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:transistor_led_tutorial:transistor_led_tutorial_v1.doc
Appendix F
The following is the second revision of the guide. There are three documents in this portion of the Appendix:
1. the “Building the Esduino ‘Shield’ Board” document. It’s a step-by-step guide.
Thanks to Ron Wong and Thomas Behan for helping with the material here.
F-1
Esduino
LCD
“Shield”
James
A.
Smith,
Ron
Wong
&
Thomas
Behan
Rev.
1.1
January
2011
Figure
1
Esduino
LCD
"Shield"
Board
Introduction
This is part of a two-week exercise. In the first week you will demonstrate usage of simulator
tools and will build the LCD board. In the second week you will write a program which
accesses the LCD and displays values from particular points in memory.
This document is designed to step you through the process of constructing the LCD unit.
These are listed in the relevant part of the Student Lab Manual. Refer to it.
Exploration
You
are
encouraged
to
explore
the
tools
and
parts.
Here
are
some
sample
questions
you
should
ask
yourself
and
that
you
should
answer:
These
types
of
questions
are
examples
of
valid
questions
that
can
be
used
to
assess
your
achievement
of
the
learning
objectives
for
this
lab
unit.
Required
Documents
1. ELE604
Sensors
and
Measurement
Student
Lab
Manual
by
James
Andrew
Smith
2. Electronic
Assembly
Dog
LCD
schematic
/
manual
3. MC9S12C
Family
/
MC9S12GC
Family
Reference
Manual,
#MC9S12C128
Rev
01.23
05/2007
by
Freescale
Semiconductor
(available
as
a
free
download
online)
Required
Tools
1. One
(1)
Soldering
Iron
(seeFigure
2)
2. One
(1)
pair
of
side
cutters
(i.e.
flush
cutters)
(see
Figure
4)
3. One
(1)
pair
of
needle-‐nose
pliers
(see
Figure
3)
4. One
(1)
Fume
hood
(see
Figure
2)
Recommended
tools
1. One
(1)
static
strap
2. One
(1)
solder
sucker
3. One
(1)
solder
wick
4. One
(1)
“Third”
or
“Helping”
hand
(see
Figure
5)
The
fume
hood
and
soldering
iron
are
provided
in
the
lab.
The
required
parts
are
included
in
your
lab
kit.
The
side
cutters,
pliers
and
recommended
tools
are
available
at
a
number
of
stores
in
the
city,
including
Creatron
and
Home
Hardware
on
College
St.
Some
tools
are
also
available
at
Polytechnic
Hardware,
The
Source
and
Canadian
Tire.
Esduino
LCD
“Shield”
James
A.
Smith,
Ron
Wong
&
Thomas
Behan
Rev.
1.1
January
2011
Figure
2
Soldering
Iron
(right)
and
fume
hood
(left)
Figure
3
Needle-nose
pliers.
Image
courtesy
of
Wikipedia
(http://en.wikipedia.org/wiki/File:Needle_nose_pliers.jpg)
Figure
4
Side-
or
Flush-cutters.
Image
courtesy
of
Wikipedia
(http://en.wikipedia.org/wiki/File:Side_cutters.jpg)
Esduino
LCD
“Shield”
James
A.
Smith,
Ron
Wong
&
Thomas
Behan
Rev.
1.1
January
2011
Figure
5
Third-
or
Helping-Hand.
This
is
useful
for
holding
circuit
boards
or
wires
while
your
hold
a
soldering
iron
in
one
hand
and
solder
in
the
other.
Image
courtesy
of
Wikipedia
(http://en.wikipedia.org/wiki/File:DKHelpingHand.jpg)
Orientation
In
this
tutorial,
we
will
refer
to
different
parts
of
the
board
by
compass
direction
(east,
west,
north,
south).
North
West East
South
Figure
6
Front
of
the
ARPROTO3
prototyping
board.
Note
the
individual
pads.
The
LCD
will
be
mounted
on
this
side.
The
coloured
sheathing
of
the
wires
will
be
visible
on
this
side,
also.
Esduino
LCD
“Shield”
James
A.
Smith,
Ron
Wong
&
Thomas
Behan
Rev.
1.1
January
2011
Figure
7
Rear
of
ARPROTO3
Board.
You
will
do
most
of
your
soldering
on
this
side.
Steps
Pre-‐lab
–
Review
Soldering
Techniques
–
Online!
There are some very good online guides to soldering, including:
Figure
8
Video
tutorial
on
soldering
available
at
Lady
Ada's
website
(http://www.ladyada.net/learn/soldering/thm.html)
Esduino
LCD
“Shield”
James
A.
Smith,
Ron
Wong
&
Thomas
Behan
Rev.
1.1
January
2011
Mr.
Jim
Koch
will
conduct
a
session
on
soldering
during
the
lab
session.
This
is
a
vital
skill
for
electrical
engineers!
Pay
attention
to
his
suggestions
and
recommendations.
Your
TAs
are
also
expert
solderers
and
will
be
able
to
assist
you
in
the
finer
details.
Bad
soldering
is
virtually
guaranteed
to
lead
to
expensive
and
time-‐consuming
fixes
down
the
road.
So
keep
your
mind
open
to
advice
from
the
experts!
Follow
Figs.
7
through
11,
in
order.
The
black
parts
of
the
headers
will
be
placed
on
the
top
of
the
board.
The
pins
of
the
headers
will
stick
out
the
bottom
of
the
board.
You’ll
solder
the
pins
from
the
bottom
of
the
board.
Figure
9
Single
row
headers
+
ARPROTO3
board
Figure
11
Stack
on
an
existing
protoboard.
This
helps
line
up
the
pins.
Your
TA
or
one
of
your
lab
mates
may
have
a
spare
board
to
help
you
at
this
stage.
Figure
12
Solder
one
pin
on
each
header
first.
Note
the
iron
on
the
left
and
solder
on
the
right.
Check
that
the
header
is
still
lined
up
right.
Then
solder
the
remaining
pins.
Figure
13
Done.
Compared
to
the
Esduino.
Esduino
LCD
“Shield”
James
A.
Smith,
Ron
Wong
&
Thomas
Behan
Rev.
1.1
January
2011
You
want
to
place
the
LCD
into
the
prototyping
board
from
the
top.
The
pins
will
stick
out
the
bottom,
where
you
will
eventually
solder
it.
Note
that
one
side
of
the
LCD
only
has
four
pins.
These
face
the
south
end
of
the
board.
It’s
important
to
have
empty
space
on
both
the
west
and
north
ends
of
the
boards
to
accommodate
wires
and
(in
future
labs)
switches
and
LEDs.
Some more details about an ideal placement can be found in Step 10.
Figure
14
Looks
about
right.
The
layout
will
change
a
bit
by
the
end.
Yes.
It’s
important.
Remember
the
saying
“measure
twice,
cut
once?”
It
applies
here,
too,
except
we’d
say
“read
schematic
twice,
solder
once”.
Figure
15
Which
pins
get
connected
to
+5?
Esduino
LCD
“Shield”
James
A.
Smith,
Ron
Wong
&
Thomas
Behan
Rev.
1.1
January
2011
Step
4.
Add
the
+5
and
GND
lines
to
the
South
end
of
the
protoboard
Figure
16
Note
how
the
+5
and
GND
SPI
line
CSB(38)
should
be
wired
to
ground.
Don’t
install
the
other
SPI
lines
(pins
28,29,
and
39
on
the
LCD)
yet.
Figure
17Solder
the
power
wires
on.
The
alligator
clip
is
part
of
the
optional
“third
hand”.
The
wires
should
not
be
too
long.
Otherwise
they
will
interfere
with
the
Esduino
board
that
the
LCD
board
will
eventually
attach
to.
Esduino
LCD
“Shield”
James
A.
Smith,
Ron
Wong
&
Thomas
Behan
Rev.
1.1
January
2011
Figure
18Clip
off
the
extra
wire
using
the
"side"
or
"flush"
cutters.
See
the
third
hand
in
the
background?
It’s
useful!
Figure
19The
communication
lines
are
connected..
Figure
20Check
the
schematics
again!
Visually
inspect
all
pins.
Have
your
partner
look
for
cold
solder
joints
(these
are
bad
joints
that
fail
when
you
least
expect
it
because
the
bond
between
the
solder
and
the
pins
or
pads
is
not
good).
Check
the
schematics
again!
[It’s
at
this
stage
that
I
found
two
SPI
lines
shorted
together!
I
fixed
it
prior
to
destroying
my
Esduino!
Phew!
–
Dr.
Smith]
Figure
21The
DMM
connectivity
feature
is
important!
Check
to
see
that
the
traces
on
the
rear
of
the
board
will
reach
between
your
wires
and
the
pins
of
the
LCD.
The
bottom
row
of
the
LCD
should
be
the
4th
row
from
South
on
the
Protoboard.
The
top
row
of
the
LCD
should
be
the
5throw
from
North
Esduino
LCD
“Shield”
James
A.
Smith,
Ron
Wong
&
Thomas
Behan
Rev.
1.1
January
2011
(including
the
single
row
header
row
at
both
North
and
South).
The
East
edge
of
the
board
should
not
interfere
with
the
drill
hole
on
the
East
edge
of
the
board.
Step
12.
Clip
the
ends
of
the
LCD
pins
(on
the
bottom
side
of
the
board)
Keep
the
leads
short
so
that
they
don’t
interfere
with
any
board
that
might
be
attached
below.
Step
16.
Verify
routing
of
SPI
lines
between
Esduino
and
LCD.
This
is
a
mechanical
verification
with
your
multimeter.
Attach
the
LCD
board
to
the
Esduino
(supplied
by
the
TA).
Before
you
attach
the
USB
or
power
to
the
Esduino,
test
the
connection
between
the
bottom
of
the
Esduino’s
headers
to
the
individual
LCD
pins
on
the
prototyping
board.
Use
a
multimeter
for
this
test.Your
TA
will
supervise
this
process.
Table
1
SPI
pins
on
the
9s12
and
the
LCD.
Finally,
your
TA
will
power
up
the
Esduino.
He/she
will
then
run
sample
code
which
will
display
characters
on
your
LCD,
as
shown
in
Figure
22.
If
it
works,
great.
If
not,
you
will
need
to
debug
the
potential
problems.
Consult
with
your
TA.
Esduino
LCD
“Shield”
James
A.
Smith,
Ron
Wong
&
Thomas
Behan
Rev.
1.1
January
2011
Figure
22
The
LCD
board
attached
to
the
Esduino.
In
this
case,
we
are
using
a
two-line
LCD.
You
are
using
a
three-line
LCD,
so
the
characters
will
be
a
bit
smaller.
ELE604
Quick
&
Dirty
LCD
Tutorial
Ronnie
Wong
Ryerson
University
Electrical
and
Computer
Engineering
January
25,
2011
1
Some
things
to
note...
• LCD
Build
Guide:
– Figure
14:
LCD
placement
is
incorrect.
– There
is
no
Step
9,
it
jumps
from
Step
8
to
Step
10
• 1
student
solders,
the
other
should
focus
on
the
CodeWarrior
assembly
quesSons
(required
for
write-‐up)
• Soldering:
Remember
the
safety
lessons
given
by
Jim
Koch
and
Dr.
Smith!!!
2
Tip
#
1:
CodeWarrior
• The
IDE
is
available
from
Freescale:
– h\p://www.freescale.com/webapp/sps/site/
prod_summary.jsp?code=CW-‐HCS12X
– Or
Google:
“Freescale
Codewarrior
9S12”
– This
allows
you
to
work
on
your
own
computer
• Available
in
ENG307
and
ENG411
(COE538)
3
Tip
#2:
Datasheets!
• Your
best
friend!
• LCD
–
available
from
Jim
Koch’s
ELE604
page
• ESDUINO
–
also
available
from
Jim
Koch’s
page
• LCD
Build
InstrucSons
–
at
the
end
of
the
lab
manual
5
(ConSnued)
• ESDUINO:
– What
did
you
do
in
your
lab
report?
You
were
supposed
to
have
done
a
prelim
pin
allocaSon
for
your
LCD!
– In
case
you
forgot,
this
page
is
what
you
need:
6
(ConSnued)
• Dr.
Smith’s
Build
InstrucSons
(i.e.
Student
Guide)
– Hint:
Appendix
D!
– Page
125:
“ Table
1:
SPI
Pins
on
the
9S12
and
LCD”
7
Tip
#3:
Component
Placement
• There
is
more
than
one
way
to
solder
your
LCD
onto
the
ARPROTO3
board
– it
depends
on
how
you
place
your
components
and
wires.
Having
a
general
idea
on
the
size
and
spacing
of
your
components
can
also
help!
– Design
and
plan
on
a
napkin
or
paper
will
help
you
visualize
where
to
place
your
parts
and
more
importantly:
how
they
will
all
wire
together!
– REMEMBER:
There
is
limited
space
on
the
shield!
8
Tip
#4:
ARPROTO3
Board
Wiring
• REMEMBER:
the
ARPROTO3
boards
are
stackable!
This
allows
you
to
create
mulSple
boards
(for
different
applicaSons:
LCD/GPS/
Power/etc.)
and
then
stack
them!
Source:
h*p://cdn.shopify.com/s/files/1/0045/8932/files/stacked-‐shields_large.jpg?1280198233
9
OK!
I
want
to
design
–
tools?
• A
piece
of
paper?
Napkin?
• From
Jim
Koch’s
page:
“Prototyping
Shield
3”
10
Let
the
Build
Begin…
• AAAHHHH!
Where
do
I
begin?
11
Step
2:
Planning
• LCD
Datasheet
(page
4
and
8)
gets
me
this:
1. Pins
24
–
26
and
pins
30
–
37
are
Sed
to
+5V,
they
can
be
soldered
on
the
same
rail
2. Pins
23
and
27
are
GND,
thus
solder
together
12
What’s
next?
• Based
on
our
Lab
1
Report
(Ahem!),
we
found
that
the
SPI
communicaSon
pins
are
also
located
on
the
J3
connector:
• You
can
also
get
this
info
from
the
LCD
build
instrucSons
in
the
student
guide!
– Now
match
them!...
(next
page)
13
(Cont.)
14
Step
3:
Combine
with
the
Shield
CSB
(GND)
CLK
SI
+5V
RS
GND
15
What
does
this
mean?
Eureka!
• Thinking
about
it…each
J1/J2/J3/J4
header
pin
on
each
shield
that
gets
stacked
on
top
of
one
another
will
always
get
the
same
analog/digital
signal
from
that
pin.
– Note:
if
you
configure
pin
X
(i.e.
PT3)
for
an
App
X
on
Shield
X,
then
you
cannot
use
pin
X
for
App
Y
on
Shield
Y
that’s
stacked
onto
it.
You
must
use
another
pin!!!
ExcepSon:
if
your
App
Y/Shield
Y
circuit
also
needs
that
same
signal
• Power
source:
+5V
and
GND
pins
are
always
found
on
the
same
pins
per
shield
16
Step
4:
Puwng
it
Together!
Your
objecSve:
To
wire
the
LCD
onto
the
ARPROTO3
shield.
How?
By
combining…
17
Thus…
Now…its
up
to
you
to
figure
out
how
to
place
the
component
and
wires
onto
the
shield.
18
References
J.A.
Smith,
“ELE604
Sensors
and
Measurement
Student
Lab
Manual,”
Ryerson
University,
Jan
2011.
19
THE
END…
GOOD LUCK!
20
ELECTRONIC ASSEMBLY reserves
Issue 1.2010 EA DOG-M the right to change specifications
without prior notice. Printing and
DOG SERIES 3.3V Page 2 typographical errors reserved.
readable even
FSTN pos. it's fine with and black on backlight
without black on white white, blue, RGB
transflective without backlight color
backlight
3 DIFFERENT DISPLAYS
These displays are available for mentioned technologies:
6 DIFFERENT BACKLIGHTS
6 different backlight colors are available to match equipments design as much as possible. The most
effective and brightest one is the white one EA LED55x31-W.
A detailed description for integrated controller ST7036 you can find under
http://www.lcd-module.de/eng/pdf/zubehoer/st7036.pdf
A detailed description for integrated controller ST7036 you can find under
http://www.lcd-module.de/eng/pdf/zubehoer/st7036.pdf
ELECTRONIC ASSEMBLY reserves
the right to change specifications EA DOG-M
without prior notice. Printing and
typographical errors reserved. Page 7 ELECTRONIC ASSEMBLY reserves
EA DOG-M the right to change specifications
Page 8 without prior notice. Printing and
EXAMPLES FOR INITIALISATION typographical errors reserved.
H
H
H/ L
H/ L
H/ L
H/ L
H/ L
H/ L
H/ L
H/ L
H/ L
H/ L
H/ L
Note:
- LC-displays are not suited
for wave soldering or reflow
soldering. Temperatures
above +80°C may damage
lcd-module.
- Surfaces of display and
backlight are with protection
foils protected against
scratching. Please remove
before use.
Command RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Hex Note
E
D7
D6
D5
D4
D3
D2
D1
D0
RS
VIN
PSB
R/W
VDD
VSS
CSB
VOUT
RESET
CAP1N
CAP1P
Command RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Hex Note
ATTENTION
handling precautions!
Zeppelinstr. 19 · D-82205 Gilching · Phone +49-8105-77 8090 · Fax +49-8105-77 80 99 · www.lcd-module.de · info@lcd-module.de
Listing F.1: Example for driving an Electronic Assembly DOG 3x16 5V SPI Liquid Crystal Display Uses
Assembler and is compatible with Esduino and Codewarrior and contains code numeric and decimal output
(via Mr. Peter Hiscock’s source code from COE538) (tested Dec. 2010)
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
; ∗ This s t a t i o n e r y s e r v e s as t h e framework f o r a ∗
; ∗ user a p p l i c a t i o n ( s i n g l e f i l e , absolute assembly a p p l i c a t i o n ) ∗
; ∗ For a more c o m p r e h e n s i v e p r o g r a m t h a t ∗
; ∗ d e m o n s t r a t e s t h e more a d v a n c e d f u n c t i o n a l i t y o f t h i s ∗
; ∗ processor , please see the demonstration a p p l i c a t i o n s ∗
; ∗ l o c a t e d in the examples s u b d i r e c t o r y of the ∗
; ∗ F r e e s c a l e C o d e W a r r i o r f o r t h e HC12 Program d i r e c t o r y ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
; A u t h o r : R o n n i e Wong
; December 1 1 , 2 0 1 0
; Sources :
; 1 . J . V a l v a n o , I n t r o d u c t i o n t o Embedded S y s t e m s : I n t e r f a c i n g t o t h e F r e e s c a l e 9 S12 , 1 s t Ed . , 2010.
; 2 . F r e e s c a l e , MC9S12C F a m i l y MC9S12GC F a m i l y R e f e r e n c e Manual , Rev . 0 1 . 2 3 , May 2 0 0 7 .
; 3 . P e t e r H i s c o c k s , INT2BCD and BCD2ASCII c o n v e r s i o n s u b r o u t i n e s , COE538 − R y e r s o n U n i v e r s i t y 2010.
; export symbols
XDEF Entry , Startup ; e x p o r t ’ Entry ’ symbol
ABSENTRY Entry ; f o r a b s o l u t e a s s e m b l y : mark this as application entry point
; Include d e r i v a t i v e −s p e c i f i c d e f i n i t i o n s
INCLUDE ’ d e r i v a t i v e . inc ’
; v a r i a b l e / data section
ORG RAMStart
; I n s e r t here your data d e f i n i t i o n .
; i n s e r t rmb and o t h e r v a r i a b l e s h e r e . . .
; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; I n t e g e r t o BCD C o n v e r s i o n R o u t i n e ( p o r t e d f r o m P . H i s c o c k s )
; V a r i a b l e s f o r b 1 6 t o d e c . asm and b c d t o a s c . asm s u b r o u t i n e s
bcdbuffer EQU ∗ ; The f o l l o w i n g r e g i s t e r s a r e t h e BCD b u f f e r area
tenthous RMB 1 ; 1 0 , 0 0 0 d i g i t , max s i z e f o r 16 b i t b i n a r y
thousands RMB 1 ; 1 ,000 d i g i t
hundreds RMB 1 ; 100 d i g i t
tens RMB 1 ; 10 d i g i t
units RMB 1 ; 1 digit
bcdspare RMB 10
noblank RMB 1 ; Used i n ’ l e a d i n g z e r o ’ b l a n k i n g b y BCD2ASC
; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; code section
ORG ROMStart
Entry :
Startup :
mainLoop :
; BCD C o n v e r s i o n
LDD #3456 ; Digits to print out . . .
JSR int2bcd
JSR bcd2asc
LDX #b c d b u f f e r
JSR LCD OutString ; P r i n t w/ o d e c i m a l
LDX #b c d b u f f e r
; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; i n s e r t subroutines here . . .
; Timer S u b f u n c t i o n s : 9 S12C32 @ 4MHz
; T h i s t i m e −d e l a y r o u t i n e i s s o f t w a r e d r i v e n
; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; E n a b l e TCNT a t 1 u s
Timer Init :
MOVB #$80 , TSCR1 ; E n a b l e TCNT, movb i s an 8− b i t move memory t o memory
;MOVB #$02 , TSCR2 ; S e t TCNT p e r i o d @ 1 u s − 1 m i c r o s e c o n d (@ 4MHz b u s , w i t h o u t M o n i t
MOVB #$05 , TSCR2 ; S e t TCNT p e r i o d @ 1 . 3 3 u s − 1 . 3 3 m i c r o s e c o n d (@ 24MHz b u s , w i t h M o n i t o r )
RTS
; RegD i s t h e t i m e t o w a i t i n u s
; RegD must b e l e s s t h a n 3 2 7 6 7
Timer Wait :
NOP
ADDD TCNT ; End o f w a i t t i m e
wloop CPD TCNT ; S t o p when RegD < TCNT
BPL wloop ; o r i g i n a l by Valvano
RTS
; RegA c o n t a i n s t h e command t o b e s e n t
; RS : H/L : L = Command , H = Data
LCD WriteCommand :
BCLR PTT,# $08 ; PT3 = CS = 0 , s e n d command
BSR send ; s e n d LCD command
BSET PTT,# $08 ; PT3 = CS = 1 , t o g g l e b a c k . . .
RTS
; RegA c o n t a i n s t h e d a t a t o b e s e n t
; RS : H/L : L = Command , H = Data
LCD WriteData :
BSET PTT,# $08 ; PT3 = CS = 1 , s e n d d a t a
BSR send ; s e n d LCD d a t a
BCLR PTT,# $08 ; PT3 = CS = 0 , t o g g l e b a c k
RTS
; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; LCD command s u b r o u t i n e s
; RegX c o n t a i n s s t r i n g t o b e o u t p u t e d
LCD OutString :
LDAA 1 , x+ ; could a l s o use : ldaa 0 , x − inx afterwards
BEQ done
JSR LCD WriteData
BRA LCD OutString
done RTS
; Turns o f f t h e cursor
LCD CursorOff :
LDAA #$0C
JSR LCD WriteCommand
LDY #30
JSR Timer Wait1ms
RTS
; Turns o f f d i s p l a y
LCD DisplayOff :
LDAA #$08
JSR LCD WriteCommand
LDY #30
JSR Timer Wait1ms
RTS
LCD ReturnHome :
LDAA #$02
JSR LCD WriteCommand
LDY #5
JSR Timer Wait1ms
RTS
LCD SetPosition :
; i n s e r t code here to set position . . . Revision ’2 ’
LCD WriteAtPos :
; i n s e r t code here to set write position . . . Revision ’2 ’
XGDX ; swap q u o t i e n t b a c k i n t o . D
LDX #10 ; and s e t u p f o r a n o t h e r d i v i d e b y 10
IDIV
ANDB #$0F
STAB hundreds
CPX #0
BEQ conexit
; bcdtoasc : this routine converts t h e BCD number i n the bcdbuffer into ascii format
bcd2asc :
LDAA #0 ; initialize the blanking flag
STAA noblank
; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; i n s e r t i n t e r r u p t routines here . . .
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
;∗ Interrupt Vectors ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
ORG $FFFE
DC.W Entry ; Reset Vector
The Revision 1 version of the Esduino’s schematics and parts layout are found here.
G-1
[JB4] TX/RX Communications Routing:
Place two shunts in the positions shown Esduino
US = USB-to-SCI (of the MCU) 9S12C-based Arduino-compatible*
When Xbee Option is present: Rev. 1
UX = USB-to-Xbee (for configuring via Host) [JB3]: Digital11 Source
SX = SCI-to-Xbee (for wireless communications) 1-2 (left): PM4
[U4]: Serial Memory [JB2]: Digital10 Source 1-3 (down): PP5 (PAD1)
Footprint for optional 1-2 (left): PT4 1-4 (right): PT5
[J14][J15]: USB2MCU module goes here, SPI memory device. 2-3 (right): PM3
to provide USB interface to host PC; [D2]: User LED [U1]:
or supply your own TTL-level signals (on DIG13) Freescale 9S12C 16-bit microcontroller
to/from Host
[JB8] PS/PM SELECT:
PT3
PT7
PT6
PT2
PT1
PM5
PM2
PAD07
PAD06
DIG1
DIG0
PT0
Select between PS0/PS1
J14 US JB4
GND J3 and PM0/PM1 assignments
[J9][J10]: [Xbee Option]
>
<
D2
+5V
J1
for DIG0 and DIG1 pins
D13
D12
D11
D10
D9P
D8
D7
D4
Plug ADXB here for XBee Interface U4
GND
DTR
SX UX
UX SX
AREF
PT4 PM3 S M
(3V/5V compatible). SPI [J11] BDM IN:
DIG11
PWM D6
PWM D5
<TX US J6 C17
D2 JB2
1 PWM D3
GND J15 DI PM4 PT5
JB8
[J6]: SPI peripheral connector Standard 6-pin Background
RX > ADXB +5 JB3
SPI signals, Output Enable, +5V, J10 Esduino Debug Mode connector for
SCK
PP5
JB1
BDM IN
and Ground are all brought out to www.TechnologicalArts.com advanced debugging use
SS* R5 J11 LOAD
VIN C6
this convenient connector for easy OE* J5 JB6 SW1
USB [SW1 and JB6]:
interfacing to SPI peripherals DO C5 MAN
PB4 R1
G C7
When JB6 set to MAN, use SW1 to
[JB1]: 5V Source Selector PWR PE7 select Serial Monitor mode.
D3 C10
AUTO RUN
PE4
1-2 (lower): 5V from USB Y1 When JB6 set to AUTO, Serial
U1
R6 D1 PA0 R3
2-3 (upper): 5V from U1 via VIN C1 C11
J8 PM0 Monitor mode must be controlled
+
J9 Y2 JB5 PM1
[D1]: Power indicator LED by host via DTR line on serial port.
R2 3V 5V J7 AN7
J12 C16 VDD VRH AR
AN6
C15 C14 JB7
[J7] PB4, PE7,PE4,PA0: C9 [J8] PM0 - PM1:
U3
Four bonus Digital pins. +
RESET
VIN
AN0
AN1
AN2
AN3
AN4
AN5
GND
GND
J4
SW2
REV. 1 J13
[U3]: 3.3V regulator (800 mA max.) transceiver to implement a
CAN interface.
PAD00
PAD01
PAD02
PAD05
PAD03
PAD04
1
2 1 PE0/XIRQ*
SPI Signals JUMPER1 W2
+5V 100n JUMPER1
J6 9S12C
2
PM2/MISO JB8 DIG0/1 SEL
7
6 VDD PM1/TXCAN
5 PM5/SCK DIG13 PM3/SS* 1 8 PM0/RXCAN
PM3/SS* PM2/MISO 2 CS VCC 7 5 6
4 3 4
3 PT3/IOC3/PW3 DIG9/PWM 3 SO HOLD 6 PM5/SCK ARDUINO 9S12C PS0 PS1 ARDUINO
1
4 PM4/MOSI 4 WP SCK 5 PM4/MOSI J2 1 2 J1 4
2 VSS SI
PP5/PW5
PM0/RXCAN
PM1/TXCAN
PM2/MISO
PM3/SS*
PM4/MOSI
PM5/SCK
PS1
PS0
1 C3 1 AN0 AN0/PAD00 DIG0/RX 1
U4 25LCXXXA 100n 2 AN1 AN1/PAD01 DIG1/TX 2
2
CON7 3 AN2 AN2/PAD02 AN6/PAD06 DIG2 3
48
47
46
45
44
43
42
41
40
39
38
37
5VUSB U1 VDD AN3 AN3/PAD03 PT0/IOC0/PW0
4 DIG3/PWM4
J14 5 AN4 AN4/PAD04 AN7/PAD07 DIG4 5
1 VRH 6 AN5 AN5/PAD05 PT1/IOC1/PW1 DIG5/PWM6
VSSX
VSSA
USB2MCU module PT2/IOC2/PW2
VDDX
2 SEL DIG6/PWM7
attaches to J14 and J15 CON6 PT6/IOC6 DIG7 8
PM3/SS*
1
PS1/TXD
PS0/RXD
PM5/SCK
CON2 JB7
PM2/MISO
PM4/MOSI
PP5/KWP5
D2
PM1/TXCAN
PM0/RXCAN
J15 PT0/IOC0/PW0 1 36 VRH 2 CON8
DTR PT1/IOC1/PW1 PW0/IOC0/PT0 VRH J4
4 2 35 1 2 1 2
1
URX PT2/IOC2/PW2 PW1/IOC1/PT1 VDDA C9 RESET* R7 2K0 J3
3 3 1 L
3
PT3/IOC3/PW3 PW2/IOC2/PT2 3V3 PT7/IOC7 DIG8
2 4 PW3/IOC3/PT3 2 +3V3 1
1 34 AN7/PAD07 100n 3 5V PT3/IOC3/PW3 DIG9/PWM 2
3
PAD07/AN07 +5V
AUTO 5 33 AN6/PAD06 4 GND DIG10/PWM 3
CON4 JB6 VDD1 PAD06/AN06 AN5/PAD05 GND DIG11/PWM
2 6 VSS1 PAD05/AN05 32 5 4
31 AN4/PAD04 6 VIN PM2/MISO DIG12 5
PAD04/AN04 VIN
MAN PT4/IOC4/PW4 7 MC9S12C 30 AN3/PAD03 PM5/SCK DIG13 6
1
PT5/IOC5 PW4/IOC4/PT4 PAD03/AN03 AN2/PAD02 CON6 GND
8 IOC5/PT5 PAD02/AN02 29 7
CUT W3 TO W3 PT6/IOC6 9 28 AN1/PAD01 AREF 8
DISABLE PT7/IOC7 IOC6/PT6 PAD01/AN01 AN0/PAD00 PM4/MOSI
JUMPER1 10 IOC7/PT7 PAD00/AN00 27
AUTO RESET VDD VDD1 J8 PM3/SS* CON8
2
BKGD 11 26 PA0 PM1/TXCAN 1
2
3 MODC/BKGD PA0 3
SW1 PM0/RXCAN 2 VDD +5V
PB4 12 25 PE0/XIRQ*
3
2
RUN LOAD PB4 XIRQ*/PE0 VDDPLL CON2 JB5 selects JB2 JB3
1
1
5V or 3V3 2 1 3 JB3 selects source
3
1
C4 operation of DIG11/PWM
3
XCLKS*/PE7
ECLK/PE4
VSSR
VDDR
RESET*
VDDPLL
XFC
VSSPLL
EXTAL
XTAL
TEST/VPP
IRQ*/PE1
R2 470n J7 JB5
2
1
4
1
1
1
10K C6 C7 C5 AN7/PAD07 1 2
13
14
15
16
17
18
19
20
21
22
23
24
AN6/PAD06 2 JB2 selects source
2
C16 R4 4K7 100n PT4/IOC4/PW4 of DIG10/PWM
2 1
2
2
1
1 2
PP5/PW5
100n VDD
J11 BDM IN VDD R1
3K9 +3V3
2 1 VIN
2
4 3
POWER
1
6 5 PE1/IRQ* 5V out U2 LD1117S IN
1
RESET* 2 3 3
URX PS1 C8 R5 Vout Vin J12
2
1
2
8MHz
ADJ
2
2
3
1
1
2 1 PB4 470n 2
2
R3 10M
BONUS 2 PE7 RESET J13
1
1
1
22p 22p 1
2
2
4 PA0
D3 1N4148 R9 2
2 1 CON4 715R
+3V3 5VUSB
J9 PA0
2
PIN1 1 20 PIN20
PIN2 VCC AD0/DIO0 19 PIN19
2 COM SEL (JB4) Settings:
PIN3 DOUT AD1/DIO1 18 PIN18
3 DIN/CONFIG AD2/DIO2 - for normal operation, jumper 1 to 2, and 5 to 6
PIN4 4 17 PIN17 - for XBee-to-9S12 communication, jumper 2 to 4, and 3 to 5
PIN5 D08 AD3/DIO3 16 PIN16
5 RESET RTS/AD6/DIO6 - for XBee-to-host connection, jumper 1 to 3, and 4 to 6
PIN6 6 15 PIN15 +3V3 +5V Revision Notes:
PIN7 PWM0/RSSI AS/AD5/DIO5 14 PIN14 U3 LD1117S33
7 PWM1 VREF 1 -fixed J9/10 pinout
PIN8 8 13 PIN13 2 3
PIN9 [reserved] ON/SLEEP 12 PIN12 VOUT VIN -added optional SPI EEPROM (U4)
9
1
GND
GND AD4/DIO4 + C14 -added selection jumpers for DIG0/1 connections (JB6)
PWR
1
1
100n
2
ADXB Connector
2
J10 D1 + C1
PIN1 PIN20
PIN2 1 20 PIN19
2
PIN3 2 19 PIN18
3 18 NOTES:
1 PIN4 PIN17 10u 10V TANT 1
1 2
PIN10 9 12 PIN11
10 11 must implement timeout) Esduino 9S12C MCU Module
(DTR will also initiate AutoReset feature, unless W3 is open) Size Document Number Rev
B FILE: esduino0.dsn 1
The following is the “build guide” for the Rev. 1 version of the Esduino board. It is similar to the standard
Esduino escept that all through-hole parts have been removed. You will place these components on the board
following the instructions provided here.
H-1
Esduino
Board
(Rev
1)
Build
Guide
Thomas
Behan,
James
Andrew
Smith
&
Ron
Wong
Document
Version
2
January
2011
Figure
1
Esduino
Board
Introduction
This manual will guide you through the building of the Esduino Board.
These are listed in the relevant part of the Student Lab Manual. Refer to it.
Required
Documents
1. ELE604
Sensors
and
Measurement
Student
Lab
Manual
by
James
Andrew
Smith
2. MC9S12C
Family
/
MC9S12GC
Family
Reference
Manual,
#MC9S12C128
Rev
01.23
05/2007
by
Freescale
Semiconductor
(available
as
a
free
download
online)
Esduino
Board
(Rev
1)
Build
Guide
Thomas
Behan,
James
Andrew
Smith
&
Ron
Wong
Document
Version
2
January
2011
Required
Tools
1. One
(1)
Soldering
Iron
(seeFigure
2)
2. One
(1)
pair
of
side
cutters
(i.e.
flush
cutters)
(see
Figure
4)
3. One
(1)
pair
of
needle-‐nose
pliers
(see
Figure
3)
4. One
(1)
Fume
hood
(see
Figure
2)
Recommended
tools
1. One
(1)
solder
sucker
2. One
(1)
solder
wick
3. One
(1)
“Third”
or
“Helping”
hand
(see
Figure
5)
The
fume
hood
and
soldering
iron
are
provided
in
the
lab.
The
required
parts
are
included
in
your
lab
kit.
The
side
cutters,
pliers
and
recommended
tools
are
available
at
a
number
of
stores
in
the
city,
including
Creatron
and
Home
Hardware
on
College
St.
Some
tools
are
also
available
at
Polytechnic
Hardware,
The
Source
and
Canadian
Tire.
Figure
2
Soldering
Iron
(right)
and
fume
hood
(left)
Figure
3
Needle-nose
pliers.
Image
courtesy
of
Wikipedia
(http://en.wikipedia.org/wiki/File:Needle_nose_pliers.jpg)
Esduino
Board
(Rev
1)
Build
Guide
Thomas
Behan,
James
Andrew
Smith
&
Ron
Wong
Document
Version
2
January
2011
Figure
4
Side-
or
Flush-cutters.
Image
courtesy
of
Wikipedia
(http://en.wikipedia.org/wiki/File:Side_cutters.jpg)
Figure
5
Third-
or
Helping-Hand.
This
is
useful
for
holding
circuit
boards
or
wires
while
your
hold
a
soldering
iron
in
one
hand
and
solder
in
the
other.
Image
courtesy
of
Wikipedia
(http://en.wikipedia.org/wiki/File:DKHelpingHand.jpg)
Steps
Pre-‐lab
–
Review
Soldering
Techniques
–
Online!
There are some very good online guides to soldering, including:
Figure
5
Video
tutorial
on
soldering
available
at
Lady
Ada's
website
(http://www.ladyada.net/learn/soldering/thm.html)
Mr.
Jim
Koch
will
conduct
a
session
on
soldering
during
the
lab
session.
This
is
a
vital
skill
for
electrical
engineers!
Pay
attention
to
his
suggestions
and
recommendations.
Your
TAs
are
also
expert
solderers
and
will
be
able
to
assist
you
in
the
finer
details.
Bad
soldering
is
virtually
guaranteed
to
lead
to
expensive
and
time-‐consuming
fixes
down
the
road.
So
keep
your
mind
open
to
advice
from
the
experts!
Figure
6
Collection
of
parts
with
the
ESD12C32-KIT.
Esduino
Board
(Rev
1)
Build
Guide
Thomas
Behan,
James
Andrew
Smith
&
Ron
Wong
Document
Version
2
January
2011
Step
2.
Check
the
PCB
for
bad
connections.
You
need
to
look
over
the
board
for
anything
out
of
place.
Spare
scraps
of
solder,
solder
bubbles,
etc.
Then
gently
poke
each
surface
mount
part
to
see
if
it
moves.
Parts
that
are
loose
will
need
to
be
fixed
by
your
TA.
Step
3.
Prepare
to
solder
components
from
smallest
to
largest.
You
will
need
to
flip
the
board
over
to
solder
all
of
the
parts.
This
means
that
parts
must
be
held
in
place
by
the
table.
By
starting
with
the
smallest
parts
first,
we
can
ensure
that
the
parts
do
not
fall
out.
Figure
8
Diode
Alignment.
Make
sure
to
orient
the
diode
correctly.
Check
for
the
bar
on
both
the
PCB
and
diode
on
D3.
Esduino
Board
(Rev
1)
Build
Guide
Thomas
Behan,
James
Andrew
Smith
&
Ron
Wong
Document
Version
2
January
2011
Step
5.
Push
the
diode
flush
with
the
board,
bend
the
leads
to
hold
it
in
place.
Figure
9
Diode
flush
with
the
PCB.
Once
you
are
sure
the
diode
has
the
correct
polarity
bend
the
leads
and
slide
it
in
flush
with
the
board.
Once
completely
flush,
bend
the
leads
to
hold
the
diode
in
place.
Figure
10
Diode
leads
bent
and
ready
to
be
soldered.
Remember
to
heat
the
lead
and
PCB,
not
the
solder
directly!
Also
do
not
use
too
much
solder.
De-‐soldering
is
much
more
difficult
then
soldering,
do
it
right
the
first
time.
Esduino
Board
(Rev
1)
Build
Guide
Thomas
Behan,
James
Andrew
Smith
&
Ron
Wong
Document
Version
2
January
2011
Figure
11
Correctly
soldered
leads,
one
is
clipped.
Figure
12
Crystal
oscillator
soldered.
The
crystal
oscillator
does
not
have
polarity
and
should
be
soldered
in
the
same
way
as
the
diode.
Esduino
Board
(Rev
1)
Build
Guide
Thomas
Behan,
James
Andrew
Smith
&
Ron
Wong
Document
Version
2
January
2011
Step
9.
Add
White
Power
Connector
(J13)
and
Switch
(SW1).
Figure
13
White
power
plug
and
Switch
soldered.
These
two
parts
are
approximately
the
same
height,
and
so
may
be
soldered
together.
Figure
14
Place
the
male
headers
on
the
PCB.
Soldering
the
male
headers
can
be
tricky,
use
the
following
steps
to
make
sure
the
connections
are
straight,
and
clean:
4)
Flip
the
board
right
side
up
to
make
sure
all
the
headers
are
straight.
With
only
one
pin
tacked,
they
can
be
fixed
by
hand
without
having
to
de-‐solder.
Step
11.
Solder
Female
headers.
Leave
J10,
J14,
and
J15
open
for
the
USB
Programmer.
Figure
15
Place
the
male
headers
on
the
PCB.
Solder the female headers using the same techniques used in the previous step.
Step
12.
Add
the
black
power
connector
and
button
(SW2).
Figure
16
Bent
leads
of
the
black
power
connector.
Use
pliers
to
bend
the
leads
of
the
black
power
connector
so
it
is
held
in
place.
This
will
make
soldering
it
easier.
Esduino
Board
(Rev
1)
Build
Guide
Thomas
Behan,
James
Andrew
Smith
&
Ron
Wong
Document
Version
2
January
2011
Step
13.
Add
USB
Programmer
side
board.
Figure
17
Add
USB
side
board.
Add
the
USB
programmer
side
board.
Notice
that
J10
must
be
left
open
for
the
USB
programmer
side
board
to
fit.
Figure
6
The
DMM
connectivity
feature
is
important!
Esduino
Board
(Rev
1)
Build
Guide
Thomas
Behan,
James
Andrew
Smith
&
Ron
Wong
Document
Version
2
January
2011
Step
16.
Left
over
parts.
Figure
19
Left
over
parts.
You
should
have
a
few
left
over
parts.
These
were
left
off
so
that
the
USB
side
programmer
and
be
soldered
directly
to
the
board.
Figure
20
Finished
Esduino
Board
with
jumpers.
1
Booting,
boot
up,
and
bootstrap
effectively
mean
“a
self-‐sustaining
process
that
Figure
7
Background
Debugger
Module
(BDM)
for
the
Esduino.
Also
known
as
a
BDM
cable
or
BDM
"pod"
(p/n
USBDMLT)
.
Photo
courtesy
of
Technological
Arts.
Here
are
the
steps
to
installing
the
serial
monitor
“bootstrap”
code.
2
Your
TA
will
be
happy
to
do
this
for
you.
1. Go
to
Technological
Arts
resource
page
to
get
the
USBDMLT
drivers:
http://support.technologicalarts.ca/docs/USBDMLT/
a. Download
the
USBDMLT
CODE
WARRIOR
IDE
SETUP
FILES.zip
zip
file
2. Go
to
Technological
Arts
Esduino
page
to
get
the
abs
files
at
http://support.technologicalarts.ca/docs/Esduino/Code/
a. Save
the
ESD12C32_Serial_Monitor.abs
file
3. Unzip
the
USBDMLT
file
to
your
local
directory
and
plug
in
the
BDM
cable
pod
(see
Figure
7)
into
the
USB
port
of
your
PC
4. Install
the
USB
driver
in
your
extracted
USBDMLT
file
folder
under
"USB_Driver"
5. Run
the
files
"Install
Codewarrior
Files"
and
"Install
Codewarrior
Debug
Files."
(Also
found
in
the
extracted
folder)
6. In
the
"Utilities"
subfolder,
run
"Test_USBDM."
It
should
detect
with
"1
Found"....exit.
7. Insert
the
BDM’s
six-‐pin
connector
into
the
BDM
port
of
the
Esduino.
Ensure
bootstrap
look
like?
Check
out
a
pair
of
Blundstone
boots
(http://www.blundstone.ca/).
2
More
instructions
on
the
BDM
can
be
found
here:
http://www.technologicalarts.ca/catalog/product_info.php?cPath=50_55&products
_id=572&osCsid=9c08084a090017f8ca2351ce628d51ea
(click
on
the
"Resources"
tab
for
instructions
on
setup)
Esduino
Board
(Rev
1)
Build
Guide
Thomas
Behan,
James
Andrew
Smith
&
Ron
Wong
Document
Version
2
January
2011
that
you
line
up
the
pins
correctly
(there
are
two
ways
to
do
it;
one
is
right
and
one
is
wrong!)
Refer
to
Figure
8.
8. Inside
the
Freescale
program
folder
in
your
C
directory...C:\Program
Files\Freescale\Codewarrior
for
S12(X)
V5.X,
run
the
program
hiwave.exe
(Its
basically
the
serial
monitor
without
the
Codewarrior
IDE).
9. Select
the
link
type
as
TBDML...and
select
the
MC9S12C32
chip
variant.
10. Use
the
Load
option
to
get
your
abs
file
into
the
unit.
11. You’re
done!
Figure
8
BDM
connection
to
the
Esduino.
Note
the
white
square
on
the
J11
port.
Make
sure
that
the
red
wire
on
the
BDM
lines
up
with
it
and
that
the
plastic
flange
is
beside
it
as
well.
Appendix I
I.1 Setup
You will want to set up your Esduino board to communicate with a desktop or laptop PC in order to log the
data and manipulate it in Matlab or maybe Labview. Here, we assume that you are using Windows on the PC.
This has been tested using the following:
1. MacBook Pro running Codewarrior 5.x on a Parallels virtual machine (Windows XP). Used to compile
the code and transfer it to an Esduino, Rev 1.
This is different that the typical lab setup for students (e.g. Windows XP under VMWare virtual machine
with Linux host) and 9s12’s built-in serial monitor (rather than the BDM).
To get this to work, I created a new project in Codewarrior and replaced the main.c file contents with
the content’s of Valvano’s file. I also imported the SCI.C and SCI.H files, then ran Make a few times before
downloading it via the BDM cable.
I.2 To-Do
How to alternate between the Esduino’s Serial Monitor mode (“Load”?) and running the serial communication
to the PC (“Run”?), as this is more typical of the student setup.
I-1
I.3 Serial Communication Code & Test
I.3.1 Test first using RealTerm
RealTerm (http://realterm.sourceforge.net/) is the most capable serial terminal program for Windows.
It’s much better than HyperTerm, and it’s free! Use it to test out the serial output from your Esduino first.
The Esduino serial code (see Listing I.1 and the complete files at http://users.ece.utexas.edu/~valvano/
Starterfiles/SCI_9S12.zip) is configured for 19200 baud, as is RealTerm in Fig. I.1.
Figure I.1: RealTerm is set up for 19200 baud. Use the Windows Device Manager (right) to identify the correct
COM port that RealTerm is to use (COM 8 in this case, but it will likely be different on your computer!)
// how t o r u n p r o g r a m s t h a t u s e t h e SCI p o r t
// 1 ) c o n n e c t 9 S12C32 t o PC ’ s COM p o r t ,
// s e t 9 S12C32 t o BOOT mode
// r e s e t 9 S12C32
// 2 ) e x e c u t e P r o j e c t −>Debug ( c o m p i l e s and d o w n l o a d s c o d e t o 9 S12C32 )
// 3 ) q u i t MW d e b u g g e r o n c e p r o g r a m m i n g c o m p l e t e
// q u i t t i n g t h e d e b u g g e r w i l l r e l e a s e t h e COM p o r t
// 4) s t a r t a t e r m i n a l program ( l i k e HyperTerminal )
// s p e c i f y p r o p e r COM p o r t , 1 9 2 0 0 b i t s / s e c , no f l o w c o n t r o l
// 5 ) s e t t o RUN mode and h i t r e s e t
// 6 ) when done , q u i t t e r m i n a l p r o g r a m
// q u i t t i n g t h e t e r m i n a l p r o g r a m w i l l r e l e a s e t h e COM p o r t
// s e t 9 S12C32 t o BOOT mode
// r e s e t 9 S12C32
//−−−−−−−−−−−−−−−−−−−−−OutCRLF−−−−−−−−−−−−−−−−−−−−−
// O u t p u t a CR, LF t o SCI t o g o t o a new l i n e
// I n p u t : none
// O u t p u t : none
// t o g g l e PortT b i t 0 e a c h t i m e , d e b u g g i n g p r o f i l e
void OutCRLF( void ) {
SCI OutChar (CR ) ;
SCI OutChar ( LF ) ;
PTT ˆ= 0 x01 ; // t o g g l e b i t 0
}
char s t r i n g [ 2 0 ] ; // g l o b a l t o a s s i s t i n d e b u g g i n g
unsigned short n ;
void main ( void ) {
DDRT |= 0 x03 ; // PortT b i t s 1 , 0 a r e o u t p u t t o LED
SCI Init (19200); // f a s t e s t s t a n d a r d b a u d r a t e on r u n mode 9 S12C32
>> a=serial(’COM8’); % Use Device Manager (Windows) to verify this port. Assign to ‘a’
>> set(a,’BaudRate’,19200); % Set the speed to match the code running on Esduino.
>> fopen(a); % Open the ‘‘file’’ for ‘a’.
>> a % Report what is going on with this ‘file’
Communication Settings
Port: COM8
BaudRate: 19200
Terminator: ’LF’
Communication State
Status: open
RecordStatus: off
Read/Write State
TransferStatus: idle
BytesAvailable: 10
ValuesReceived: 40
ValuesSent: 0
>> out=fscanf(a); % Wait for serial data to arrive. (waits for a Carriage Return?).
>> fclose(a) % close the ‘a’ file
>> delete(a) % delete the ‘a’ file
>> clear a % clear the variable, too.
>> out % What did Matlab capture on the serial port? It’s stored in ‘out’
out =
The Revision 1 version of the Esduino’s schematics and parts layout are found here.
J-1
[JB4] TX/RX Communications Routing:
Place two shunts in the positions shown Esduino
US = USB-to-SCI (of the MCU) 9S12C-based Arduino-compatible*
When Xbee Option is present: Rev. 1
UX = USB-to-Xbee (for configuring via Host) [JB3]: Digital11 Source
SX = SCI-to-Xbee (for wireless communications) 1-2 (left): PM4
[U4]: Serial Memory [JB2]: Digital10 Source 1-3 (down): PP5 (PAD1)
Footprint for optional 1-2 (left): PT4 1-4 (right): PT5
[J14][J15]: USB2MCU module goes here, SPI memory device. 2-3 (right): PM3
to provide USB interface to host PC; [D2]: User LED [U1]:
or supply your own TTL-level signals (on DIG13) Freescale 9S12C 16-bit microcontroller
to/from Host
[JB8] PS/PM SELECT:
PT3
PT7
PT6
PT2
PT1
PM5
PM2
PAD07
PAD06
DIG1
DIG0
PT0
Select between PS0/PS1
J14 US JB4
GND J3 and PM0/PM1 assignments
[J9][J10]: [Xbee Option]
>
<
D2
+5V
J1
for DIG0 and DIG1 pins
D13
D12
D11
D10
D9P
D8
D7
D4
Plug ADXB here for XBee Interface U4
GND
DTR
SX UX
UX SX
AREF
PT4 PM3 S M
(3V/5V compatible). SPI [J11] BDM IN:
DIG11
PWM D6
PWM D5
<TX US J6 C17
D2 JB2
1 PWM D3
GND J15 DI PM4 PT5
JB8
[J6]: SPI peripheral connector Standard 6-pin Background
RX > ADXB +5 JB3
SPI signals, Output Enable, +5V, J10 Esduino Debug Mode connector for
SCK
PP5
JB1
BDM IN
and Ground are all brought out to www.TechnologicalArts.com advanced debugging use
SS* R5 J11 LOAD
VIN C6
this convenient connector for easy OE* J5 JB6 SW1
USB [SW1 and JB6]:
interfacing to SPI peripherals DO C5 MAN
PB4 R1
G C7
When JB6 set to MAN, use SW1 to
[JB1]: 5V Source Selector PWR PE7 select Serial Monitor mode.
D3 C10
AUTO RUN
PE4
1-2 (lower): 5V from USB Y1 When JB6 set to AUTO, Serial
U1
R6 D1 PA0 R3
2-3 (upper): 5V from U1 via VIN C1 C11
J8 PM0 Monitor mode must be controlled
+
J9 Y2 JB5 PM1
[D1]: Power indicator LED by host via DTR line on serial port.
R2 3V 5V J7 AN7
J12 C16 VDD VRH AR
AN6
C15 C14 JB7
[J7] PB4, PE7,PE4,PA0: C9 [J8] PM0 - PM1:
U3
Four bonus Digital pins. +
RESET
VIN
AN0
AN1
AN2
AN3
AN4
AN5
GND
GND
J4
SW2
REV. 1 J13
[U3]: 3.3V regulator (800 mA max.) transceiver to implement a
CAN interface.
PAD00
PAD01
PAD02
PAD05
PAD03
PAD04
1
2 1 PE0/XIRQ*
SPI Signals JUMPER1 W2
+5V 100n JUMPER1
J6 9S12C
2
PM2/MISO JB8 DIG0/1 SEL
7
6 VDD PM1/TXCAN
5 PM5/SCK DIG13 PM3/SS* 1 8 PM0/RXCAN
PM3/SS* PM2/MISO 2 CS VCC 7 5 6
4 3 4
3 PT3/IOC3/PW3 DIG9/PWM 3 SO HOLD 6 PM5/SCK ARDUINO 9S12C PS0 PS1 ARDUINO
1
4 PM4/MOSI 4 WP SCK 5 PM4/MOSI J2 1 2 J1 4
2 VSS SI
PP5/PW5
PM0/RXCAN
PM1/TXCAN
PM2/MISO
PM3/SS*
PM4/MOSI
PM5/SCK
PS1
PS0
1 C3 1 AN0 AN0/PAD00 DIG0/RX 1
U4 25LCXXXA 100n 2 AN1 AN1/PAD01 DIG1/TX 2
2
CON7 3 AN2 AN2/PAD02 AN6/PAD06 DIG2 3
48
47
46
45
44
43
42
41
40
39
38
37
5VUSB U1 VDD AN3 AN3/PAD03 PT0/IOC0/PW0
4 DIG3/PWM4
J14 5 AN4 AN4/PAD04 AN7/PAD07 DIG4 5
1 VRH 6 AN5 AN5/PAD05 PT1/IOC1/PW1 DIG5/PWM6
VSSX
VSSA
USB2MCU module PT2/IOC2/PW2
VDDX
2 SEL DIG6/PWM7
attaches to J14 and J15 CON6 PT6/IOC6 DIG7 8
PM3/SS*
1
PS1/TXD
PS0/RXD
PM5/SCK
CON2 JB7
PM2/MISO
PM4/MOSI
PP5/KWP5
D2
PM1/TXCAN
PM0/RXCAN
J15 PT0/IOC0/PW0 1 36 VRH 2 CON8
DTR PT1/IOC1/PW1 PW0/IOC0/PT0 VRH J4
4 2 35 1 2 1 2
1
URX PT2/IOC2/PW2 PW1/IOC1/PT1 VDDA C9 RESET* R7 2K0 J3
3 3 1 L
3
PT3/IOC3/PW3 PW2/IOC2/PT2 3V3 PT7/IOC7 DIG8
2 4 PW3/IOC3/PT3 2 +3V3 1
1 34 AN7/PAD07 100n 3 5V PT3/IOC3/PW3 DIG9/PWM 2
3
PAD07/AN07 +5V
AUTO 5 33 AN6/PAD06 4 GND DIG10/PWM 3
CON4 JB6 VDD1 PAD06/AN06 AN5/PAD05 GND DIG11/PWM
2 6 VSS1 PAD05/AN05 32 5 4
31 AN4/PAD04 6 VIN PM2/MISO DIG12 5
PAD04/AN04 VIN
MAN PT4/IOC4/PW4 7 MC9S12C 30 AN3/PAD03 PM5/SCK DIG13 6
1
PT5/IOC5 PW4/IOC4/PT4 PAD03/AN03 AN2/PAD02 CON6 GND
8 IOC5/PT5 PAD02/AN02 29 7
CUT W3 TO W3 PT6/IOC6 9 28 AN1/PAD01 AREF 8
DISABLE PT7/IOC7 IOC6/PT6 PAD01/AN01 AN0/PAD00 PM4/MOSI
JUMPER1 10 IOC7/PT7 PAD00/AN00 27
AUTO RESET VDD VDD1 J8 PM3/SS* CON8
2
BKGD 11 26 PA0 PM1/TXCAN 1
2
3 MODC/BKGD PA0 3
SW1 PM0/RXCAN 2 VDD +5V
PB4 12 25 PE0/XIRQ*
3
2
RUN LOAD PB4 XIRQ*/PE0 VDDPLL CON2 JB5 selects JB2 JB3
1
1
5V or 3V3 2 1 3 JB3 selects source
3
1
C4 operation of DIG11/PWM
3
XCLKS*/PE7
ECLK/PE4
VSSR
VDDR
RESET*
VDDPLL
XFC
VSSPLL
EXTAL
XTAL
TEST/VPP
IRQ*/PE1
R2 470n J7 JB5
2
1
4
1
1
1
10K C6 C7 C5 AN7/PAD07 1 2
13
14
15
16
17
18
19
20
21
22
23
24
AN6/PAD06 2 JB2 selects source
2
C16 R4 4K7 100n PT4/IOC4/PW4 of DIG10/PWM
2 1
2
2
1
1 2
PP5/PW5
100n VDD
J11 BDM IN VDD R1
3K9 +3V3
2 1 VIN
2
4 3
POWER
1
6 5 PE1/IRQ* 5V out U2 LD1117S IN
1
RESET* 2 3 3
URX PS1 C8 R5 Vout Vin J12
2
1
2
8MHz
ADJ
2
2
3
1
1
2 1 PB4 470n 2
2
R3 10M
BONUS 2 PE7 RESET J13
1
1
1
22p 22p 1
2
2
4 PA0
D3 1N4148 R9 2
2 1 CON4 715R
+3V3 5VUSB
J9 PA0
2
PIN1 1 20 PIN20
PIN2 VCC AD0/DIO0 19 PIN19
2 COM SEL (JB4) Settings:
PIN3 DOUT AD1/DIO1 18 PIN18
3 DIN/CONFIG AD2/DIO2 - for normal operation, jumper 1 to 2, and 5 to 6
PIN4 4 17 PIN17 - for XBee-to-9S12 communication, jumper 2 to 4, and 3 to 5
PIN5 D08 AD3/DIO3 16 PIN16
5 RESET RTS/AD6/DIO6 - for XBee-to-host connection, jumper 1 to 3, and 4 to 6
PIN6 6 15 PIN15 +3V3 +5V Revision Notes:
PIN7 PWM0/RSSI AS/AD5/DIO5 14 PIN14 U3 LD1117S33
7 PWM1 VREF 1 -fixed J9/10 pinout
PIN8 8 13 PIN13 2 3
PIN9 [reserved] ON/SLEEP 12 PIN12 VOUT VIN -added optional SPI EEPROM (U4)
9
1
GND
GND AD4/DIO4 + C14 -added selection jumpers for DIG0/1 connections (JB6)
PWR
1
1
100n
2
ADXB Connector
2
J10 D1 + C1
PIN1 PIN20
PIN2 1 20 PIN19
2
PIN3 2 19 PIN18
3 18 NOTES:
1 PIN4 PIN17 10u 10V TANT 1
1 2
PIN10 9 12 PIN11
10 11 must implement timeout) Esduino 9S12C MCU Module
(DTR will also initiate AutoReset feature, unless W3 is open) Size Document Number Rev
B FILE: esduino0.dsn 1
Since the beam load cell from Futek is proprietary, no detailed information (e.g. GF, material parameters, # of
working bridges, etc.) is provided. As such, there is no point in calculating the expected bridge voltage signal
proportional to the applied load.
However, if you note in the specifications, Futek provides the nominal output sensitivity of 1mv/Volt. What
this means is that if you use 10 Volt d.c. reference voltage to drive the bridge, the nominal bridge output will
be 10 mv for the rated full load of 1 LB (or 1.2 LB max. allowed). Therefore, with this information you can
figure out the gain of the IA required to give you the output of 0 to 5Volts (into your A/D) for load of 0 to 1
LB. You may then fine tune the gain of the IA if necessary.
Also, it is important that you connect the ”+” and ”-” terminals of the bridge to the corresponding terminals
of your IA to get the desired positive voltage output under load; and also properly balance the bridge to get
zero voltage output under no -load condition (refer to the chapter on the load cell labs).
K-1
!"#$
%&#
'(
)%*#
!
%+
,"
#
'
(
%(
%(/%
(
((
%
((%
(#
%
( ((
%(
%
%(
%
#
5
%
("
(
(%
(
6(7
%
"%
!# '
6%$7
(
%
%(%
$
((
"%
" '/((
% (
-(
(%
( (3(8
5
(
$%
/ #
&# 5
%
(
%("(
%%
(
/%
(" '/((
% ( 7
(
(*%(#
9# 5
%
(,
("%
(
%
(
(
%" %
2
%(
(
(%%%(
(
%(
%:
(
%#
;# ,(<%=3 %"
"%
(*%(
(
$
(
(%%
&
*(
%
(("%#
("%(!
(
(
($0#&1# %
//%$
%9
(%/(
(
" (
#
>% //%*
"( ("%#
(
(( (
#5
%
(
((
(
/%
%#
%;#
9
,
%
(4
%
%
((
(%
#
, !4)
>%!2#
(%#5
%&89!
,
&4)
>%&2#
(%#5
%?8@&
,
94)
>%;2#
(%#5
%!!8!&&
,
;4)
>%@2#
(%#5
%!?8!@&
,
%
%(
%#
%%$
%
(
%
(#%
((
('(
#
, %*
%@$
+
%
(
%#
(/!A*
(
"#
;
((
(
%" (
"((
$
%B#
)(((( (
,(
(((
(
+
%(%%
(
(
%
(#'(
'#
?
#$$
%#
C(>%%
&'
!# %%
(
%
88
%(
%
(#
&#
$%(((
(
%
#
9# 3(%%%/(/%(
(
($(
%
(
%%
((
((
(
(#
;#
%%%G((
(%%#
?# (
%
"
(
%
(
(( #
@# '/
/%(
((
#
B#
"%
(%/(
/
%
#
# %%(
%(/
%((#
# '/
% %
%
((
(
(%%
%
(#
!#
%
(
%
("(
%%(&#
&'
!# *(%//%%%
(
(%
#
&# *(%(
#
9# *(%% (
" "%
/("#
;# *(
(/#
?# *(%/%%
%(#
@# *(
(%
/%#
B# *(/%
(
%%
((
($(
(%
(
(#-/(/% G
/%
(
(
%#
# *(%
(%%%(#
# *(
(
%
%(%
(#
!#*(
("(
%
(
%
;8(%"
#
@
#$$
%
*0G
14*(%
(>*/%
(%##
B
#$$
%
8(
(
(%
%
%
"
(0
4/6,$2
K-10 Edit Date: February 12, 2013
Appendix L
MEMSIC 2125
L-1
! !
MXD2125G/H/M/N SPECIFICATIONS T"15@GI1J1LD@!R!)+q&E![CC1A1I5D?7L!\!;!g!GLA1@@!7D>1IB?@1!L7D1F]!S((E!S([!\!+3;S!GLA1@@!
Improved, Ultra Low Noise 7D>1IB?@1!@N1C?8?1FU
!
M E M S IC
3 5 :;! ;3+;;! ! *+3;Z! ;3bgg! ! b3+f!
! );! ;3:Z)! ! *g3:+! ;3fZ;! ! +3bg!
4
Vref!<![!I181I1LC1!27AD561!?@!525?A5KA1!8I7J!D>?@!N?L3!!%D!?@! *;! ;3*9Z! ! *93*g! ;3fb+! ! )3bb!
Y +g @1D!5D!)3+;S!DON?C5A!5LF!>5@!*;;P[!78!FI?21!C5N5K?A?DO3! +! ;3;b9! ! *93:9! ;3ffg! ! *3:9!
;! ;3;;;! ! *93Z+! *3;;;! ! ;3*+!
Top View
! Table 1: Changes in Tilt for X- and Y-Axes
!
!
Features
y Measures ±3 g on each axis
y Simple pulse output of g-force for each axis
y Convenient 6-pin 0.1” spacing DIP module
y Analog output of temperature (TOut pin)
y Fully temperature compensated over 0 to 70 °C
operating temperature range
Theory of Operation
The MX2125 has a chamber of gas with a
heating element in the center and four
temperature sensors around its edge.
When the accelerometer is level, the hot
gas pocket rises to the top-center of the
chamber, and all the sensors will measure
the same temperature.
By tilting the accelerometer, the hot gas will collect closer to some of temperature sensors. By
comparing the sensor temperatures, both static acceleration (gravity and tilt) and dynamic acceleration
(like taking a ride in a car) can be detected. The MX2125 converts the temperature measurements into
signals (pulse durations) that are easy for microcontrollers to measure and decipher.
Copyright © Parallax Inc. Memsic 2125 Dual-Axis Accelerometer (#28017) v2.0 1/29/2009 Page 1 of 3
Pin Definitions
For Memsic MXD2125GL pin ratings, see the manufacturer’s datasheet posted on the 28017 product page
at www.parallax.com.
Communication Protocol
Each axis has a 100 Hz PWM duty cycle output in which acceleration
is proportional to the ratio tHx/Tx. In practice, we have found that
Tx is consistent so reliable results can be achieved by measuring
only the duration of tHx. This is easy to accomplish with the BASIC
Stamp PULSIN command or with the Propeller chip’s counter
modules.
With Vdd = 5V, 50% duty cycle corresponds to 0 g, but this will vary
with each individual unit within a range of 48.7% to 51.3%. This
zero offset may be different when using Vdd = 3.3 V. See the
manufacturer’s datasheet for details.
Example Circuit
The example schematic and wiring diagram below are for the BASIC Stamp and Board of Education.
The program below, SimpleTilt.bs2, simply measures the pulse width, that is, the duration of tHx, for
each axis. The raw values are displayed in the BASIC Stamp Editor’s Debug Terminal. If you run the
program, then tilt the accelerometer, you should see the values for each axis change.
Copyright © Parallax Inc. Memsic 2125 Dual-Axis Accelerometer (#28017) v2.0 1/29/2009 Page 2 of 3
' Smart Sensors and Applications - SimpleTilt.bs2
' Measure room temperature tilt.
'{$STAMP BS2}
'{$PBASIC 2.5}
x VAR Word
y VAR Word
DEBUG CLS
DO
PULSIN 6, 1, x
PULSIN 7, 1, y
PAUSE 100
LOOP
y Boe-Bot Robot Projects with the Memsic 2125 Accelerometer — The following projects with
source code are posted under the Stamps in Class Mini-Projects sticky-thread in the Stamps in Class
Forum at http://forums.parallax.com:
o Boe-Bot Robot Navigation with Accelerometer Incline Sensing
o A Tilt Radio Controller for Your Boe-Bot
y The Memsic 2125 Demo Kit BASIC Stamp Source Code — this source code contains conditional
compile directives that allow it to be used with the BS2, BS2e, BS2sx, BS2p, and BS2pe.
Propeller Objects
Several Memsic 2125 Accelerometer code objects and applications
for the Propeller chip are available in the Propeller Object Exchange
(http://obex.parallax.com).
Copyright © Parallax Inc. Memsic 2125 Dual-Axis Accelerometer (#28017) v2.0 1/29/2009 Page 3 of 3
Appendix M
M-1
http://www.evbplus.com/Code_Warrior_hcs12.html
CodeWarrior is a very powerful and professional IDE. The main feature of CodeWarrior IDE is the
source level debugger in assembler and C. CodeWarrior Special Edition is a wonderful gift from
Freescale to all of us and it's free for educational use. What's more, by CodeWarrior supporting
serial monitor, they have made it very affordable to support CodeWarrior for the OEM.
Freescale has invested millions of dollar into CodeWarrior and the current versions work very well.
What's more, Freescale knows they will never sell enough copies of CodeWarrior to make back
what they have invested. They did it to drive chip sales.
As a software developer, the first thing you look at is available tools and what it will cost.
There are many companies making MCU chips these days and for the most part they all have
about the same features at a similar price. Special Edition CodeWarrior sets Freescale apart from
others. There is no any MCU chip maker offers you a such first class C source level
debugger free of charge.
CodeWarrior IDE does not work with D-Bug12, but it works with serial monitor. Before Freescale
created the serial monitor a BDM is needed as an interface between the PC and HCS12. Freescale
created the serial monitor for working with CodeWarrior to eliminate the cost of a BDM.
Now a student can use the serial monitor with CodeWarrior to debug his programs and in fact,
many universities have been using the serial monitor with CodeWarrior without a BDM in their
classrooms.
Without spending money on a BDM, a student will be able to spend his savings on purchasing a
more advanced trainer, like the Dragon12-Plus board with many on-board peripherals. Purchasing
an EVB board that comes with a BDM at a reasonable price, most likely leaves the student with an
EVB of only limited functionality.
Some universities use D-Bug12 monitor first, then replace the D-Bug12 monitor with serial
monitor to be used with CodeWarrior IDE. In this case, a school laboratory only needs to have
one BDM or use one Dragon12 board as a BDM POD, to program all students' boards with serial
monitor.
To replace bootloader and D-Bug12 monitor with serial monitor, you need a BDM or a BDM POD to
perform the task. The procedure to program the on-chip flash memory is provided at:
www.evbplus.com/TinyBDM_9s12/TinyBDM_9s12.html
Some universities use CodeWarrior IDE only. In this case, we pre-load the on-chip flash memory
with serial monitor.
If your board is pre-installed with D-Bug12 monitor, the Port B LED indicators will light up from left to right one
at a time and the speaker will chirp once when the board is turned on. If the chirp is too soft you can remove the
sticker on the speaker to increase the volume.
If you ordered the board with serial monitor for Code Warrior, it would be pre-installed with serial monitor and a
factory test program. The state of the left switch of the 2-position DIP switch (S7) is tested by the serial monitor
for selecting RUN or LOAD mode during power up or reset, and the Port B LED indicators will light up from right
to left one at a time and the speaker will chirp once to indicate that the serial monitor is functioning.
If the left switch is placed in "LOAD" mode (in the "low" position) the monitor will wait for a command from PC.
If the left switch is placed in "RUN" mode (in the "up" position) the LED indicators will light up again from left to
right to indicate that the program execution is diverted to the user code.
Code Warrior communicates with serial monitor only in LOAD mode and so in order to interface with Code
Warrior you have to reset the left switch in the “low “position. The Port B LED indicators will light up from right to
left one at a time and the speaker will chirp once when the board is turned on.
If the serial monitor is not installed or erased by a BDM, the LED indicators will not light up one at a time during
power up or reset.
If your board is pre-installed with D-Bug12 monitor, it will display the diagnostic code “E-4-3” on the 7-segment
LED and the speaker will chirp once when the board is turned on. The code character "E" stands for EVB mode.
If you ordered the board with serial monitor for Code Warrior, it would be pre-installed with serial monitor and a
factory test program. The state of the left switch of the 2-position DIP switch (S7) is tested by the serial monitor
for selecting RUN or LOAD mode during power up or reset.
If the left switch is placed in "LOAD" mode (in the "low" position) the monitor will display the diagnostic code
“S-4-3” on the 7-segment LED and the speaker will chirp once and then wait for a command from PC.
If the left switch is placed in "RUN" mode (in the "up" position) the monitor will display the diagnostic code
“U-4-3” on the 7-segment LED and the speaker will chirp once to indicate that the program execution is diverted
to the user code.
The code character "U" stands for running a User program and the code character "S" is displayed as the
number "5" and stands for Serial monitor.
Code Warrior communicates with serial monitor only in LOAD mode and so in order to interface with Code
Warrior you have to reset the left switch in the “low “position. It will display the diagnostic code “5-4-3” on the
7-segment LED and the speaker will chirp once when the board is turned on
If the serial monitor is not installed or erased by a BDM, the LED indicators will not light up one at a time during
power up or reset.
Finally, the first book written exclusively for the CodeWarrior has
arrived.
Dr. Richard Haskell and Dr. Darrin Hanna have completed a new book for learning to program
in C using CodeWarrior. The book includes sample programs tested on our Dragon12-Plus and
the MiniDragon-Plus2 boards. The CodeWarrior itself can be daunting, but their book will make it
easy for you to learn what you need to get your project up and running quickly.
You can find a description of the book at this website: http://www.lbebooks.com/index.htm
The CodeWarrior stationery file for the Dragon12-Plus and MiniDragon-Plus2 can be used in two
new books "Learning by example using C - Programming the Dragon12-Plus using CodeWarrior"
and "Learning by example using C - Programming the MiniDragon-Plus2 using CodeWarrior". The
books are written by professors Richard Haskell and Darrin Hanna at Oakland University.
Instructions of how to download Code Warrior from Freescale's web site and CodeWarrior
tutorial can be found at Professor Paterno's web site:
http://web.njit.edu/~paterno/ECET310/T3-CodeWarrior%20Simulator.pdf
The CodeWarrior project setup procedure can be found at Professor Jeff Sumey's web site:
http://www.aet.cup.edu/~jsumey/cet360/cwintro/cwintro.html
The most resourceful “CodeWarrior for the Dragon12 trainer” web site:
http://www.mecheng.adelaide.edu.au/robotics/wpage.php?wpage_id=56
The mechanical engineering of University of Adelaide in Australia is awesome. Here you can see
what their students have achieved in so many great projects:
http://www.mecheng.adelaide.edu.au/news/
The size of either file is quite large. It will take a few hours to download, so you should first save it
on your hard drive in case you need to install it in another PC.
Following is the web site for downloading the CodeWarrior full edition for a 30-day free evaluation:
http://www.freescale.com/webapp/sps/site/overview.jsp?nodeId=01272600612247
N-1
13
HCS12 Serial Monitor
Connection
This section provides information about debugging with the CodeWarrior IDE and the
HCS12 Serial Monitor connection.
4. In the debugger main window, choose Component > Set Connection to select another
connection.
Figure 13.2 Set Connection Dialog Box - HCS12 Serial Monitor Selection
5. Select HC12 as Processor, then HCS12 Serial Monitor as connection in the Set
Connection dialog box.
6. Click the OK button.
The Monitor Setup dialog box appears.
7. In the Monitor Setup dialog box Monitor Communication tab, choose the correct Host
serial communication port if necessary.
NOTE We recommend that you use the Vector Table Mirroring feature. Otherwise,
you cannot program vectors as captured or protect them from erasure or
overwriting by the HCS12 Serial Monitor.
Figure 13.6 Monitor Setup Dialog Box - Vector Table Mirroring Tab
12. To enable this feature, check the Enable Vector Table Mirroring checkbox.
Figure 13.7 Monitor Setup Dialog Box - Vector Table Mirroring Tab
13. Click Auto Detect to make the debugger search for the vector table address and
vectors reserved by the HCS12 Serial Monitor.
14. Once automatic detection succeeds, press OK to start debugging.
Load Displays Load Executable File dialog box (see Load Executable File
Window).
Command Files Opens Connection Command Files dialog box. Each tab allows
access to a different set of connection command files:
\cmd\HCS12_Serial_Monitor_startup.cmd
\cmd\HCS12_Serial_Monitor_reset.cmd
\cmd\HCS12_Serial_Monitor_preload.cmd
\cmd\HCS12_Serial_Monitor_postload.cmd
Debugging Opens Debugging Memory Map dialog box for target MCU (see
Memory Map Debugging Memory Map).
Trigger Module Opens Trigger Module Settings dialog (see HCS12 On-Chip DBG
Settings Module or HCS12X On-Chip DBG Module).
Bus Trace Opens Trace component window within the main window (see
HCS12 On-Chip DBG Module or HCS12X On-Chip DBG Module).
5.
O-1
http://wiki.mdmsolutions.org/index.php/9s12c32MemoryMap
Ed itin g
Edit this page
CREDITS
In fo rm a tio n
Last edited on February 18,
These notes were sent to me by Eric Engler, in 2007
discussion of BinLoad. For more information, PageHistory
PageInfo
please see his website.
S ea rc h
Notes on the 9S12C32
Memory Map
LikePages
Although written for the 32K flash 9S12C32, these notes are
helpful in understanding the basic 9S12 memory paging mechanism
and many of these notes apply to other 9S12 devices, also.
User info
NOTE: AN2548 says the stack needs 35 bytes of storage for its
own use. This is often misunderstood - they are NOT
asking us to reserve the top 35 bytes for use by the
SerMon, but rather they are going to use the same
stack used by the end-user program, and the max no.
of bytes the SerMon will put on the stack is 35 bytes.
So it's safe to allocate the stack starting from the
higest avail. RAM location (SP must start one byte
higher than the top of RAM - typically $4000).
$4000: 16K fixed flash block (PPAGE block $3E). This is where user
programs will often go. This is not shared with any other
function (the $c000 block is shared with vectors and the
SerMon itself)
The 64K addressing range is called the logical address range (this is
the address range used by the PC/SP/IX/IY, etc). The type of address
that uses the PPAGE addressing scheme to reference flash blocks using
their native internal address is called a physical address.
I don't want to confuse anyone here, but I should mention that there's
two types of physical address schemes. The "paged" scheme simply uses
the PPAGE value as the high order byte. This means there's a gap
between $ffff (highest 64K address) and $3d0000 (lowest paged address).
A user program gets burned into flash from $3d0000 to $3dffff, and then
from $3f0000 to $3fffff. The CodeWarrior tool chain uses this scheme.
The "linear" scheme uses an equivalent address that builds up from the
64K range, and has no hole. The D-bug12 bootloader and the P&E tools
use this scheme. With this model you can just keep incrementing the
address one byte at a time from $00000 to $fffff (less than this,
depending on how much flash your chip has), with no holes in the middle.
Many modern debuggers and flash burning programs that run on the PC can
translate a paged address file on the fly, or the SRecCvt program can be
used to translate a paged .s19 file to a linear .s19 file. Why would
you want to translate? Because the CodeWarrior chain (and possibly
others) will generate paged addresses and you may need linear addresses
for use with the bootloader, or P&E tools, etc. P&E has their own
translation program called logtophy (logical to physical). Sometimes
people will use a different extension for a linear file: I've seen .s2
in some cases, but there is no widely used convention for this, so you
can't be sure which scheme is in use if you see a file with an .s19
extension.
The memory window at $8000 seems unimportant on the C32 since you can
directly address the entire 32K of flash using logical 64K addresses at
runtime (aside from the case of programming flash, as mentioned above).
However, you can still use the memory window and there can be a benefit
in using it. If you store $3E in the PPAGE register at address $0030,
then the $4000 block of flash will also be seen at $8000. Similarly, if
you store $3F in the PPAGE register, then the $C000 block will also be
visible at $8000. Of course, since these 2 flash blocks are also fixed,
you'll continue to see them at $4000 or $C000. The window at $8000, in
effect, results a 16K hole between the two fixed blocks of flash, but
you can use Karl's trick as mentioned above to treat this as one big
block of 30K.
Startup Code
One important factor that needs to be considered when you have a program
in flash that will run upon startup (switch in Run position): you must
have some initialization code to configure a few things before the main
program runs. You have to map the control registers and RAM, and then
set SP at the top of RAM. You should also set the PLL frequency. If
you're using gcc, the startup code has to be patched. I have a complete
demo project in my EmbeddedGNU Windows IDE, including the modified gcc
startup code. There's also code for the reset vector so your program
will execute upon powerup. You can use my code even if you don't want
to use my IDE. Be sure to look at the help file for some more info on
the C32.
However, the serial interupt is dedicated for use by the serial monitor
if running in boot mode (monitor mode). It uses these interrupts to let
it steal some MCU clock cycles so it can execute our debug commands and
send back the results. This is an invasive style of debugging because
the timer in the MCU still ticks away while the serial monitor is
running - this can cause trouble if our program is using the timer for
its purposes. It's a reasonable trade-off to make in order to get
low-cost debugging over the serial port. In cases where we need less
If we run in boot mode then the serial monitor, while still present in
flash, is not actually active. However, the vectors just below $f800
are still used in the boot mode because we're not allowed to modify the
protected flash range where the serial monitor lives ($f800 - $ffff).
How does the C32 MCU know that it's supposed to use our vectors and not
the serial monitor vectors if we're running in the boot mode? Because
the serial monitor has firmware vectors in place that will trap all of
the interrupts, and it will direct those interrupts to the new vector
table if the serial monitor is not active. Even the serial port
interrupt, normally used only by the serial monitor in program mode, is
redirected to our own vector table in boot mode.
Answers provided to the Instructor assume that the reader is using Freescale HCS12C Family Student Learning Kit,
and CodeWarrior development software.
This short course has been created using an adapted version of the Process Oriented Guided Inquiry Learning (POGIL)
method. For more information visit www.pogil.org
Introduction to CodeWarrior™ –
Simulating the Microcontroller in
Assembly Language
www.freescale.com/universityprograms
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
All other product or service names are the property of their respective owners
© Freescale Semiconductor, Inc. 2006.
Document Number: LABS12CINTRO03S /REV 1 Freescale Semiconductor LABS12CINTRO03S, Rev 1 1
Page 3: Check the language support you want (Assembly) and click Next.
Overview
Page 4: Check Relocatable Assembly.
A laboratory experience is vital for us to be able to start programming the microcontroller and to be able to really understand how it
works and to apply it in embedded system designs. This module shows the student how to enter an assembly language program in Page 5: Check Full Chip Simulation and P&E Multilink/Cyclone Pro and click Finish.
the CodeWarrior® integrated development environment and then to simulate its execution using the True-Time simulator/debugger. In the Project Manager Window
4. Switch to the Full Chip Simulation for debugging by clicking the pull down arrow and selecting Full Chip Simulation. (This
Learning Objectives does not use the hardware for debugging. If you want to actually use the HCS12 hardware, choose P&E Multilink Cyclone
In this module we introduce you to the CodeWarrior® programming environment. We will see how to start the system and enter a Pro.)
program to be run with the debugger. In the next module we will give you a program and you will start to learn to use the HCS12
instruction set by modifying if to change how it operates.
Success Criteria
At the end of this module you will be able to assemble a program and to run and debug it with the CodeWarrior simulator/debugger.
Prerequisites
You must know about the HCS12 instruction set and the memory addressing modes available. You do not have to know the
instruction set in detail. The following lab modules will help you learn that.
More Resources and Further Information 5. Create listing files by opening the Simulator Settings panel by clicking the icon shown above.
Cady, Fredrick M., Software and Hardware Engineering: Assembly and C Programming for the Freescale HCS12
a. Click on + next to Target in the Target Settings.
Microcontroller, 2nd edition. (New York: Oxford University Press, Inc., 2008). Chapter 5 An Assembler Program, Chapter 6 The
Linker, Chapter 7 The HCS12 Instruction Set. b. Highlight Assembler for HC12 and in that panel click on Options.
Smart Linker, Metrowerks Corporation, Austin, TX, 2003. (i) Check Generate a listing file.
Debug (DBG) Module V1 Block User Guide, S12DBGV1/D, Freescale Semiconductor, 2003. (ii) Check Object File Format. Choose ELF/DWARF 2.0 Object File Format.
MC9S12C128 Data Sheet: Covers MC9S12C Family and MC9S12GC Family, Freescale Semiconductor, Austin, Texas, 2005. (iii) Click OK.
Montañez, E. and Ruggles, S., MCUSLK_CSM12C32 - Getting Started with the Microcontroller Student Learning Kit c. Click OK.
(MCUSLK), Freescale Semiconductor, Austin, Texas, 2005.
6. Open the Sources folder (click on the + if it is not open).
Sibigtroth, J. M., CPU12RM/AD rev. 3 – CPU12 Reference Manual, Freescale Semiconductor, Austin, Texas, 2002.
7. Double click on main.asm and enter the following code after the comment
Williams, J., AN2548SW1 – CodeWarrior Project Software files for AN2548/D, Freescale Semiconductor, Austin, Texas, 2003.
; Your program code goes here.
Debugger HCS12 Onchip DBG Module User Interface, Metrowerks, 2003.
; Your program code goes here
; Initialize I/O
Using the CodeWarrior® Simulator main_loop:
; DO
1. Launch the CodeWarrior IDE. nop ; A "no operation" operation
a. From the Windows desktop, click Start > Programs > Freescale CodeWarrior > CW for HC12 Vx.x > CodeWarrior IDE. ldx #ConstData ; Initialize X with an address
ldab #$02 ; Initialize a counter with data
2. Create New Project. ; Load and store data in a loop
a. From the IDE main menu bar, select File > New. New window appears.
loop:
ldaa 0,x ; Get the data
b. Highlight HC(S)12 New Project Wizard. staa VarData ; Store it in RAM
ldaa 2,x ; Get another byte
c. Enter a Project Name that makes sense to you (like lab_x).
staa VarData+1 ; Store it
d. Enter a Location for the project. This should be on a drive or in a directory where you want to keep your HCS12 projects. inx ; Increment the pointer
decb ; Decrement the counter
e. Click OK. bne loop ; Loop until B = 0
3. In the New Project Wizard nop
; Forever
Page 2: Select MC9S12C32 (or your derivative) as the derivative you want to use and click Next. bra main_loop
Explore 2.
The linker parameter file allows us to locate the various parts of the program in the proper sort of memory. For example, all code
and constant data must be in ROM and variable data and the stack in RAM.
3. In the ConstData why does DC.B produce different data bytes for $10 and 10?
Explore 3.
In future lab exercises you may wish to add other source files to your project. Here is how you do that.
STARTUP SECTION
12. Add other source files to the relocatable files in the project:
2. When would you want to run and debug your programs using the hardware debugger?
16. Run the program without the PBMCUSLK using the CodeWarrior True-Time Simulator.
Skill Exercise 1
a. Make sure Full_Chip_Simulation is shown in the Project Manager pull down window as shown in step 4 above.
1. Double click on each of the register boxes in the Register window and enter a value of zero for each register. You won't be
b. Launch the True-Time Simulator by Project > Debug, F5, or clicking on the icon
able to change the CCR.
2. Press the Reset Target button (or type control-R) to return the program to the initial reset state.
3. Single-step through the program and complete a table showing the result of each instruction. The CCR (Condition Code
Register) bits NZVC are shown bold when the bit is set.
If a loader warning appears click OK.
Instruction D A B IX IY PC SP NZVC
c. If Simulator is not the debug target, click on Component > Set Target and chose Simulator Target Interface and click
OK. Reset state 0000 00 00 0000 0000 C000 FFFE 0000
d. If your program has not been loaded, or you want to reload it, click Simulator > Load and load bin\simulator.abs. lds
#__SEG_END_SSTACK
e. You can use all the features of the simulator on the code.
nop
Explore 4.
ldx #ConstData
After the simulator has been launched, have a look at the display:
ldab #$02
1. The Source window shows your source program.
ldaa 0,x
2. The Assembly window shows the program as it looks in memory. Right Click in the Assembly window and check Display
Code to make your display show the code in the memory locations $C000 - $C01A. Right Click again and check Display staa VarData
Symbolic to show symbolic instead of decimal addresses.
ldaa 2,x
3. The Registers window shows the current status/contents of all registers.
staa VarData+1
4. The Data window will show the current value of constant and variable data in your program. Click on the +ConstData to show
inx
the four constant data bytes. Right Click on ConstData and select FORMAT ALL Hex. Click on the +VarData to show the two
variable bytes. decb
5. The Procedure window shows what procedure you are currently in and the Command window allows you to enter bne loop
simulator/debugger commands.
ldaa 0,x
6. The Memory window allows the display of memory contents. Right Click in the Memory window and select Address . . . and
in the Display Address window enter C000. staa VarData
Japan:
Freescale Semiconductor Japan Ltd.
Headquarters
ARCO Tower 15F
1-8-1, Shimo-Meguro, Meguro-ku,
Tokyo 153-0064
Japan
0120 191014 or +81 3 5437 9125
support.japan@freescale.com
Asia/Pacific:
Freescale Semiconductor Hong Kong Ltd.
Technical Information Center
2 Dai King Street
Tai Po Industrial Estate
Tai Po, N.T., Hong Kong
+800 2666 8080
support.asia@freescale.com
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other
product or service names are the property of their respective owners. ARM is the registered
trademark of ARM Limited. ARM9, ARM11, and ARML210™ are the trademarks of ARM Limited.
Java and all other Java-based marks are trademarks or registered trademarks of Sun
Microsystems, Inc. in the U.S. and other countries. The “PowerPC” name is a trademark of IBM
Corp. and used under license.
© Freescale Semiconductor, Inc. 2006.
Document Number: LABS12CINTRO03S /REV 1
Appendix P
P-1
What's New with the 9S12? 10-11-28 11:30 AM
1. Introduction
2. Creating a new CodeWarrior Project for you M68DKIT912C32
3. Understanding how the on-chip serial monitor interacts with CodeWarrior
4. Configuring Processor Expert to be compatible with the serial monitor
5. Adding functions to our user application
6. Reviewing our code
7. Compile, Link, and Debug
8. Running the application
9. Review of what we accomplished
10. Cut to the chase - Use the custom stationery
Well let me tell you. There is tightly coded serial resident monitor that is included on every
M68MOD912C32 module. This enables you, through the CodeWarrior interface, to access virtually all
debugging features of the 9S12, through a standard serial cable. In other words, using CodeWarrior v3.0
Special Edition, and your M68DKIT912C32, you can begin writing your application. As you become more
familiar to the tools and your application becomes more sophisticated, you can upgrade to more feature rich
tools as required.
The serial resident monitor is described in detail in Application Note 2548 which include the associated
software files. You really do not need the software unless you are going to port the debugger to a different
family of devices (e.g. DP256).
Let's go step by step setting our M68DKIT912C32. Before we start, you should already have CodeWarrior
v3.0 installed on your machine. If you do not, do it now. It is a standard Windows installation procedure.
If you do not own a copy, you may download the Special Edition version at no charge. Follow the step by
step installation wizard and licensing instructions. OK, let's continue.
back to the top
Highlight HC(S)12 New Project Wizard and provide a project name. I used my_project
my_project. You will also
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 1 of 22
What's New with the 9S12? 10-11-28 11:30 AM
need to set a path location where you want your project to be created. This should be your working
directory. The next step is to select the device type.
Select the MC9S12C32. This is the device that is used on the M68MOD912C32 module. Hit next.
Now you need to select the language you will use to program your application. I have selected C for this
example. You can see you also have the options to program in Assembly or C++. You can also select all or
any combination of these. Hit next.
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 2 of 22
What's New with the 9S12? 10-11-28 11:30 AM
The wizard will ask you if you wish to use Processor Expert. Processor Expert is a tool that combines
easy-to-use component based application creation with an expert knowledge system. Functionality of CPU
and on-chip peripherals as well as higher levels of specific applications are encapsulated into components
called Embedded Beans. This powerful tool frees up developers from the long effort of learning bits and
bytes of new peripherals and how to properly set them up to implement the desired functions. It allows the
developer to describe how built-in peripherals and their hardware environment will be used and
automatically generates the code to properly initialize, write to and read these peripherals. This tool
dramatically saves the time to learn about a new device and the time to correct mistakes and help
concentrate on the real part of the application, the added value of a project.
CodeWarrior v3.0 now has support for an add on product call PC-lint from Gimpel Software. Without
going into too much detail, PC-lint finds quirks, idiosyncrasies, glitches and bugs in C and C++ programs.
The purpose of such analysis is to determine potential problems in such programs before integration or
porting, or to reveal unusual constructs that may be a source of subtle and, yet, undetected errors. Because it
looks across several modules rather than just one, it can determine things that a compiler cannot. It is
normally much fussier about many details than a compiler wants to be. If you want to know more about this
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 3 of 22
What's New with the 9S12? 10-11-28 11:30 AM
Now I think this part is really cool. The fact that you can have full IEEE compliance on float and double
variables on a 16-bit processor is neat. That is why I use it. Does it make my code larger - YES. Do I
really need this type of precision for this example - NO. But like you, I am an engineer and I think it is
neat. If you think you are going to be short of code space, and you don't need the precision, then by all
means disable it. OK, hit next please.
Now this may be one of the more important parts of the configuration wizard. This is where we select
which targets we want to support in our application. If you are not sure what a target it, think of it like a
configuration. The "Metrowerks Full Chip Simulator" is the default selection. As you would expect, that
is a simulator that does not require hardware for debugging. I think that is always a good one to include so
I would keep it. Also, let's select the "Motorola Serial Monitor Hardware Debugging" target. Do you
remember how we talked about Application Note 2548 above? Well that is the same serial monitor that is
on your M68MOD912C32 module.
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 4 of 22
What's New with the 9S12? 10-11-28 11:30 AM
Let the tool work for a little while. It is pulling all of the necessary files together that are required to create
your project as you specified it in the wizard. When it is completed, you will see something like the
following:
You have successfully created a project using the New Project Wizard. "Well that's great!", you say, "Now
what?" Hmmmm... Good question. Now we need to turn this project into something useful. Let's take a
step back and see what we actually have to work with. Our M68MOD912C32 module is plugged into a
M68DM912C32 docking module. The M68DM912C32 has two LEDs and two user switches. At the very
least, we should be able to do something with those, right? Well, the schematic of the M68DM912C32 can
be downloaded here. If we just want to take a peak at the schematic we can see that the LEDs are connect
to PT0 and PT1.
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 5 of 22
What's New with the 9S12? 10-11-28 11:30 AM
If you are like me, you like immediate gratification - just to make sure you have everything hooked up
correctly. You just want to blink the LEDs, right? Well like Uncle Albert always said, "...with great power
comes great responsibility" (for all of you Spiderman fans out there). No seriously, we have to do a few
things up front to make sure that the Processor Expert utility is configured properly with the monitor that is
already on our board.
Remember, the serial monitor is really just a separate program that is already programmed into the FLASH
of the 9S12C32. When the part comes out of reset, the PC follows the reset vector to the monitor program.
From there, the monitor decides if it should stay in the monitor program and perform a certain function (e.g.
like pass the contents of memory to the debugger so it can be displayed for you) or just load the user's reset
vector (i.e. start of your program) and pass control to the main application. The main things we have to
make sure of are:
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 6 of 22
What's New with the 9S12? 10-11-28 11:30 AM
Go to the build target pull down menu and change it from "Simulator" to "Monitor".
back to the top
You will see a green check mark disappear from the 80-pin configuration and appear at the 48-pin
configuration. You will also notice that the graphical representation of the device in the target CPU window
will change from the 80-pin version to the 48-pin version.
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 7 of 22
What's New with the 9S12? 10-11-28 11:30 AM
The 9S12C32 has 2K of on-chip RAM. Like all 9S12 devices, the memory resources are able to be
relocated throughout the memory map. The designer of the serial monitor had to make certain assumptions
of where this memory was going to exist because the monitor supports all 9S12 families spanning from 32K
all the way to 512K devices. You need to make sure that your RAM is relocated so that it ends with
location $3FFF
$3FFF. Since the 9S12C32 device has 2K, we need to relocate the memory to a starting address
$3800
$3800. In other words, 2K of RAM ($800$800) starting at location $3800 will finish at location $3FFF
$3FFF.
in order to open the bean inspector window for that particular bean. You should see the following on the
right hand side of your screen:
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 8 of 22
What's New with the 9S12? 10-11-28 11:30 AM
Go to the "Internal RAM Mapping" field of the properties tap and change the $0800 to $3800. Click on
the build options tap because we have to make a change there as well.
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 9 of 22
What's New with the 9S12? 10-11-28 11:30 AM
In fact, you see that Processor Expert has already identified an inconsistency in our configuration (as
indicated by the red exclamation points). Change the RAM address to $3800 to match what we did on the
previous tab. Also, change the value of the "Memory Model" field to small. This should resolve all of the
red exclamation point into green check marks.
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 10 of 22
What's New with the 9S12? 10-11-28 11:30 AM
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 11 of 22
What's New with the 9S12? 10-11-28 11:30 AM
Well that is it. You have done it. We have now given Processor Expert sufficient information regarding the
device that we are using (48-pin C32, already has a serial monitor installed, etc...) so that it can generate
code accordingly. Speaking of code, we haven't written any application code to do anything yet. We
haven't been blinking any LEDs. Where is our immediate gratification!
No problem, let's do that now. This is what I propose. We use one of the PWM outputs that is connected to
LED0 to modulate the brightness of the LED. Let's say every 20 msec we will update the duty cycle. So
what do we need to accomplish this? We need a function to initialize and update the PWM. We also need
a function to create a 20 msec time-base in order for us to perform our update. Boy, I am glad we have
Processor Expert!
First, let's add the PWM bean to our project. Expand the folders in the Bean Selector window to reveal the
PWM bean. The order you expand the folders is first expand CPU internal peripherals folder
and then expand the timer folder under that. You should see the PWM
bean as in the selection below:
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 12 of 22
What's New with the 9S12? 10-11-28 11:30 AM
Double-click the PWM bean and it will be added to your project. You will be asked if you want to add the
bean to all configurations for which you can reply yes and check "don't ask me again" so the box doesn't
keep popping up while we build our project.
You will see that the bean has been added to your project but the red explanation marks indicate that we
need to configure something or provide additional information for Processor Expert to be able to generate
code. It is telling us we need to set a PWM period and an initial on or off time. In addition, we need to
confirm that the correct PWM output (namely PT0) so we are directing the signal to the correct LED. If you
click the PWM period field you will see the following pop-up box:
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 13 of 22
What's New with the 9S12? 10-11-28 11:30 AM
This is a graphical tool that let's you define your PWM period. If I type in 20 msec, and a 5% error
allowed, Processor Expert tell us that it can achieve 19.040 msec which is close enough for what we are
doing. I confirm the selection with an OK and go the the Starting pulse width field.
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 14 of 22
What's New with the 9S12? 10-11-28 11:30 AM
Now we have less choices here because some pre-scalars and timebases have already been assumed from
our previous selection. If we move our mouse over the the closest values text in the possible settings
section, we can simply select from the pull down list. I chose 74.667 usec because it was my first option.
This means the very first PWM cycle will be on (or off, depending on polarity settings) for 74.667 usec and
then be the opposite polarity for the remaining 19.040 msec. Click OK to confirm that setting.
Another thing I like about this interface is that we can name our beans to something meaningful instead of
the default names. For example, in this specific case, the bean name defaulted to PWM6. That is fine but it
really doesn't mean anything to me at the application level. Let's call it, LED_D2; at least that matches the
schematic! It is in fact connected to PT0 so the output pin selection is correct. You should see something
like this when you are done:
As a side note, if your view does not look like this, make sure that you have the "Advanced" button
selected. This changes the number of fields you can view. The view buttons are located in the lower left
OK, now that we have added the PWM functionality, let's add the time-base that we will use for our update
frequency. Go back to the Bean Selector window to reveal the Timer Interrupt bean. The order you expand
the folders is again to expand CPU internal peripherals folder and then expand the
timer folder under that. You should see the Timer Interrupt bean as in the selection below:
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 15 of 22
What's New with the 9S12? 10-11-28 11:30 AM
Double-click this bean and add it into your project. Once again, we will see some red exclamation marks
indicating that Processor Expert needs additional information from us. Just as we did before, select the
period field and enter a value of 20 msec. I also renamed the bean to something more meaningful to the
application, TI1_20ms. You should see something like this:
I want to take this opportunity to show you something really cool about Processor Expert. The reason why
we have gone to the trouble of creating a periodic interrupt of 20 msec is because we want to execute a
piece of code every 20 msec, namely, updating the PWM duty cycle. That implies interrupt service routine
and things of that nature, right? Well, Processor Expert handles all of that for you automatically. It creates
a C file called Events.c
Events.c. In this file are all of the functions that are included in the scope of the event
handler (i.e. interrupt vectors). In other words, Processor Expert generates all of the necessary function calls
associated with the events. All you need to do is add you code within the 'brackets' of the function. Pretty
cool, huh? If it doesn't make sense quite yet, it will.
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 16 of 22
What's New with the 9S12? 10-11-28 11:30 AM
In the picture above, I clicked the "Events" view of the Bean Inspector. There you can see that there is
going to be an event procedure (i.e. function call) named TI1_20ms_OnInterrupt() and it is going
to be included in the file Events.c
Events.c. OK, enough of that, when you see the code it will be entirely clear.
back to the top
1. Set up the CPU, clock speed, and RAM to accommodate serial monitor on the 9S12C32 device
2. Created a PWM function to control the brightness of LED_D2
3. Created a 20 msec time-base interrupt
This is going to generate all of the necessary files based upon the inputs we gave Processor Expert. Once
that is compete, click the files tab so you can see all of the file that Processor Expert created for us. You
may also need to expand the "Generate Code" folder and the "User Modules" folder.
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 17 of 22
What's New with the 9S12? 10-11-28 11:30 AM
As a general rule of thumb, do not modify the files in the "Generate Code" folder. Let this be the working
folder for Processor Expert. Your working directory should be the "User Modules" folder. Your main()
routine is contained in my_project.c
my_project.c. All of the interrupt handler functions are contained in
Events.c
Events.c.
Double-click the Events.c file to open it in the editor. Scroll down to the function (line 53) You will
see the following function handler:
The comments indicate where we should write the code we want to be executed each time the event
TI1_20ms_OnInterrupt() is called. Namely, we want to update the PWM duty cycle. If we open
the LED_D2.c file, we can see all of the functions that Processor Expert created for us.
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 18 of 22
What's New with the 9S12? 10-11-28 11:30 AM
void TI1_20ms_OnInterrupt(void)
{
/* Write your code here ... */
static word x;
LED_D2_SetRatio16(x); /* Update the new PWM duty cycle. */
x+=500; /* Add 500 to the last value of x. */
}
You can copy and paste the text here directly if you would like. When you are done, your file should look
like the following:
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 19 of 22
What's New with the 9S12? 10-11-28 11:30 AM
All right, it is gratification time. Make sure that your M68DKIT912C32 is has power and is connected to
the serial port of your PC. Also make sure you don't have any other programs running that may currently be
connected to the serial port (like a Palm Pilot sync or something like that). make sure that the little switch
on your M68MOD912C32 module is in the "boot" position and then hit the reset button in the middle of the
board.
This will compile, link, and launch the debugger. The debugger will negotiate with your serial monitor,
erase the FLASH in the 9S12C32, and download the executable file we just created. If this operation is
successful you will see the following:
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 20 of 22
What's New with the 9S12? 10-11-28 11:30 AM
Click the green "GO" button and your program will execute on your M68DKIT912C32. LED_D2
should periodically change from bright to dim and then back to bright again. There should be a little
gratification there, right?
back to the top
Not too bad. I wanted you to have a chance to make all of these adjustments so you could understand all of
the pieces of the puzzle. It is like learning how to drive a car with a standard transmission so that you are
able to appreciate the automatic one (thanks Dad!). OK, we understand it now so we don't really want to
have to perform all of these steps every time we want to create a new application using the
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 21 of 22
What's New with the 9S12? 10-11-28 11:30 AM
M68DKIT912C32 with the serial monitor. Well, luckily we do not have to. We can copy the project that
we have and place it in the "Stationery" folder within the CodeWarrior Installation. That way, the next time
we have a project we can use the stationery and it will already be configured for us.
back to the top
I have created a piece of default stationery specifically for your M68DKIT912C32. It has I/O defined for
the LEDs and the two switch buttons. It has a periodic 20 msec interrupt event. Every 20 msec it updates
the PWM output duty cycle to an LED so it appears to get brighter, brighter, brighter, and then dimmer,
dimmer, dimmer. Also, every 20 msec it polls the state of SW3, if it is pressed, it turns on the other LED. If
it is not, the LED remains off. All of the functionality is within the Events.c. file so the user can write
all of your own code. You can remove the code in the Events.c file as well, I just put it in there so you
would know that your program was working OK.
You will need to unzip the file into the Stationery directory shown in the figure below:
You have completed this tutorial and this section. Good Luck!
back to the top
http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 22 of 22
P-24 Edit Date: February 12, 2013
Appendix Q
Listing Q.1: Example for blinking an LED on PM5 based on Timer Overflow. Uses Assembler and is compatible
with Esduino and Codewarrior (tested Nov. 2010). Modified from code found at www.microdigitaled.com
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
; ∗ This s t a t i o n e r y s e r v e s as t h e framework f o r a ∗
; ∗ user a p p l i c a t i o n ( s i n g l e f i l e , absolute assembly a p p l i c a t i o n ) ∗
; ∗ For a more c o m p r e h e n s i v e p r o g r a m t h a t ∗
; ∗ d e m o n s t r a t e s t h e more a d v a n c e d f u n c t i o n a l i t y o f t h i s ∗
; ∗ processor , please see the demonstration a p p l i c a t i o n s ∗
; ∗ l o c a t e d in the examples s u b d i r e c t o r y of the ∗
; ∗ F r e e s c a l e C o d e W a r r i o r f o r t h e HC12 Program d i r e c t o r y ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
;
; − − − − − − − − − − − − − − − − − − − − − − − − − − − −
; This code m o d i f i e d from t h e o r i g i n a l f i l e , Timer Overflow AssemProg . t x t
; f o u n d a t h t t p : / / www . m i c r o d i g i t a l e d . com/HCS12/ Hardware / Dragon12 / C o d e w a r r i o r a s m
; There a r e o t h e r e x a m p l e s o f A s s e m b l e r code w r i t t e n t o work w i t h
; C o d e w a r r i o r ( i . e . p r o b a b l y assume t h e u s e o f t h e S e r i a l M o n i t o r and
; n o t DBUG−12 o r a BDM m o d u l e ) .
;
; James S m i t h ; Nov . 2 0 1 0 .
; − − − − − − − − − − − − − − − − − − − − − − − − − − − −
; export symbols
XDEF Entry , Startup ; e x p o r t ’ Entry ’ symbol
ABSENTRY Entry ; for a b s o l u t e a s s e m b l y : mark t h i s as application entry point
; I n c l u d e d e r i v a t i v e −s p e c i f i c d e f i n i t i o n s
INCLUDE ’ mc9s12c32 . i n c ’
; v a r i a b l e / data section
; code section
ORG ROMStart
; Include d e v i c e i n i t i a l i z a t i o n code
; INCLUDE ’ MCUInit . i n c ’
Entry :
Startup :
; remap t h e RAM & ; EEPROM h e r e . S e e EB386 . p d f
ifdef HCS12 SERIALMON
; s e t r e g i s t e r s at $0000
CLR $11 ; INITRG= $ 0
; s e t ram t o end a t $3FFF
LDAB #$39
STAB $10 ; INITRM= $ 3 9
Q-1
LDS #RAMEnd+1 ; initialize the stack pointer
endif
LDAA #$80
STAA TSCR1
LDAA #$04 ; P r e s c a l e r =16 ( Try 0−7 v a l u e s t o s e e c h a n g e s on LEDs )
STAA TSCR2
LDAA #0
OVER BSET TFLG2,%10000000 ; c l e a r t h e Timer o v e r f l o w f l a g ( w r i t i n g HIGH c l e a r s i t )
H1 BRCLR TFLG2 , mTFLG2 TOF, H1 ; w a i t f o r Timer O v e r f l o w
INCA ; keep adding the o v e r f l o w s
STAA PTM ; and dump i t on PORTM t o s e e PTM o r PTIM?
BRA OVER
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
;∗ Interrupt Vectors ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
ORG $FFFE
DC.W Entry ; R e s e t V e c t o r . CPU w a k e s h e r e and i t is sent to start of the code at $4000
Listing Q.2: Example for blinking an LED on PM5 based an Interrupt Service Routine linked to RTI. Uses
Assembler and is compatible with Esduino and Codewarrior (tested Nov. 2010). Modified from [12] example
11-18.
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
; ∗ This s t a t i o n e r y s e r v e s as t h e framework f o r a ∗
; ∗ user a p p l i c a t i o n ( s i n g l e f i l e , absolute assembly a p p l i c a t i o n ) ∗
; ∗ For a more c o m p r e h e n s i v e p r o g r a m t h a t ∗
; ∗ d e m o n s t r a t e s t h e more a d v a n c e d f u n c t i o n a l i t y o f t h i s ∗
; ∗ processor , please see the demonstration a p p l i c a t i o n s ∗
; ∗ l o c a t e d in the examples s u b d i r e c t o r y of the ∗
; ∗ F r e e s c a l e C o d e W a r r i o r f o r t h e HC12 Program d i r e c t o r y ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
;
; − − − − − − − − − − − − − − − − − − − − − − − − − − − −
; T h i s c o d e i s an a d a p t i o n o f Example 11−18 f r o m t h e t e x t
; ”HCS12 M i c r o c o n t r o l l e r and Embedded S y s t e m s : U s i n g A s s e m b l y
; and C w i t h C o d e W a r r i o r b y Mazadi and C a u s e y .
;
; James S m i t h ; Nov . 2 0 1 0 .
; − − − − − − − − − − − − − − − − − − − − − − − − − − − −
; export symbols
XDEF Entry , Startup ; e x p o r t ’ Entry ’ symbol
ABSENTRY Entry ; f o r a b s o l u t e a s s e m b l y : mark this as application entry point
; − − − − − − − −
; I n c l u d e d e r i v a t i v e −s p e c i f i c d e f i n i t i o n s
INCLUDE ’ mc9s12c32 . i n c ’
; − − − − − − − −
; v a r i a b l e / data s e c t i o n
; − − − − − − − −
; code s e c t i o n
ORG ROMStart
Entry :
Startup :
; −−−−−−−−−−−−−−−−−−−−− don ’ t t o u c h a n y t h i n g BELOW h e r e −−−−−−−−−−−−−−−−−−−−−
; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
; remap t h e RAM & EEPROM h e r e . S e e EB386 . p d f
i f d e f HCS12 SERIALMON
; s e t r e g i s t e r s at $0000
CLR $11 ; INITRG= $ 0
; s e t ram t o end a t $3FFF
LDAB #$39
STAB $10 ; INITRM= $ 3 9
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
;∗ Interrupt Vectors ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
ORG $FFF0 ; V e c t o r t a b l e l o c a t i o n f o r RTI i n t e r u p t
DC.W RTI ISR
ORG $FFFE
DC.W Entry ; Reset V e c t o r . CPU w a k e s h e r e and it is sent to start of the code at $4000
2. Connect the BDM programmer (also known as a “debugger”), such as that shown in Fig. Q.1.
(a) Use either the Tech. Arts or Wytec open-source BDM (USBDM) or the P&E Multilink.2
(b) The red line on the BDM cable should be closest to Pin 1 on the six-pin BDM port of the Esduino.
Pin 1 is demarked with a small white square on the PCB, beside “J1”.
(c) Connect the USB port on the BDM programmer to the USB port on your “’host” computer.
4. Start a new Code Warrior project using the built-in template. Any project will do. Just make sure to
select the correct chip.
5. Once the project is created, change the debugger from “Full Chip Simulation” to your choice of debugger
hardware:
1
Initial version of these instructions were written by Thomas Behan in Winter 2011. James Smith updated them in December
2011.
2
The P&E Multilink is the easiest to set up because the drivers for it come with Codewarrior.
(a) If you are using the hardware debugger from Technological Arts or Wytec, choose TBDML. You will
have had to install the open source drivers for this device ahead of time, though.
(b) If you have the P & E Multilink debugger, then choose it instead.3
7. Click through the pop-up windows that follow until you get to the Hi-Wave “True-Time Simulator and
Real-Time Debugger” window. For instance:
(a) If you’re using the USBDM, in the USBDM configuration popup window, use the defaults.
(b) Click ‘ok’ to the “Loading new application...” warning.
(c) Click ‘ok’ to the “Debugger is going to errase...” warning.
8. The original, dummy project has now been programmed into the Esduino.
3
The P&E debugger costs two to three times as much (about $120 with shipping) as the others but it is much easier to install!
(a) Select “Load” from the appropriate drop-down menu in the Hi-Wave window:
i. ‘HC12MultilinkCyclonePro’ for the P&E Multilink
ii. ‘TBDML’ if you are using the Technological Arts or Wytec debugger hardware
(b) Browse your computer’s files, and select the file: “ESD12C32 Serial Monitor.abs”.
i. You can download the file from http://support.technologicalarts.ca/docs/Esduino/Code/
SerialMonitor/UseWithHiwave/
(c) Once the file is selected, click on “Load” (not any other ‘advanced’ option)
(d) Click ok to the “Debugger is going to mass erase...” warning.
Now, unplug power to the Esduino, then unplug the BDM hardware. Connect a USB cable between your
computer and the small USB port on the Esduino. Power up the Esduino. Fire-up Codewarrior and download
code via the HCS12 Serial Monitor option.
1. Use the USBDM’s “HCS12 programmer.exe utility that is provided in the Utilities folder of the USBDM
project.” (Carl Barnes; Tech. Arts), or
BDM Hardware vs. Serial Monitor The Esduino comes with a serial monitor that resides in its memory.
For general programming and testing, this is sufficient for connecting your Esduino to your PC. However,
a BDM cable is a better, more fool-proof way of getting code onto the Esduino. Technological Arts and
Wytec sell “cheap” BDM cables (less than $50) that require the use of open-source drivers. Some people
(like Dr. Smith) have trouble installing the drivers. An alternative is the $120 Multilink BDM from P&E.
After two months of evaluation, it’s fair to say that it’s the easiest way to get code onto the Esduino.
Memory (Assembler Programming) “one problem everyone is having is the RAMStart is defined differ-
ently depending on if the HCS12 SERIALMON symbol is defined or not. If defined the stack is started
at $3FFF+1, if not at $0FFF, which seems to cause problems on the real board but not the simulator”.
(courtesy of Anthony Bailey)
The following documents, originally written for students in BME100, will aid you in following the required
IEEE format.
R-1
Download the Template from the
BME 100 webpage. Don’t make the
document from scratch!
Write your
name in the Using the IEEE Template
“header” Write
here Student ID
Title is 24 pt Times New Roman TNR font
in the
header
A subtitle which narrows the Here
scope of your project is good!
Student ID
Introduce your topic here. Put and Full
your “Thesis statement” here. Name here.
Introduction
You are expected to use standard formatting for both your articles and for the referencing/citations. We use
IEEE (Institute of Electrical and Electronics Engineers) formatting because IEEE is the world’s largest
professional organization and you are very likely to read and write IEEE documents in your professional
(real-world!) careers.
Luckily, the Library’s RefWorks system can output to IEEE standard. You need to set this up:
As you gather articles into RefWorks you can then automatically output the references to your word
processor document.
Warning! Sometimes RefWorks cuts off parts of the citation (like location of the conference, part of the
conference name and journal number). If so, you are responsible for adding it back in!!
Example
When writing your text, you will need to add citations to tell the reader where you got your information
from. Here is an example
It was found that the interaction between the feet and the “muddy icky ground” [1] was an intractable
problem in the development of the system. Luckily, Poulakakis et al. were able to overcome this with
bounding. [2] The citations are numbered in order of usage and we make sure to add quotation marks
around text taken directly from the original paper. When there are more than two authors in a paper we
only list the first author followed by the Latin expression “et al.”
II. Conclusions
In the references, note that the first reference [1] is a Journal article (IEEE Transactions on
Instrumentation and Measurement), the second reference [2] is a conference paper and the third reference
[3] is a web link (URL).
References
[2] I. Poulakakis, J. A. Smith and M. Buchler, "Experimentally validated bounding models for the scout
II quadrupedal robot," in Robotics and Automation, 2004. Proceedings. ICRA '04. 2004 IEEE
International Conference on Robotics and Automation, Boston, USA, 2004, pp. 2595-2600 Vol.3.
[3] J. Smith, "A Study on Procrastinating Professors," BME100 Online Resources, October 2001
[Online]. Available:. BME100 Online Resources, http://www.ee.ryerson.ca/~jasmith/tado/bme100
[Accessed: May 2, 2010]
Macintosh HD:Users:jasmith:Teaching:Ryerson:BME100:2010_Summer:Citation_Standard.doc
Version 1
Refworks Update on IEEE Citation/Referencing
EXAMPLE 1:
[4] R. J. Wong and L. B. Ong, "On being careful with some features while referencing," Journal of Rons Documents,
vol. 5, pp. 45, May 2010, 2010.
Believe it or not, some online resource’s Refworks function will auto fill in both fields with the publication
year so it’s up to you to double check for inconsistencies!
EXAMPLE 2:
[4] R. J. Wong and L. B. Ong, "On being careful with some features while referencing," Journal of Rons Documents,
vol. 5, pp. 45-49, May, 2010.
Again, another mistake even though we’ve corrected our following field information
As you can see, there’s a comma in between May and 2010. Unfortunately, there’s no way around this so
you’ll have to delete the comma yourself.
=*$".6(%
9'154,%=*$".6%
O73%'%5)&Q"O`52%)("352*Q"
"
"
?(%&'$%+,&'-*%'+#%6@*78>%6??8>%$&A7%+(&$*%')#%-*%'$*%/+0$>%
%3.),-*"%'9"
"
]9"T5'*&A"777"
"
!"""#$%&'&%()#
<*4$'74,%=*$".6(%>*7%$.%?@%
*&+,-#./%0-# OP,'$/1QA"OP,'$/1Q"53-"OP,'$/1Q"
"
"
P9P9"K%)3*"53-"89R9"S$*<51-"
!"#$%&"'(%)*'+,%-.,(% "
#$%&" &'()*" +,%-*" ./0*1&" ./22/3)(4,&*-" .5&*&" 6/1"
.%'5'%/3&" ,&%3+" '$*" 7888" .%'5'%/3" &(&'*29" " :*1'5%3" 7888"
<*4$'74,%=*$".6(%>A.6,%$"#1%?@%
&*.'%/3&" $50*" &)%+$')(" -%66*1*3'" .%'5'%/3" &'()*&;" <)*5&*"
.$*.=" >%'$" (/,1" %3&'1,.'/1" 53-" '$*" 1*6*1*3.*&" 5'" '$*" *3-" "#$%&'$%()*#&%+,&'-*.#%/+0$%(-11-2$3%45%6$&%+1787"
/6"'$%&"+,%-*"6/1"2/1*"%36/125'%/39" OP,'$/1Q"*'"5)9"
"
"
T9"S2%'$"*'"5)9"
&,/$%0'$#$'.1(% "
?&*" '$*" 1*6*1*3.*" 3,2@*1" %3&'*5-" /6" '$*" %'*2" -*'5%)&" 6/1"
.%'5'%/3&9" " 76" (/," 51*" 1*6*11%3+" '/" &*0*15)" 1*6*1*3.*&A"
%3.),-*" *5.$" 3,2@*1*-" 1*6*1*3.*" ,&*-A" ,&%3+" 153+*&" 9'154,%B+'$.6%
>$*3"5<<)%.5@)*9""?&*"*34-5&$*&"6/1"'$*"153+*"&*<515'/19" 9" :33%6;378%+(&$*%&'$%$3)&-*.#%/+0$"
" K9"S2%'$A"8-9"
#$*" -5'5" 51*" &,<</1'*-" %3" B!C!!DEA" @,'" $50*" @**3" "
F,*&'%/3*-"%3"2/1*"1*.*3'"&',-%*&"B!A"DE9""73"B!GEA"6/1" <*4$'74,%B+'$.6(%
*H52<)*A" <%+&" >*1*" 1*</1'*-" '/" @*" 5@)*" '/" 6)(I" J)-"
:33%6;3#78%+(&$*%&'$%$3)&-*#.%/+0$#"
K.L/35)-A" $/>*0*1A" 3/'*-" '$5'" '$*" <%+&" $5-" @**3"
'$1/>3"%3'/"'$*"5%19"BME" ]9"Y//$"53-":9"a/@%3A"8-&9"
" 76" '$*1*" 51*" 2/1*" '$53" '$1**" *-%'/1&A" ,&*" '$*" 6%1&'"
$3)&-*.#%/+0$%(-11-2$3%45%6$&%+178"
]9"Y//$"*'"5)9A"8-&9"
2'34'.56#7"8%9,:$'.1%
85.$"1*6*1*3.*"%&"<1*.*-*-"@("5"1*6*1*3.*"3,2@*19""#$*"
1*6*1*3.*"3,2@*1"%&",&*-">$*1*"'$*"5,'$/1">/,)-",&,5))(" C4#:,(%#1+%C*34'(",6(%
@*",&*-"%3"/'$*1".%'5'%/3"6/125'&9"
O:%'(QA"OY1/0%3.*ZS'5'*"P@@1*0%5'%/3Q;"OY,@)%&$*1Q"
"
"
76"5"@//="%&"<,@)%&$*-"%3"&*0*15)".%'%*&A".$//&*"'$*"6%1&'"
),1,6#4%;*4,(% .%'(")%&'*-9"
J2%'"53("<51'&"/6"5".%'5'%/3"'$5'"51*"3/'"5<<)%.5@)*9" "#$% &'$% +44*$<)+&$3% (-*0% -(% &'$% =,41)#'$*.#% /+0$>% )(%
?&*" 5@@1*0%5'*-" 6/12&" /6" ./2<53(" 53-" N/,135)" 505%)5@)*9"
352*&"%6"</&&%@)*9" "
?&*" '$*" 5@@1*0%5'*-" 6/12" /6" '$*" 2/3'$" >$*1*" [/@/=*3A"V\;"]%)*("
1*F,%1*-9" "
"
76" '$*" <)5.*" /6" <,@)%.5'%/3" %&" >*))4=3/>3A" (/," /3)("
3**-"'$*"352*"/6"'$*"<)5.*"U*9+9"V*>"W/1=X9"
"
^/3-/3;"S<1%3+*14_*1)5+"
"
!" G"
" I.*61#4%>C#7,6%G.6A#$@%
76" '$*" <)5.*" /6" <,@)%.5'%/3" %&" /,'&%-*" '$*" ?SA" %3.),-*"
'$*"./,3'1(9" BObQE" B:,&'-*C>%6BD)&1$C>8%!O#0)'+K%A"0/)9"ObQA"3/9"ObQA"
" OK/3'$QA"OW*51QA"<<9"O&'51'"bQ4O*3-"bQ9"
"
:52@1%-+*A"83+)53-;":52@1%-+*"?"Y" "
"
?&*"'$*"&'53-51-"5@@1*0%5'%/3"/6"'$*"N/,135)"352*"%6"%'"
$5&"/3*9"
0'$#$'.1(%G.6%C6'1$%9.*6:,(% "
BME" W7%T,#'>%6:#%U$%K+5%D')/G>8%F@2.J,K+',-1A"0/)9"
2..F%
!fMA"3/9"!A"\,)("!hceA"<<9"!C!4!Cg9"
"BObQE" OP,'$/1QA"!"##$%A"ObQ'$"*-9"OY)5.*Q;"OY,@)%&$*1QA"
OW*51Q9" BfE" K7@7%X.K+'-/5>%F7%J-1)&)>%Y7%H1-/)3)#%$&%+17%
" 6Q,&,*$%X=&)A+1%E$&2-*G#>8%O7.N-5@,G+P2.F21@7A"
" 0/)9"GcA"3/9"!GA"L*.9"GCCMA"<<9"cMgc4cMhM9"
B!E" L9"89"d3,'$A"90'E+*2',+K.JK5#)-,@*3A"G3-" "
*-9"a*5-%3+A"KP;"P--%&/34]*&)*(A"!hfD9"
D" c"
&",('(H-'((,6$#$'.1% 0'$#$'.1(%G.6%B4,:$6.1':%9.*6:,(%
BObQE" B:,&'-*C>%6BD)&1$C>8%BY$R*$$C%&'$#)#>%
!,3%('$,%
OL*<51'2*3'QA"O?3%0*1&%'(QA"OY)5.*QA"OW*51Q9"
"BObQE" OP,'$/1QA"!F-,K2%A"OS%'*QA"O:1*5'%/3"-5'*Q9"
BObQE" B:,&'-*C>%6BD)&1$C8>%BY$R*$$C%3)##$*&+&)-/>% BJ3)%3*E9"P05%)5@)*;"OS%'*"352*QA"O?a^Q"
OL*<51'2*3'QA"O?3%0*1&%'(QA"OY)5.*QA"OW*51Q9" BP..*&&*-;"OL5'*QE9"
P05%)5@)*;"OS%'*"352*QA"O]*@"&%'*Q"BP..*&&*-" "
OL5'*QE9" "
" "B!DE" 7888":/2<,'*1"S/.%*'(A"&444.6#*:0,2)./#1-H
" 2,;./,;K2.A0-E2A"7888":/2<,'*1"S/.%*'(A"V/09"
?&*" '$*" ./11*.'" '(<*" 6/1" '$*" <5<*1" U'$*&%&A" GCCg9"BJ3)%3*E9"P05%)5@)*;"$''<;ZZ
-%&&*1'5'%/3X9"
>>>9./2<,'*19/1+Z5,'$/1Z"
?&*" '$*" 5@@1*0%5'*-" 6/12" /6" '$*" -*<51'2*3'" 53-"
,/)<$*#)&57%%?(%&'$%,/)<$*#)&5.#%/+0$%)/A1,3$#%&'$%#&+&$% &'()*Z.&4&'()*9$'2"BP..*&&*-;"GD"\539"GCChE9"
/1"<1/0%3.*"'$5'"%'"%&"%3A"/2%'"'$*"&'5'*Z<1/0%3.*"352*" "
61/2"'$*"<)5.*9"
76" (/," 6/,3-" '$*" '$*&%&" /1" -%&&*1'5'%/3" %3" 53" /3)%3*"
-5'5@5&*A"+%0*"'$*"-5'5@5&*"%36/125'%/3"5&">*))9" BO2..F%
"
BObQE" OP,'$/1QA"!F-,K2%A"OY)5.*Q;"OY,@)%&$*1QA"OW*51Q9"B84
B!!E" Z7%L),>%6:%L-A+1%F-0=+*)#-/%:1R-*)&'0%(-*%WL[?% @//=E9"P05%)5@)*;"OL5'5@5&*"352*QA"O?a^Q"
F)*A,)&%W$*)()A+&)-/>8%K7F-0=7[A7%&'$#)#>%D"E[>% BP..*&&*-;"OL5'*QE9"
[5)%65HA"VSA"!hhD9"
"
"
B!GE" ;7:7%[1-+&>%6F+#$%[&,3)$#%-(%D$A'/)A+1%I$=-*&%
]1%'%3+"L*0*)/<2*3'"P2/3+"S',-*3'"83+%4 B!cE" P9_9"P$/"53-"\9L9"?))253A"F@2.F@2#);.#(.
/$$*#>8%J'7Y7%3)##$*&+&)-/>%KAO)11%"/)<$*#)&5>% =+)3-'5[.F)+'3K+,-#'[.+'E.6#*:-K-'5A"
K-/&*\+1>%VF>%]^^_7%:<+)1+41$S%J*-V,$#&%Y)#` 83+)*>//-":)%66&A"V\;"Y1*3'%.*4[5))A"!hfG9"B84
&*1'5'%/3&"53-"#$*&*&A"$''<;ZZ @//=E9"P05%)5@)*;"P:K"L%+%'5)"^%@151(A"$''<;ZZ
>>>9<1/F,*&'9./2"BP..*&&*-"GC"`*@9"GCChE9" </1'5)95.29/1+Z"BP..*&&*-;"DC"\539"GCChE9"
" "
=6$':4,%.6%I.*61#4%
BObQE" OP,'$/1QA"O#%')*QA"!O#0)'+K%A"0/)9"ObQA"3/9"ObQA"
OL5'*QA"<<9"O&'51'"bQ4O*3-"bQ9"BJ3)%3*E"P05%)5@)*;"
OL5'5@5&*"352*QA"O?a^Q"BP..*&&*-;"OL5'*QE9"
"
J17*34'(",+%-.:*A,1$% "
L/" 3/'" %3.),-*" ,3<,@)%&$*-" -/.,2*3'&" %3" '$*" B!eE" 6I-AG%:/A'-*#%H$$=%cT-+&.%Q*-0%Q1-+&)/R>8%
@%@)%/+15<$(9""J3)("1*6*1"'/"'$*"-/.,2*3'"%3"'*H'9" 6-P-K.4'57A"0/)9"McA"3/9"!GA"L*.9"!hhcA"<9"!!9"
D1$,6K',L(M%,$:N% BJ3)%3*E9"P05%)5@)*;"P.5-*2%."S*51.$"Y1*2%*1A"
$''<;ZZ>*@9*@&./$/&'9./2"BP..*&&*-;"!C"`*@9"
UOP,'$/1QA"<1%05'*"./22,3%.5'%/39"OK/3'$Q"OW*51Q9X"
GCChE9"
"
"
E,$$,6(M%,$:N% "
aB:,&'-*C>%6BD)&1$C8>%,/=,41)#'$37b" 76" '$*" 51'%.)*" $5&" 5" LJ7" UL%+%'5)" J@N*.'" 7-*3'%6%*1X" /1"
" [L^" U[53-)*" S(&'*2" 7-*3'%6%*1X" 1*6*1*3.*A" ,&*" %'"
" %3&'*5-"/6"'$*"?a^"/6"'$*"-5'5@5&*9"
J)-"K.L/35)-"$5-"5"6512">%'$"051%/,&")%0*&'/.="UJ)-" "
KAY-/+13>%6K5%L)($8>%,/=,41)#'$37b" B!ME" @7%K+#-/>%6F-00$/&#%A-/#)3$*$3%'+*0(,1>8%
" J6U./&A684."0KK2,-'A"0/)9"DeA"3/9"GA"\,3*"
GCCDA"<<9"!GC4!GG9"BJ3)%3*E9"P05%)5@)*;"P:K"
L%+%'5)"^%@151(A"-/%;!C9!!ceZfgGhc!9fgGhhM"
BP..*&&*-;"DC"\539"GCChE9"
"
e" M"
P$",6%J(,G*4%;,G,6,1:,(%
#$*1*" 51*" /'$*1" '(<*&" /6" 25'*1%5)&" '$5'" $50*" 3/'" @**3" ",%.G%0.1$,1$(%
./0*1*-"%3"'$%&"F,%.="+,%-*9""Y)*5&*"1*6*1"'/"'$*"6/))/>%3+"
!"#$%&"'(%)*'+,%-.,(%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%R%
6/1"2/1*"%36/125'%/3"U@/)-*-"1*6*1*3.*&"51*"<1*6*11*-X;"
" &,/$%0'$#$'.1(%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%R%
Q=RS% DBBBM%!"""#$%&'()*+#,%-.*)/#,)/0*#1(.2*M% 2'34'.56#7"8%9,:$'.1%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%R%
DBBB%0.A7*$,6%9.:',$8M%T.KN%UVVWN%QP14'1,SN%%
T*3*15)"a,)*&"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"!"
=K#'4#34,X%DBBB%0.A7*$,6%9.:',$8M%%
"$$7XHHLLLN:.A7*$,6N.65H#*$".6H($84,H% P,'$/1&"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"G"
:(O($84,N"$A%Q=::,((,+X%?V%I#1N%UVVYSN% S%3+)*"P,'$/1"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"G"
K,)'%<)*"P,'$/1&"U,<"'/"DX"dddddddddddddddddddddddddddddddddddddddd"G"
Q=US% <*6+.:"%J1'K,6('$8M%3%4#)%#$.)*#5*6*+*7-*8#!# K,)'%<)*"P,'$/1&"U2/1*"'$53"DX"ddddddddddddddddddddddddddddddd"G"
!"""#,)/0*9%QP14'1,SN%=K#'4#34,X%<*6+.:"%% 8-%'/1&"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"G"
J1'K,6('$8M%"$$7XHHLLL4'3NA*6+.:"N,+*N#*H Y)5.*&"53-"Y,@)%&$*1&"dddddddddddddddddddddddddddddddddddddddddddddddd"G"
G'1+H:'$#$'.1H',,,N"$A4%Q=::,((,+X%?V%I#1N%
0'$#$'.1(%G.6%C6'1$%9.*6:,(%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%?%
UVVYSN%
R//="dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"D"
BPDE" 7888A"&444.4E-,#)-+K./,;K2.U+'0+K7"BJ3)%3*E9"" 7'*2"%3"5"^51+*1"R//="ddddddddddddddddddddddddddddddddddddddddddddddddd"D"
P05%)5@)*;"7888A"$''<;ZZ>>>9%***9/1+Z</1'5)Z
:/36*1*3.*ZY1/.**-%3+"dddddddddddddddddddddddddddddddddddddddddd"D"
.2&k-/.&k%</1'5)&Z%</1'5)&Z<,@)%.5'%/3&Z5,'$/1&Z
'153&N3)Z&'()*253,5)9<-6"" \/,135)"UY5<*1"6/125'X"dddddddddddddddddddddddddddddddddddddddddddddddd"c"
BP..*&&*-;"DC"\539"GCChE9" S'53-51-"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"c"
#*.$3%.5)"a*</1'"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"c"
BPcE" K9:9#9"]%)&/3A"&/&.O#0)'+K.F-,K2.J\\)2P-+,-#'3A"
#$*&%&ZL%&&*1'5'%/3"ddddddddddddddddddddddddddddddddddddddddddddddddddddd"e"
\539"GCC!9"BJ3)%3*E9"P05%)5@)*;""
$''<;ZZ>>>9*629)**-&95.9,=Zl251=Z7S75@@1Z"" ?3<,@)%&$*-"L/.,2*3'"dddddddddddddddddddddddddddddddddddddddddddddd"e"
BP..*&&*-;"DC"\539"GCChE9" 73'*10%*>&A"*'.9"dddddddddddddddddddddddddddddddddddddddddddddddddddddddd"e"
^*''*1&A"*'.9"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"e"
BPeE" JKK.F@+,.OJ/D.O#0)'+K.J\\)2P-+,-#'./#0)123A"
0'$#$'.1(%G.6%B4,:$6.1':%9.*6:,(%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%]%
P@@1*0%5'%/3&9./29"BJ3)%3*E9"P05%)5@)*;""
$''<;ZZ>>>95@@1*0%5'%/3&9./2ZN5&95&<"" ]*@"&%'*"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"M"
BP..*&&*-;"DC"\539"GCChE9" 84R//="dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"M"
P1'%.)*"/1"\/,135)"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"M"
BPME" 7888A">]]^.&444./,+'E+)E3./,;K2.U+'0+K9"
BJ3)%3*E9"P05%)5@)*;"7888A"$''<;ZZ P$",6%J(,G*4%;,G,6,1:,(%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%^%
&'53-51-&9%***9/1+Z+,%-*&Z&'()*Z"
GCChkS'()*kK53,5)9<-6""
BP..*&&*-;"e"`*@9"GCChE9"
<.6,%Z,47[%
#$*1*"%&"%36/125'%/3"%3"BPD!PeE"'$5'".53"@*"$*)<6,)" >$*3" "
,&%3+"5@@1*0%5'%/3&A"53-"%36/125'%/3"%3"BPME"'$5'"%&",&*6,)" L%-" (/," =3/>" '$5'" '$*1*" %&" &/2*/3*" 5'" '$*" E'36#68" >%'$"
%3">/1-".$/%.*A"<,3.',5'%/3"53-"&'()%3+;" &<*.%5)%j*-"%36/125'%/3"&=%))&"%3"(/,1"51*5"/6"&',-(m""
" "
#$%&" %&" (/,1" 9*3\,:$% 97,:'#4'($A" 53-" $*Z&$*" %&" $*1*" '/"
&87," 9.*6:,"
",47%8.*%5,$%#%3,$$,6%*1+,6($#1+'15%.G%$",%6,(.*6:,(%
P@@1*0%5'%/3&",&*-"%3" BPDA"<<9"!D4!cE" 8.*%1,,+%$.%(*::,,+"5'"L5)$/,&%*"?3%0*1&%'(9"
1*6*1*3.*&" "
#/"6%3-"/,'">$/"(/,1"&,@N*.'"&<*.%5)%&'"%&A"/1"6/1"$*)<">%'$"
7888"#153&5.'%/3&A"\/,135)&" BPDA"<<9"!e4!gE" '$%&"53-"/'$*1"-5'5@5&*&A"./3'5.'"5"E'36#6'#1;"
"
53-"^*''*1&"5@@1*0%5'%/3&"
V/347888"N/,135)"5@@1*0%5'%/3&" BPc!PeE" D1-"`)//1A"S*H'/3"^%@151(" Y$/3*;"hCG4chc4DhMe"
!DMC"R511%3+'/3"S'1**'" 8425%);"S*H'/39^%@151(o-5)9.5"
]/1-".$/%.*"53-",&5+*" BPMA"<<9"GD4GhE" Y9J9"R/H"!CCC"
[5)%65HA"VS"
" :535-5"RD\"Gnc"
"
f" N+3,.0:E+,2E.U+)1@.>]]^.