ECE 271 LAB 11 Spring 2012 PURPOSE: Using the Serial Ports for communication with the PC. EXERCISE: In this lab you will provide a user interface using the PC monitor and keyboard to the Age of the moon program you developed previously. Your program will prompt for the year, month, and day. It will then display the age of the moon using something like "The age of the moon is 17 days". Given that your previous moon age lab is in working order, your main required tasks are to write the following subroutines: putChar: Sends a single character to be displayed on the PC monitor. Be sure to check TDRE in the SCSR before sending. Use BRCLR or BRSET. getChar: Waits until a character is entered from the keyboard and then returns it. Be sure to check RDRF in SCSR before reading. Use BRCLR or BRSET. printString Displays the null-terminated ASCII string pointed to by the X register (null-terminated means ends in zero). getDigit Gets a key from the keyboard. If the key is a digit then echo the character to the screen, shift the contents of X left by 4 bits, then add the decimal value of the number to the X register and return 1 in the B register. If the key is a non-digit, then return 0 in the B register. getBCD Gets a packed BCD number of up to 4 digits from the keyboard and returns the result in the D register. The user will hit a non-digit to signify the end of the number. This routine simply clears the X register and then calls getDigit until the B register is 0. Note: there are a number of registers associated with the SCI system, but you really only have to deal with two of them (BUFFALO initializes the rest). The ones you need are SCDR (Section 9.4.6 in Reference Manual) and SCSR (Section 9.4.5). In SCSR you only need to be concerned with the TDRE and RDRF bits. Our HC11 boards actually communicate through a different, but similar port. Make the following changes to your code (you should be using equates anyway) SCSR register: $102E --> $6400 SCDR register: $102F --> $6401 TDRE mask: %10000000 --> %00000010 RDRF mask: %00100000 --> %00000001 Do not make calls to Buffalo's monitor code. If you don't know what I'm talking about, then you have nothing to worry about here. If you didn't get moon age lab to work, some options are: 1) Get it to work. 2) Have the user enter an address and you print the contents of that address. 3) Do something more interesting than option 2.