ch07 - 1 Chapter 7 Exercise Solutions E7.1 The I/O method...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 7 Exercise Solutions E7.1 The I/O method in which dedicated instructions and memory space are provided for the I/O devices is called isolated I/O. The I/O method in which instructions and memory space are shared between the I/O devices and memory devices is called memory-mapped I/O. E7.2 The protocol of the interlocked input handshaking is illustrated in Figure 7S.1. In the interlocked input handshaking, two signals are provided. One signal, (called H1), is driven by the interface chip. The other, (called H2), is driven by the input device. Whenever the interface chip wants to read data from the input device, it asserts the H1 signal. The input device first places data on the port pins and then asserts the H2 signal to inform the interface chip that valid data has been placed on the port pins. The interface chip latches the data and then de- asserts the H1 signal. The input device also de-asserts the H2 signal after the de-assertion of the H1 signal. E7.3 We need to program the PIOC register properly. - bit 7 is a status bit and cannot be set and we can write any value to it, - set bit 6 to 1 to enable STRA interrupt, - set bit 5 to 0 to configure port C pins as normal port pins, - set bit 4 to 1 to enable handshake, - set bit 3 to 0 to select input handshaking, - set bit 2 to 1 to select pulse more handshake protocol, - set bit 1 to 0 to select the falling edge of STRA as active edge, and - set bit 0 to 0 to select the low level as the active level of the STRB signal. The value to be written into the PIOC register is either %01010100 or %11010100. We also need to configure port C as an input port. Write the value of %00000000 to the DDRC register. The following instruction sequence will configure the port C as required: REGBAS equ $1000 ; base address of the I/O register block PIOC equ $02 ; the offset of PIOC from REGBAS DDRC equ $07 ; the offset of DDRC from REGBAS PIOC_INI equ $54 ; value to be written into PIOC input equ $00 ; value to set port C as an input port LDX #REGBAS LDAA #PIOC_INI STAA PIOC,X ; configure port C as desired LDAA #input STAA DDRC,X ; configure port C pins as input E7.4 The following instruction sequence will read in the current port C pin logic levels: DDRC equ $07 REGBAS equ $1000 PORTC equ $03 ; offset of PORTC from REGBAS input equ $00 6- 1 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
LDAA #input STAA DDRC,X ; configure port C pins for input LDAA PORTC,X ; read the current port C pins logic levels E7.5 Let's use port B to turn on and off those traffic lights. Use PB5~PB3 to drive east-west bound green, red, & yellow LEDs and use PB2~PB0 to drive south-north bound green, red, & yellow LEDs. All LEDs are driven by port B pins using the circuit connection similar to Figure 6.17, i.e., the port pin must be high in order to turn on an LED. The following loop will create a delay of 100 ms with the 2MHz E clock: LDX #20000 loop NOP ; this instruction takes 2 E clock cycle to execute NOP ; this instruction takes 2 E clock cycle to execute DEX ; this instruction takes 3 E clock cycle to execute
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

ch07 - 1 Chapter 7 Exercise Solutions E7.1 The I/O method...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online