# EE 134 / EE 101 Spring, 2002 Lecture 19 Exam 2 Solutions.

## Presentation on theme: "EE 134 / EE 101 Spring, 2002 Lecture 19 Exam 2 Solutions."— Presentation transcript:

EE 134 / EE 101 Spring, 2002 Lecture 19 Exam 2 Solutions

Problem 1. Figure 9.16 in text: Input Handshake Timing Diagrams Peter Spasov Microcontroller Technology: The 68HC11, Fourth Edition Copyright ©2002 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. We are using Interlocked mode. STRB active low. We are not using pulsed mode here.

Another view of Problem 1: FIGURE 9-19 Centronics Parallel Interface Timing Diagram Peter Spasov Microcontroller Technology: The 68HC11, Fourth Edition Copyright ©2002 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. 68HC11 PORTC STRA STRB PORTCL is read Data is latched into PORTCL The Centronics standard is a good example of input handshaking, where the MCU is inside the printer. In this problem we do not have an ACK signal.

* EE101/EE134 Exam 2 (The following is just a sample Main program) Main LDX#REGBAS;set IX for indexed addressing of ports BSRInit_PortC New_Data BSRInput_Data BSRDisplay_Bit BRANew_Data ********************************************************* *Subroutine: Initialize Port C *The MCU receives parallel data from the peripheral *using interlocked handshaking. * HNDS = 1, all other bits = 0 *Calling register: IX = REGBAS *Return regiester: none, but ACCA changed Init_PortC BCLRDDRC,X \$FF ; all inputs (It was OK to not include this) LDAA#\$10 STAAPIOC,X RTS ********************************************************* *Subroutine: Wait for data in PORTCL *Calling register: IX = REGBAS *Return register: ACCA contains input data Input_Data BRCLRPIOC,X \$80 Input_Data; wait for STAF=1 LDAAPORTCL,X; ACCA = data RTS

Problem 3: FIGURE 9-3 Seven-Segment LED Display Connections Peter Spasov Microcontroller Technology: The 68HC11, Fourth Edition Copyright ©2002 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. This is the type of LED display specified in the problem. A low (zero) bit turns that segment on.

FIGURE 9-4 Seven-Segment Code Examples Peter Spasov Microcontroller Technology: The 68HC11, Fourth Edition Copyright ©2002 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

********************************************************* *Subroutine: Display 0 if Z set, 1 if Z clear *Uses common-anode 7-segment LED display (0=on, 1=off) *Assume PB0 -> a, PB1 -> b,..., PB6 -> g, PB7 -> N.C. *Calling registers: IX = REGBAS, Z bit in CCR *Return register: none, but ACCA changed Display_Bit BNEOne; be sure Z isn't changed before test Zero LDAA#\$40; or \$C0 STAAPORTB,X RTS One LDAA#\$79; or \$F9 STAAPORTB,X RTS

Problem 4: FIGURE 9-9 3 x 4 Matrix Keyboard (Telephone Format) Peter Spasov Microcontroller Technology: The 68HC11, Fourth Edition Copyright ©2002 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Problem 4: FIGURE 9-10 Parallel I/O with Keyboard. Also connect PC7 high using a pull-up resistor. Peter Spasov Microcontroller Technology: The 68HC11, Fourth Edition Copyright ©2002 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. With this layout we need to setup the Port C Data Direction Register, DDRC, with \$0F.

Problem 5: a.Printers b.Instruments c.One microsecond (two clock cycles) d.IRQ e.0 f.\$D6 g.\$1007 h.0 (or no change) i.Read, receive, or load j.Data bus

Download ppt "EE 134 / EE 101 Spring, 2002 Lecture 19 Exam 2 Solutions."

Similar presentations