0% found this document useful (0 votes)
78 views2 pages

Lab 1. A Digital Lock Preparation: Figure 1.1. Texas Io Window Showing The Door Is Unlocked

This document provides instructions for Lab 1, which involves creating a digital lock simulation using the TExaS software. Students will write assembly code to read the states of two switches and control an LED based on the switch values. The LED should turn on if one switch is pressed and the other is not. The document explains how to set up the simulator files and I/O ports. It also provides a template for the assembly code and directions for testing and demonstrating the working simulation.

Uploaded by

M Iqbal Zainur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views2 pages

Lab 1. A Digital Lock Preparation: Figure 1.1. Texas Io Window Showing The Door Is Unlocked

This document provides instructions for Lab 1, which involves creating a digital lock simulation using the TExaS software. Students will write assembly code to read the states of two switches and control an LED based on the switch values. The LED should turn on if one switch is pressed and the other is not. The document explains how to set up the simulator files and I/O ports. It also provides a template for the assembly code and directions for testing and demonstrating the working simulation.

Uploaded by

M Iqbal Zainur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Jonathan W.

Valvano EE319K Spring 2010 Lab Manual Page 5

Lab 1. A Digital Lock


Preparation
Read Chapter 1 of the book
Read Sections 2.1, 2.2, 2.3, 2.6 and 3.7 of the book
Install and run TExaS, execute Help->GettingStarted, read up to but not including “Developing C software…”
Download and run the first three lessons at
http://users.ece.utexas.edu/~valvano/Readme.htm
Purpose
The general purpose of this laboratory is to familiarize you with the software development steps using the TExaS
simulator. Starting with Lab 2, we will use TExaS for both simulation and debugging on the real board, but for this lab, we
will use just the simulator. You will learn how to perform digital input/output on parallel ports of the 9S12. Software skills
you will learn include port initialization, logic operations, and unconditional branching.

System Requirements
The specific device you will create is a digital lock with two binary switch inputs and one LED output. The LED
output represents the lock, and the operator will toggle the switches in order to unlock the door. Let T be the Boolean
variable representing the lock (0 means LED is off and door is locked, 1 means LED is on and door is unlocked). Let H and
P be Boolean variables representing the state of the two switches (0 means the switch is not pressed, and 1 means the switch
is pressed). The specific function you will implement is
T=P&H
This means the LED will be on if and only if the P switch is pressed and the H switch is not pressed, as shown in Figure 1.1.

Figure 1.1. TExaS IO window showing the door is unlocked.

Procedure
The basic approach to this lab will be to first develop and debug your system using the simulator.
Part a) Use the TExaS simulator to create three files. Lab1.rtf will contain the assembly source code. Lab1.uc will
contain the microcomputer configuration. Lab1.io will define the external connections, which should be the two switches
and one LED as shown in Figure 1.1. In this class, we will use the 9S12DP512 microcomputer, which you can specify using
the Mode->Processor command. You should connect switches to PP1 (means Port P bit 1) and to PH1 (means Port H bit 1).
You should connect an LED to PT1 (means Port T bit 1). The switches should be labeled H and P, and the LED should be
labeled T. When H switch is “off” or open position, the signal at PH1 will be 0V, which is a logic “0”. For this situation,
your software will consider H to be false. When the H switch is “on” or closed position, the signal at PH1 will be +5V, which
is a logic “1”. In this case, your software will consider H to be true. The P switch, which is connected to PP1, will operate in
a similar fashion. When your software writes a “1” to PT1, the LED will turn on. Figure 1.1 shows the condition with the
LED is on because P is pressed and H is not pressed.

void main(void){
DDRH = 0x00; // make Port H an input, PH1 is H
DDRP = 0x00; // make Port P an input, PP1 is P
DDRT = 0xFF; // make Port T an output, PT1 is T
while(1){
PTT = (~PTH)&PTP; // LED on iff PH1=0 and PP1=1
}
}
Program 1.1. This C program specifies the operations your assembly program should perform in Lab 1.

[email protected] 3/9/2010
Page 6 Introduction to Embedded Systems: Interfacing to the Freescale 9S12

Part b) You will write assembly code that inputs from PH1 and PP1, and outputs to PT1. Program 1.1 describes the software
algorithm in C. Notice that this algorithm affects all bits in a port, although only one bit is used. In general, this will be
unacceptable, and we will learn later how to write code that affects one bit at a time. You can copy and paste the address
definitions for ports H, P, and T from the port12.rtf file. In particular, you will need to define DDRH DDRP DDRT PTH
PTP and PTT. The structure of assembly programs in this class is shown as Program 1.2. The opening comments include:
file name, overall objectives, hardware connections, specific functions, author name, TA, and date. The equ pseudo-op is
used to define port addresses. Global variables are declared in RAM, and the main program is placed in EEPROM. The 16-
bit contents at $FFFE and $FFFF define where the computer will begin execution after a power is turned on or after the reset
button is pressed. This template, shown in Program 1.2, can be found in most example programs for the 9S12DP512.

;****************** Lab1.RTF ***************


; Program written by: Your Name
; Date Created: 7/29/2009 6:06:11 PM
; Last Modified: 7/29/2009 6:06:18 PM
; Section 1-2pm TA: Nachiket Kharalkar
; Lab number: 1
; Brief description of the program
; The overall objective of this system is a digital lock
; Hardware connections
; PH1 is switch input H
; PP1 is switch input P
; PT1 is LED output T (on means unlocked)
; The specific operation of this system
; unlock if P is pressed and H is not pressed
;I/O port definitions on the 9S12DP512
PTH equ $0260 ; Port H I/O Register
DDRH equ $0262 ; Port H Data Direction Register
PTP equ $0258 ; Port P I/O Register
DDRP equ $025A ; Port P Data Direction Register
PTT equ $0240 ; Port T I/O Register
DDRT equ $0242 ; Port T Data Direction Register
org $0800 ; RAM
; Global variables (none required for this lab)
org $4000 ; flash EEPROM
main
;Software performed once at the beginning
loop
;Software repeated over and over
bra loop
org $FFFE
fdb main ;Starting address
Program 1.2. Assembly language template.

Demonstration
During the demonstration, you will be asked to run your program to verify proper operation. You should be able to
single step your program and explain what your program is doing and why. You need to know how to set and clear
breakpoints. You will be asked to look up the meaning of commands like Mode->FollowPC using the on-line help. Be
prepared to make changes to Lab1.io, such as changing the names and colors of the switches and LEDs.

Deliverables
1) Assembly listing of your final program
2) One screen shot of the UC and IO windows, showing PTT PTP and PTH in the lab1.uc window and showing
the case with the LED on.

03/09/10

You might also like