ECE 331 Spring 2009 Homework 9 Solution: I/O Addressing, Microcontrollers, and Ports - Pro, Assignments of Electrical and Electronics Engineering

The solutions to homework 9 for ece 331 spring 2009. It covers topics such as i/o addressing approaches, microcontroller registers, i/o ports, setting port directions, and using specific mcu registers for an hcs12 device. It also includes questions related to secondary functions of various ports and monitoring signals.

Typology: Assignments

Pre 2010

Uploaded on 07/28/2009

koofers-user-s6x
koofers-user-s6x 🇺🇸

9 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE 331 Spring 2009 Homework 9 -solution
Due Friday April 10 at the beginning of class.
1. List the two I/O Addressing approaches discussed in class. Briefly (one sentence) describe
the difference between them.
1) Memory mapped, 2) Isolated. Memory mapped shares address space
between memory and I/O devices while Isolated splits the memory into two
sets of addresses selected by a M/IO’ signal.
2. Briefly describe the general function of Microcontroller (MCU) Registers.
Memory locations that store MCU configuration data or provide interfaces
to on-chip I/O devices.
3. Briefly describe what an I/O Port is on a microcontroller.
Set (generally 8) of signals connected to MCU pins that can be read/written
by software through a data register. Ports can be input, output, or bi-
directional.
4. How would you set a bi-directional I/O port to be an output port?
Port direction is controlled by values stored in a Data Direction Register.
For the HC12, storing a ‘1’ in the DDR sets the port to output.
5. Write a program segment that would set the lowest two pins (1:0) of Port K to be outputs and
the upper six pins (7:2) to be inputs. Use the MCU Register addresses for an HCS12 device.
LDAA #$03
STAA $F0
6. Using the block diagram for the MC9S12DP256, list the secondary functions (other than
general purpose I/O) of each of the following ports on the HCS12.
a) Port A expanded mode address/data port, upper byte
b) Port B expanded mode address/data port, lower byte
c) Port H interrupt functions
a) Port P SPI comm. port (2) or pulse width modulator
d) Port S comm. port: SPI and SCI (2)
e) Port T timer
f) Port AD0 analog to digital converter, channel 0
g) Port AD1 analog to digital converter, channel 1
h) Port E expanded mode control port, interrupts, mode select
pf2

Partial preview of the text

Download ECE 331 Spring 2009 Homework 9 Solution: I/O Addressing, Microcontrollers, and Ports - Pro and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

ECE 331 Spring 2009 Homework 9 -solution

Due Friday April 10 at the beginning of class.

  1. List the two I/O Addressing approaches discussed in class. Briefly (one sentence) describe the difference between them. 1) Memory mapped, 2) Isolated. Memory mapped shares address space between memory and I/O devices while Isolated splits the memory into two sets of addresses selected by a M/IO’ signal.
  2. Briefly describe the general function of Microcontroller (MCU) Registers.

Memory locations that store MCU configuration data or provide interfaces to on-chip I/O devices.

  1. Briefly describe what an I/O Port is on a microcontroller.

Set (generally 8) of signals connected to MCU pins that can be read/written by software through a data register. Ports can be input, output, or bi- directional.

  1. How would you set a bi-directional I/O port to be an output port?

Port direction is controlled by values stored in a Data Direction Register. For the HC12, storing a ‘1’ in the DDR sets the port to output.

  1. Write a program segment that would set the lowest two pins (1:0) of Port K to be outputs and the upper six pins (7:2) to be inputs. Use the MCU Register addresses for an HCS12 device. LDAA #$ STAA $F
  2. Using the block diagram for the MC9S12DP256, list the secondary functions (other than general purpose I/O) of each of the following ports on the HCS12. a) Port A expanded mode address/data port, upper byte b) Port B expanded mode address/data port, lower byte c) Port H interrupt functions a) Port P SPI comm. port (2) or pulse width modulator d) Port S comm. port: SPI and SCI (2) e) Port T timer f) Port AD0 analog to digital converter, channel 0 g) Port AD1 analog to digital converter, channel 1 h) Port E expanded mode control port, interrupts, mode select
  1. Suppose you are using a general purpose I/O port to monitor a signal that periodically switches high briefly but otherwise shows a low value. Without using any MCU hardware, what would you need to do to ensure you did not miss any high values on the monitored signal? Either construct external logic to capture the signal or generate a quick software loop to continuously read the port.
  2. How many Modes of Operation does the HC12/S12 have? How many of them are useful for “normal” applications? There are 8 total modes. 3 of these modes are ‘normal’.
  3. What HCS12 I/O ports are consumed by secondary functions in normal expanded wide mode and not available for general purpose I/O? Port A, Port B, and Port E (some pins)
  4. In Normal Single-Chip mode, which ports are available for general purpose I/O?

All ports are general purpose I/O in single chip mode.

  1. What MCU pin (signal) determines if the chip will operate in a normal or special mode of operation? MODC
  2. What is the major difference in the way the HCS12 manages expanded modes of operation compared to the HC12? The HCS12 multiplexes address/data functions onto Ports A and B. The HC12 uses 4 ports for the same functions.