Lab 9: Parallel I/O Ports and Subroutines with HC12 Microcontroller, Lab Reports of Microcomputers

Lab 9 of the ece3120 spring 2004 course, focusing on using parallel ports to interface with simple devices, subroutines, and dbug12 monitor functions. Students are required to build an i/o circuit, write a program, and debug it. The program must read switch activations, display values on seven-segment led digits, and control leds based on switch modes.

Typology: Lab Reports

Pre 2010

Uploaded on 07/30/2009

koofers-user-935
koofers-user-935 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE3120
SPRING 2004
LAB 9 – Parallel I/O Ports
The purpose of this lab is to learn the use of the parallel ports to interface to simple
devices, plus further practice in using subroutines and the Dbug12 monitor functions for
terminal input-output, as applied to a program that counts and displays switch activations.
PRE-LAB:
Prepare pseudocode, the first draft of the program, and a schematic of your I/O interface
circuit. Also draw graphical representations of the stack addresses and contents, as they
should exist during each subroutine execution. This must be completed before coming to
the lab and shown to the lab instructor at the start of the lab session.
Approved: Lab TA _____________________ Date ____________
PROGRAMMING ASSIGNMENT:
1. Build an appropriate I/O circuit and write a fully commented program for the HC12
board, including appropriate directives and labels for memory operands and
constants, called Switch.asm.
You will build, test, and demo this system in the Mechatronics Lab (BN326). Use
your breadboard and components from your EE labs to build the circuit required. The
lab TA will loan you the switches and 7-segment displays for use in the lab, which
must be returned. Wire your breadboard to the HC12 interface adapter board. Be very
careful to use the correct connections! Do NOT use any kind of 7-segment decoder
IC. This system must implement the following functionality:
Read the changes in value of two toggle switches (called SW1 and SW2)
reliably, using debouncing by the periodic sampling technique as discussed in
class.
Display a value on two seven-segment LED digits (called DIGIT1 and
DIGIT2), using the scanning technique discussed in class, such that both
digits are always displaying the proper values, with sufficient brightness,
without any visible flicker.
Light up two LEDs (called LED1 and LED2) as specified below.
Run the program continuously and never exit, except when the reset button is
pressed or power is cycled off-on.
Initially reset both transition counts to zero after power-up. Turn off the
DIGITs and LEDs.
4/21/04 Lab 9 1
pf3

Partial preview of the text

Download Lab 9: Parallel I/O Ports and Subroutines with HC12 Microcontroller and more Lab Reports Microcomputers in PDF only on Docsity!

S PRING 2004

LAB 9 – Parallel I/O Ports

The purpose of this lab is to learn the use of the parallel ports to interface to simple devices, plus further practice in using subroutines and the Dbug12 monitor functions for terminal input-output, as applied to a program that counts and displays switch activations.

P R E - L A B :

Prepare pseudocode, the first draft of the program, and a schematic of your I/O interface circuit. Also draw graphical representations of the stack addresses and contents, as they should exist during each subroutine execution. This must be completed before coming to the lab and shown to the lab instructor at the start of the lab session.

_Approved: Lab TA _____________________ Date _____________

P R O G R A M M I N G A S S I G N M E N T :

  1. Build an appropriate I/O circuit and write a fully commented program for the HC board, including appropriate directives and labels for memory operands and constants, called Switch.asm.

You will build, test, and demo this system in the Mechatronics Lab (BN326). Use your breadboard and components from your EE labs to build the circuit required. The lab TA will loan you the switches and 7-segment displays for use in the lab, which must be returned. Wire your breadboard to the HC12 interface adapter board. Be very careful to use the correct connections! Do NOT use any kind of 7-segment decoder IC. This system must implement the following functionality:

  • Read the changes in value of two toggle switches (called SW1 and SW2) reliably, using debouncing by the periodic sampling technique as discussed in class.
  • Display a value on two seven-segment LED digits (called DIGIT1 and DIGIT2), using the scanning technique discussed in class, such that both digits are always displaying the proper values, with sufficient brightness, without any visible flicker.
  • Light up two LEDs (called LED1 and LED2) as specified below.
  • Run the program continuously and never exit, except when the reset button is pressed or power is cycled off-on.
  • Initially reset both transition counts to zero after power-up. Turn off the DIGITs and LEDs.

S PRING 2004

  • Mode1: Whenever SW1 is in the closed (on) position, count every transition in either direction (off-to-on and on-to-off) of SW2. Display a ‘1’ on DIGIT1. Display the current value of transition count1 (0-9) on DIGIT2. When the total count1 value exceeds 9, light up LED1 continuously. Continue to show the least significant digit of count1, starting over at zero (when count1=10), on DIGIT2. Also display the total count1 value on the PC in the command window, in the format “Count 1 = dd”, where “dd” is the 2-digit decimal integer value. Show each new value on a new line.
  • Mode2: When SW1 is in the open (off) position, count every off-to-on transition ONLY of SW2. Display a ‘2’ on DIGIT1 and light up LED2. Display the current value of transition count2 (0-9) on DIGIT2. When the total count2 value exceeds 9, light up LED2 continuously. Continue to show the least significant digit of count2, starting over at zero (when count2=10), on DIGIT2. Also display the total count2 value on the PC in the command window, in the format “Count 2 = dd”, where “dd” is the 2-digit decimal integer value. Show each new value on a new line.
  • The LEDs, DIGITs, and PC display always show the correct values for the current mode, and they change immediately whenever the mode changes.
  • The program must consist of a main routine and several single-purpose subroutines, such that the main program does little work other than calling the subroutines.
  • Use polling (not interrupts) for all I/O operations.
  • The choice of method for passing parameters and results is up to you. Be sure it is documented as usual.
  • As always, preserve the values of all registers (except the CCR and results) in the subroutine.
  • As always, the code must start at $800.
  1. The program may use data memory locations beginning at $900 as needed.