ECE 271 LAB 12 Spring 2012 EXERCISE: For this lab you will write a short program which reads and writes through the serial communications interface (SCI) on the HC11 and which serves as a crude piano keyboard. Your program will first send some prompt string such as "Piano program - use QWERTY row on keyboard". The user will then type keys on the keyboard and your program will "echo" the key back and then play a note corresponding to the key pressed. The data area for your program will include a "keyboard map" describing the allowed keys, the associated frequency, and a "period". (Table on back). It will also include the prompt string - use fcb and enclose the string in single quotes. Your main program will first print your prompt string (call printString). It will then wait for a character to be received (call getChar), echo the character to the screen (call putChar), and then play the tone (call PLAYTONE). It will then loop back and wait for a new key. In addition to last week's getChar, putChar, and printString routines you will add a PLAYTONE routine: Subroutine PLAYTONE will play for 1/4 second the tone corresponding to the key passed in the A register. It must first search the table to see if there is a matching key and abort the routine if none is found. It will then use the two numbers given to play the tone as follows. First compute the frequency divided by two. This is the number of times to toggle the speaker in 1/4 second. The number following the frequency (the "period") will be used in a software delay between each toggle of the speaker. So, put that number in X, count down to zero, then toggle the speaker. In an outer loop count the number of speaker toggles and stop when the frequency divided by two is reached. See back for speaker information. Doing just the above will get you 90% grade. Do more for more credit. "NOTES": 1. As on previous labs: write good code, have flowcharts, each subroutine must be transparent, etc. Flowcharts and code will be checked at the start of your lab period. 2. Note that debugging will be a little more difficult than usual for the reason that Tute and BUFFALO are communicating over the same serial lines that you will be sending data over. In particular, stepping over the lines of code where SCSR bits (TDRE and RDRF) are looked at and where SCDR is read/written WILL NOT WORK! Also, you must switch to the "Comm" window when running. 3. Use bit instructions for all "bit" changing and testing (e.g., BRCLR, BRSET). Note that bit instructions (e.g., BRCLR) must use indexed addressing - no extended (EXT) addressing. 4. Partial header information is given on the back. Note that we use different SCI registers than given in the text). * Lab 12 partial header PORTA equ $1000 SPEAKER equ PORTA SPEAKERBIT equ %00100000 SCSR equ $6400 ; Serial communications status register SCDR equ $6401 ; Serial communcations data register TDRE equ %00000010 ; mask for TDRE flag in SCSR RDRF equ %00000001 ; mask for RDRF flag in SCSR * The following table gives key, frequency, and "period" keymap fdb 'q', 220, 758 ; A fdb '2', 233, 715 ; A# fdb 'w', 247, 675 ; B fdb 'e', 262, 636 ; C fdb '4', 277, 602 ; C# fdb 'r', 294, 567 ; D fdb '5', 311, 536 ; D# fdb 't', 330, 505 ; E fdb 'y', 349, 478 ; F fdb '7', 370, 450 ; F# fdb 'u', 392, 425 ; G fdb '8', 415, 402 ; G# fdb 'i', 440, 379 ; A fdb '9', 466, 358 ; A# fdb 'o', 494, 337 ; B fdb 'p', 523, 319 ; C fdb '-', 554, 301 ; C# fdb '[', 587, 284 ; D fdb '=', 622, 268 ; D# fdb ']', 659, 253 ; E fdb 0