100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
ECET 340 Week 1 iLab 1 2024/2025 $23.99   Add to cart

Exam (elaborations)

ECET 340 Week 1 iLab 1 2024/2025

 5 views  0 purchase
  • Course
  • Institution

ECET 340 Week 1 iLab 1 2024/2025/ECET 340 Week 1 iLab 1 2024/2025/ECET 340 Week 1 iLab 1 2024/2025

Preview 2 out of 15  pages

  • September 9, 2024
  • 15
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • Unknown
avatar-seller
OBJECTIVES:

1. To become familiar with Microcontroller MC9S12 parallel ports and how
simple input and output devices are interfaced through them.
2. To learn how to program I/O instructions in C language.
3. To learn how to organize a program to read data from input ports, process the
data, and display the result on a simple output device.



I. PARTS LIST:

Equipment:
Computer running Windows XP or Vista 32 bit.
Codewarrior v. 5.9.0

Parts:
1- Wytec EVBPlus Microcontroller Demonstration Board Kit, including:
MC9S12DG256 demonstration board
USB cable and adapter
Universal power supply and cable
MC9S12DG256 Development Boards CD


II. INTRODUCTION

Parallel I/O ports are the two-way signal interface between a microprocessor and external
peripheral devices. I/O means ports can be configured for either receiving multi-bit
signals into the controller (input port) or sending signals out from it (output port). The
processor uses its ports to control the access of peripherals to its own internal buses.

When the processor outputs to different peripherals output ports direct the data from the
internal buses to the intended destinations. This is accomplished through data latching,
i.e., holding onto data left at the port by the processor until the receiver is ready to fetch
it. Here ports are said to act as data buffers. They also act as electrical signal buffers by
placing amplifiers between the internal buses and external devices, important both for
noise control and boosting signal power to the multiple devices that might attach to a
given port. Finally, output ports electrically isolate, or disconnect, external devices from
the internal bus whenever data transfers are not taking place.

Input ports likewise help the processor avoid bus contention by ensuring that only one
peripheral device is allowed to connect to the internal data bus at any given time. To do
this the microprocessor tri-states all ports other than the one it wants access to. There is a



ECET-340 DeVry University 1

, penalty for these features: port hardware introduces a certain amount of unavoidable
time delay in the signal path.

All port output pins have their own current limits. When used as inputs, parallel port pins
have voltage limits. Both of these are specified in the processor’s device user’s guide and
must be strictly observed in order to avoid damage to the controller hardware.

The HCS12 used in this lab has 11 individually programmable parallel ports, identified
by the letters A,B,E,H,J,K,M,P,S,T and PAD, of widths varying between 2-bits and 8-
bits. Individual bits in a port are identified by their bit position, for example bits 6 and 7
of Port M are referred to as PM6 and PM7. The Wytec demo board provides access to
these port pins through the headers labeled H1 to H8.

Port pin directions are user programmable. An initialization program sends an 8-bit
control word to the address in the control register block of memory assigned to the data
direction register for that port. For example, the symbolic address given to the data
direction register for port B is DDRB. Within the control word, ‘1’s = output ports and
‘0’s = input ports. Pin directions are assigned individually, for example,

PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0

1 1 0 0 0 0 0 1 DDRB ( DDRB = 0xC1; )

sets directions of pins PB7,PB6 and PB0 as outputs, and PB5-PB1 as inputs. Always
check to make sure the directions you assign in this register agree with your external
hardware connections to the port! Connecting an input device to a port pin programmed
in the DDR register as an OUTPUT can cause (expensive) damage to the microcontroller
IC when it and the input device both try to send out conflicting logic levels.

If a port pin is programmed as an input it is also possible to program a pull-up or pull-
down device to act internally. This is equivalent to connecting a shunt resistor to Vcc (or
ground) externally to the pin. Registers PPSP and PERP in the control block area can be
used to select pull polarity (down or up) and enable for each pin of port P, for example.
A ‘1’ in PPSP selects pull-down for that pin; a ‘0’ selects pull-up. A ‘1’ in PERP turns
on the pull device for that pin.

In the first part of this lab we program two of the HCS12 ports: Port B as an 8-bit output
port and Port H as an 8-bit input port. Our first application is simple: LEDs will are used
as output devices and an 8-position DIP switch serves as our inputs. User program
instructions determine the logic states of the input switches, process these states, and
outputs the results for display on the LEDs.

IV. Procedure
A. Program to Read Switch States and Display
1. Enter the program shown below into a new Codewarrior project, 340_lab1_1 (choose
HCS12 Serial Monitor as the target). Use F7 – F5 to compile and flash the board.


ECET-340 DeVry University 2

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller VEVA2K. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $23.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

75323 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$23.99
  • (0)
  Add to cart