ECE 2325 MICROCOMPUTER SYSTEMS

advertisement
Electrical Engineering Technology
SUNY College of Technology, Alfred, NY
ELET 2143 Embedded Controller Fundamentals
Fall Semester 2007
PRELAB 6. Generating Musical Notes with the 68HC11
NAME:________________________________
PRELAB
Hand in your Prelab at the beginning of your lab section, otherwise, you will lose 25% of your grade in this lab.
In this lab you will be asked to write a program in assembly language for the 68HC11 microcontroller that will generate the
musical notes given in Table II. You will be given a speaker to connect to pin 6 of Port A. The address of Port A is at $1000.
Question 1: Research about the Port A in the 68HC11. Look at the internet or microcontroller books about the Port A (the
Motorola manual is a good resource). Indicate which bits are inputs, which ones are outputs, and which ones are bidirectional
(input/output). Give your answer in the following table:
Port A
Input ?
Output ?
Input/Output ?
PA7
PA6
PA5
PA4
PA3
PA2
PA1
PA0
Question 2: Look at the Adapt 11 manual and fill out the following table
Port A
Pin # in connector H1
PA7
PA6
PA5
PA4
PA3
PA2
PA1
PA0
Question 3: Study the assembly code given in Table I, and modify it adequately to write a program that can play the 10
musical notes given in Table II. Adjust your counter and delays in such a way that the musical scale is agreeable to the
human ear. For example, in order to generate the note E ( f = 330 Hz) your program has to send the following periodic signal
to the speaker (pin PA6)
f = 330 Hz, T = 1/f = 1/330 = 3.03 ms,
then : t1 = t2 = 1.515 msec.
The delay routine has to generate this 1.515 ms.
The values given in the Delay routine in Table I
generate this particular frequency.
AGAIN:
t1
LOOP1:
ORG
LDAB
LDAA
STAA
JSR
LDAA
STAA
JSR
DECB
BNE
SWI
; This is a
LDY
DEY
BNE
RTS
$2000
#$70
#%00000000
$1000
t1
#%01000000
$1000
t1
AGAIN
Subroutine
#$0BD7
; register B will count the number of periods in the square wave
; write a zero to PA6
; jump to the delay subroutine
; write a “1“ to PA6
; jump to the delay subroutine
; decrement the counter
; have the number periods in the square wave been completed ?
; stop
that generates an approximated 1.5 msec delay
; Delay routine
; approx. time 1.5 msec
LOOP1
; return from the subroutine
TABLE I. Assembly code that generates the musical note E
low
middle
high
no
NOTE
B
C
D
E
F
G
A
B
C
D
sound
FREQUENCY
247 Hz
262 Hz
294 Hz
330 Hz
349 Hz
392 Hz
440 Hz
494 Hz
523 Hz
587 Hz
0 Hz
TABLE II. Frequencies of musical notes
Frequencies of more notes:
http://www.phy.mtu.edu/~suits/notefreqs.html
Download