ECE 265 Computer Problem #2: 4 3 0 $1003 S BCD Port C
ECE 265 Computer Problem #2: 4 3 0 $1003 S BCD Port C
Computer Problem #2
In the next few computer problems, you will use the THRSim11 simulator to develop
a programmable home thermostat (PHT). You will use the THRSim11 IO Box to
provide input to and display output from the ports of the M68HC11.
One feature of the PHT that you will program in this computer problem is the
ability to set the initial temperature when the thermostat is turned on. Port C of the
M68HC11 is used to furnish a one-digit signed BCD number to the unit:
4 3 0
$1003 S BCD Port C
The data is given in sign-magnitude form. Bit 4 (S) is the sign bit and Bits 3-
0 give the magnitude of the BCD digit. This value is used to adjust the default
temperature setting (TEMP DEF), given in the program, to give the initial temperature
setting (TEMP SET). For instance, if the value of the default temperature setting is
72, and the Port C data (least significant five bits) are %10100, then the initial
temperature setting should be 68.
After TEMP SET has been computed, this value should be “printed” to the LCD
display on the THRSim11 IO Box. ASCII characters “printed” to address $1040 will
appear on the display. See the Help topic on the THRSim11 IO Box (under External
Boxes) for more information.
*
* Computer Problem #2, ECE 265
*
* Your Name
* Your Partner’s Name
*
STACK EQU $00FF ; set up the stack and port
PORTC EQU $1003 ; addresses
LCDDATA EQU $1040
LCDCTRL EQU $1041
ORG 0
TEMP_DEF FCB $72 ; set the default temperature
TEMP_SET RMB 1 ; desired temperature setting
TMP1 RMB 1
ORG $E000
MAIN: LDS #STACK ; initialize the stack pointer
LOOP: LDAA PORTC ; read Port C
JSR INIT_TEMP ; initialize TEMP_SET
JSR PRINT ; print TEMP_SET to LCD
; display
BRA LOOP
INIT_TEMP: RTS
PRINT: CLRA
STAA LCDCTRL ; set the LCD cursor position
LDAA #$06
STAA LCDDATA ; to upper left
; .
; .
; .
RTS
ORG $FFFE
RESET: FDB MAIN
The program continually reads Port C, in the main loop, computes the initial tem-
perature setting (subroutine INIT TEMP), and prints it to the LCD display (subroutine
PRINT). Your task is to write the INIT TEMP and PRINT subroutines.
After you have successfully written and tested the program to produce the desired
results, then upload the assembly language program (pht2.asm) to the Computer
Problem #2 dropbox on Carmen. Each student in the group should do this indi-
vidually. When testing your program, be sure that it works for any initial default
temperature in the range of 9-90. Also, print copies of the following two pages and
turn them in during class on the due date:
1. pht2.LST
The THRSim11 IO Box Window should show some typical results. Only one hardcopy
of the programs needs to be turned in as a report for each group.