New version page

SC EMCH 367 - Lab 2 – Parallel and Serial Communication

This preview shows page 1-2 out of 6 pages.

View Full Document
View Full Document

End of preview. Want to read all 6 pages?

Upload your study docs or become a GradeBuddy member to access this document.

View Full Document
Unformatted text preview:

EMCH 367 Fundamentals of Microcontrollers Lab 2.doc Dr. Victor Giurgiutiu Page 1 12/19/2001 LAB 2 – PARALLEL AND SERIAL COMMUNICATION OBJECTIVE The objectives of this lab are to review the parallel and serial communication in the MC68HC11 microcontroller. The objective of this laboratory experiment is to learn how to use the serial communication port of the M68HC11. Basic concepts of serial communications will be reviewed. The registers used to transmit and receive serial communications data and the RDRF and TDRE flags used to identify whether or not serial communications data has been received or sent will be examined. The BAUD rate and other aspects of the serial communications interface (SCI) will be investigated.. • Review the use parallel ports • Illustrate the generation of a square wave using Port B output and a waiting sequence • Illustrate the use of Port C for input and output using a 4-button 4-LED box • Examine the relation between time and clock cycles • Review the use of serial communications • Investigate BAUD rate, ASCII code, 10-bit serial communication • Develop and practice the concept of echo • Measure serial communications signals, including the start bit, ASCII code, and the stop bit, using the oscilloscope with an external trigger generated by MCU PREREQUISITES Floppy disk with the asm codes for the programs: • LASTNAME_Firstname_Buttons_bx.asm • LASTNAME_Firstname_Sq_wav1.asm • LASTNAME_Firstname_Sq_wav2.asm • LASTNAME_Firstname_Echo.asm Hard copy (printout) of Hmwk4a and Hmwk 4b. When printing, use the 'pages per sheet' option in the lower right corner of the print dialog-box with settings of 4 or 2 (depending on your eyesight) to save paper. (We may want to experiment a little with this before printing the full document.) PROCEDURE The students will utilize the asm code developed with the THRSim11 simulator for Hmwk4a and Hmwk4b. The students will go through their Hmwk4a and Hmwk4b step by step and will verify that the MCU responds to instructions as expected. The lab is divided into sections. After completing each section, the student will ask the TA to check the student’s work and make a check mark on that section. The asm code is activated into the MCU following the standard procedure learned in Lab 1.EMCH 367 Fundamentals of Microcontrollers Lab 2.doc Dr. Victor Giurgiutiu Page 2 12/19/2001 WARM UP EXERCISES 1) Connect the oscilloscope Channel 1 through a hook probe to Port B Pin0 using a male connector. Set the oscilloscope Channel 1 to DC, 5V/div, and zero vertically in mid screen. Use the MM command to put $01 into PORTB, i.e., in the MCU address $1004. The oscilloscope signal should jump to 5 V. Put again $00 in PORTB. The oscilloscope signal should jump to 0 V. Do you observe this? ___ Y ___ N 2) Assume $A5 is loaded into PORTB at address $1004. What will be the output of parallel port B? Predict the results in the table below. Label which pin is the MSB. Port B pins PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0 Value Use the MM command to put $A5 into PORTB, i.e., in the MCU address $1004. Verify the output of parallel port B with the oscilloscope and the 8-LED display. Check the voltages on all of the pins of parallel port B (PB0 - PB7) with the oscilloscope. Then check them with the 8-LED display. Write down your observations. PB0: V PB1: V PB2: V PB3:PB4: V PB5: V PB6: V PB7:When satisfied with your results, call your TA and demonstrate. TA checkmark ________ 3) If you place $fa in DDRC at address $1007 and then load $c8 into PORTC at address $1003, what will be the output of parallel port C? Enter your prediction in the table below. DDRC pins Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value Port C pins PC7 PC6 PC5 PC4 PC3 PC2 PC1 PC0 Value Load $fa in DDRC at address $1007 and then load $C8 into PORTC at address $1003. Verify the output of parallel port C. Check the voltages on all of the PC0 - PC7 pins of parallel port C with the oscilloscope probe. Then check them with the 8-LED display. Write down your observations. PC0: V PC1: V PC2: V PC3:PC4: V PC5: V PC6: V PC7:When satisfied with your results, call your TA and demonstrate. TA checkmark ________EMCH 367 Fundamentals of Microcontrollers Lab 2.doc Dr. Victor Giurgiutiu Page 3 12/19/2001 SQUARE WAVE Use the code LASTNAME_Firstname_Sq_wav2.asm generated in Hmwk4a. The parallel port B is used to generate a square wave. A square wave is a signal that is high for a specified period of time, then low for a specified period of time. In this case, the high state will be +5V, and the low state will be 0V. Your target is to generate a square wave signal with the period of time for each state (half-wavelength) approx. 100 µs. The square wave signal generated by your MCU will be measured on the oscilloscope screen and compared with your predictions. Your code should make the MCU send out a low signal for a specified time, then a high signal for the same time. After sending out a high signal and then a low signal, it will repeat the process. The duration of the high and low states is specified using the variable DELAY. The variable DELAY is used in a wait subroutine. The MCU is a very fast device. Our M68HC11 has an 8 MHz crystal, which generates a 2 MHz clock speed. Compute and answer the following questions: a) What is the shortest duration of time that the oscilloscope can measure per division? Look up on the oscilloscope panel and enter your answer here: ___________________________ b) What is the duration of an M68HC11 machine cycle? Calculate your answer using the M68HC11 clock speed of 2 MHz and enter your answer here: ________________________ Activate the code LASTNAME_Firstname_Sq_wav2.asm. According to your Example Square wave, when value $40 is entered in DELAY, the length of your half-wave, ∆t, should be 165 µs. Hook the oscilloscope probe to the pin corresponding to your coding, and verify that what you see on the oscilloscope screen meets with your predictions. (Adjust the time/div button to see the square wave properly…). Write here the half-wavelength value read on the oscilloscope screen ______ µs. Change DELAY to the other values given in the table below, and run your program again. Enter the ∆t (µsec) predicted by you using the simulator (see Hmwk4a) and the values read on the oscilloscope screen. DELAY ∆t (µsec) Measured by simulator∆t (µsec) Measured on oscilloscope Error, % (col 2


View Full Document
Loading Unlocking...
Login

Join to view Lab 2 – Parallel and Serial Communication and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lab 2 – Parallel and Serial Communication and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?