CIS*2030 Lab 8Lab Number 8 1Overview The term Input-Output (I/0) is used to describe the transfer of data between the processor and external (hardware) devices. One of the...

easy68k










CIS*2030 Lab 8 Lab Number 8 1 Overview The term Input-Output (I/0) is used to describe the transfer of data between the processor and external (hardware) devices. One of the most common I/O strategies that processors use to communicate with external devices is called memory-mapped I/O. To this point in the course, we have naturally assumed that an address is always associated with a particular location in memory (or RAM). However, in the case of memory-mapped I/O, a set of addresses in the processor’s address space is set aside, and then assigned to registers inside the I/O devices. In other words, the registers inside the external I/O devices get their own “memory addresses” just like the locations in RAM get their own “memory addresses”. The primary advantage of memory mapped I/O is that accessing registers inside external devices is the same as accessing locations in memory, at least from the programmer’s perspective. As discussed in class, actually performing I/O operations typically requires performing read and write operations on the various registers associated with the I/O device. Depending on the capabilities of the interface, communicating with the device may either done using a programmed I/O strategy or an interrupt-driven I/O strategy. The former requires the processor to interrogate the device until the device is ready to participate in the I/O operation. The latter frees up the processor by requiring the I/O device to contact the processor when it is ready to participate in the I/O operation. Objectives Upon completion of this lab you will: § Understand memory-mapped I/O from a programmer’s perspective § Understand how to communicate with simple I/O devices using either a programmed I/O or interrupt-driven I/O strategy Memory-Mapped Input-Output CIS*2030 LabNumber8 Name:_______________________________________________ Mark:_____________/100 Lab Number 8 2 Evaluation The only graded activity in this lab is the final programming exercise. No marks are assigned to any of the prior question. Nevertheless, it is crucial that you complete all of the exercises, as these will provide you with the requisite knowledge and experience to complete the final programming exercise. Preparation Prior to starting the lab, you should review your course notes, and perform the following reading assignments from your textbook (if you have not already done so): • All of Chapter 7 (Note: This chapter describes both the software and hardware sides of input-output. Our concern is with the software side of things, not the hardware.) Introduction As discussed in class, the 68000 employs a memory-mapped I/O strategy to communicate with input-output devices external to the processor. This means that each external device is allocated one (or more) addresses in the processor’s address space, and the programmer communicates with the device by performing read and write operations on these addresses. In the case of the Easy68K, the simulator supports four simple I/O devices: (1) an eight digit 7-segment display, (2) a bank of eight Light-Emitting Diodes (LEDs), (3) a bank of eight toggle switches, and (4) a bank of eight push-button switches. To see these devices, first start the Easy68K simulator. Then select “Hardware” from the View pull-down menu. You should see a hardware window similar to the one shown in Fig. 1 on the next page. The four I/O devices are located in the upper half of the hardware window, starting with the 7-segment display and ending with the bank of eight push-button switches. To the immediate right of each I/O device is and Address field. This field shows the current memory-mapped address of the device. For example, the current memory-mapped address of the bank of eight LEDs is 0x00E00010. In practice, each of the four I/O devices can be mapped to any valid 68000 address by manually entering the address in the Address field. If the address entered conflicts with the address of another device, the color of the address will change to red. The memory map in Fig. 1 provides a visual illustration of the current address space, showing the memory-mapped address (or addresses) associated with each I/O device. Lab Number 8 3 Figure 1: Hardware window and memory-mapped addresses of I/O devices. The Easy68K enables a program to interact with the simulated hardware devices through use of TRAP #15 and task number 32 (stored in D0). For example, rather than select “Hardware” from the view menu, the following code can be used to automatically display the hardware window: MOVE.L #32,D0 ;task 32 CLR.B D1 ;display hardware window TRAP #15 ;system call Similarly, the following code can be used to determine the (base) address of the 7-segment display: MOVE.L #32,D0 ;task 32 MOVE.B #1,D1 ;return address of 7-segment display in D1.L TRAP #15 ;system call Switches) LEDs) 7.Segment) Bu4ons) RAM) Vector) Table) 0x000400) 0x0003FF) 0x000000) RAM) 0xE00000).)0xE0000E) 0xE00012) 0xE00010) 0xE00014) 0xFFFFFF) Hardware)Devices)))))))))))))))))))))))))))))))))))))))))))))))Memory)Map) Lab Number 8 4 Figure 2: Interacting with hardware simulator through software. Next, you will work through a series of programming exercises to understand how to communicate with some of the previous hardware devices. Part 1: Writing to LEDs An LED is like most other primitive semi-conductor devices in the sense that it operates like a switch. Under the right conditions, the switch closes, current flows, and the LED turns “on” and lights up. Otherwise, the LED remains “off” and does not light up. Figure 3 illustrates how the process works on the Easy68K. The eight LEDs are mapped to the byte at memory location 0xE00010. Each bit in the byte controls one of the eight LEDs. In particular, biti controls LEDi. To turn LEDi on (red), biti must be 1. Figure 3: Interface for bank of eight LEDs. 0xE00010%0% 0% 0% 0% 1% 1% 1% 1% LEDs% %b7%%%%%%%b6%%%%%%%b5%%%%%%%b4%%%%%%b3%%%%%%b2%%%%%%%b1%%%%%%%b0% Lab Number 8 5 Step 1 Download the sample program called Lab8a.X68 from the course website. Step 2 Assemble, and then execute the program using the Easy68K simulator. You should see an output similar to the one in Fig. 3. Programming Task Write a program for the previous LED interface that inputs a character from the keyboard and displays the ASCII code for the character on the LEDs. Put the program in a loop and terminate when ‘q’ is detected. • TRAP #15 with task number 5 should be used to read a single ASCII character from the keyboard into D1.B (see Easy68K help) • Save your program in a file named Lab8b.X68. Part 2: Reading from Toggle Switches The next interface that you will consider is simple input from the bank of eight toggle switches. Figure 4 illustrates how the process works on the Easy68K. The bank of eight toggle switches is mapped to the byte at memory location 0xE00012. Each bit in the byte is affected by one of the eight switches. In particular, biti is affected by switchi. For any switch that is closed (or down) the corresponding bit is set to logic 1. Otherwise, the corresponding bit is set to logic 0. Figure 4: Interface for bank of eight toggle switches. Step 1 Download the sample program called Lab8c.X68 from the course website. 0xE00010%0% 0% 0% 0% 1% 1% 1% 1% Toggle%Switches% %b7%%%%%%%b6%%%%%%%b5%%%%%%%b4%%%%%%b3%%%%%%b2%%%%%%%b1%%%%%%%b0% Lab Number 8 6 Step 2 Assemble the program. Set a breakpoint at the MOVE.B SWITCHES(A1),D1 instruction on line 24, and then execute the program. Once the program breaks, use your mouse to toggle some of the switches. Now execute the instruction on line 24 to read the state of the switches. Examine the contents of D1 to determine which bits are set to 1 and which bits are set to 0 based on the settings of the switches. Programming Task Write a program to simulate a wire connection between the bank of eight LEDs and the bank of eight toggle switches (see Fig. 5). The program should continuously read the switches and turn on/off the corresponding LED for any switch that is closed/open. Save your program in a file called Lab8d.X68. Figure 5: Software simulation of wire connection between switch/LED interfaces. Part 3: Reading from the Push Buttons The push buttons are another input interface. However, there are two differences between the push buttons and the previous toggle switches. First, unlike the toggle switches, push buttons write a logic 0 to the corresponding bit in memory when the button is pressed, and write a logic 1 when the button is released. Second, a push button only writes a logic 0 to the corresponding bit in memory while the button is being pressed. Once the button is released, it continually writes a logic 1 to the corresponding bit in memory, as illustrated in Fig. 6. Figure 6: Push-button interface. Toggle&Switches& LEDs& 0xE00014&1& 1& 1& 1& 1& 1& 1& 1& &b7&&&&&&&b6&&&&&&&b5&&&&&&&b4&&&&&&b3&&&&&&b2&&&&&&&b1&&&&&&&b0& Push&Bu2ons& Lab Number 8 7 Programming Task Write a program to simulate a wire connection between the bank of eight LEDs and the bank of eight push buttons (see Fig. 6). The program should continuously read the push buttons and turn on/off the corresponding LED for any switch that is pressed/released. Save your program in a file called Lab8e.X68. Part 4: Writing to the 7-Segment Display One of the most common output interfaces used in commodity electronic devices is the 7- segment display. This is because the display can be used to output various values, including the decimal digits 0 through 9 and the hexadecimal digits A through F. Shown pictorially in Fig. 7, a 7-segment display consists of 7 segments, labeled a, b, c, d, e, and f. Each of these segments can be selected and turned on/off to display a numeric value, as shown in Fig. 7b. Figure 7: 7-segment display segment designation. As shown in Fig. 7b, to display the number 1 on the 7-segment display it is necessary to select and turn on segments b and c. Figure 8 shows how this can be accomplished. The first thing to observe is that the Easy68K supports an 8-digit 7-segment display, where each 7- segment display can be used to display a digit. Each of the eight 7-segment displays has its own memory-mapped address: the first 7-segment display is located at address 0xE00000, the second at 0xE00002, the third at 0xE00004, and so on. (Notice that the 7-segment displays are located at consecutive even addresses.) The bytes at each even address are used to write to the 7-segment displays. For example, to display the number 1 on digit 1 – the first 7-segment display on the left in Fig. 8 – the binary code 000001102 must be written to address 0xE00000 in order to select and turn on segments b and c. Notice that the most-significant a" b" c" g"f" e" d" b" c" (a)$Segment$designa.on$
Nov 25, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here