BUILDING A MICROCOMPUTER SYSTEM

1. OBJECT 1.1 To design a microcomputer system using the 80C188 chip. 1.2 To construct and debug the hardware of the microcomputer system designed. 1.3 To develop a bootstrap loader for the microcomputer system constructed. 1.4 To use the bootstrap loader for the development of application software for the microcomputer system.

2. INSTRUCTION With advancement of semiconductor technology, the cost of has dropped tremendously. The cost has dropped to a stage where is now considered feasible to include microprocessors as intelligent controllers in many consumer products.

The development of based system is no longer a task of a big development group in a company. Today more engineers are expected to single handedly design and implement microprocessor based systems as stand-alone intelligent controllers without the help of expensive emulator sets. The need to compete effectively also cuts the allowable turn-around time for design of such systems to a bare minimum. There is therefore a pressing need for new engineers to master the skill to systematically develop a system without expensive aids and in the shortest possible time.

In this experiment, the student will be guided on the procedure to systematically develop a system for microprocessor based applications.

3. EQUIPMENT IBM compatible PC with at least one serial port Oscilloscope EPROM programmer UV eraser Soldering equipments Components as per students’ design (INTEL 80C188 based)

4. DESIGN THE HARDWARE OF A SINGLE CARD MICROCOMPUTER SYSTEM i) Study Figure 1 and the pin description of the 80C188 very carefully. The following will help you design the memory subsystem of the computer system.

(a) Note that output pins are used to control the operation of external devices. You will have to study the logic function of each of the output pins to determine how they are to be used to control your devices (e.g. RAMs, ports etc.).

(b) Input pins to the microprocessor are checked by the microprocessor and usually determine the subsequent operations. It is therefore very important that you find out exactly how each input pin affects the operation of your microprocessor and then bias them correctly.

(c) First consider the clock generator. This is the “heart” of the microprocessor. How do you connect a crystal to provide the “heartbeat”?

(d) NMI (non-maskable interrupt) - input pin. What does it mean by non-maskable? What happens if this pin is not properly biased? Note that this pin is edge triggered. It does not matter what the steady state level is. For this design, provide a push button switch to give a pulse as and when desired.

(e) HOLD and HLDA. What are the functions of these two pints? What happens if they are not properly biased?

(f) AD0-AD7. Multiplexed address and data . How to de-multiplex them? How about using a 74HC573? What is the logical function of the 74HC573? What is the purpose of the pin ALE/QSO of the microprocessor? Ho do you handle the output enable pin of the 75HC573?

(g) A16-A19. Multiplexed address and status bus. Do you really need to use them? Think carefully. If you really want to make use of these pins in part II, then you have to de-multiplex them just like AD0-AD7.

(h) A8-A15, address bus. For the 80C188, these are not multiplexed.

(i) MCS0 to MCS3 , PCS0 to PCS4 . Chip selection pins. Read about their functions. It is

useful for your part II.

(j) ARDY&SRDY. What is it used for? Make sure you biased it correctly, otherwise your circuit will not work! Why?

(k) RES pin. Used to reset the CPU to some initial state. What circuit would you connect to this

pin? ii) Selecting the memory configuration

(a) Do you need RAMs, EPROMs or both? Why? Consider the memory map of the 8088 or 80C188. Where should you put the RAMs and EPROMs in the memory map? To help you, consider the default state of CS and IP when the microprocessor is reset. These are important information and you should be able to find these information in the data sheet, books etc. This determines the location of the first instruction fetched by the CPU. Do you put RAM or EPROM at this location? Note that once the microprocessor comes out of the reset state, this location must provide the first instruction. Otherwise the microprocessor will “hang”. Next consider the locations of the interrupt vector table of the CPU. Do you put RAMs or EPROMs at these locations? With these questions correctly answered, you will be able to determine the addresses to be allocated to the RAM and EPROM chips. Subsequently, you will be able to design the address decoding circuit to select the locations in the RAM and EPROM chips.

(b) At this point, you should be able to draw up a detailed logic diagram of your design. If all goes well with your thought process, your design should contain the following components; 80C188, one RAM, one EPROM, one 74H573, one 74HC04, a crystal, 2 switches, capacitors and resistors. Note that in this experiment, I have not asked you to do a proper analysis of timing and drive requirements. I had checked these for you and ordered the appropriate components. However in your future designs, you will have to ensure that timing and drive requirements are fulfilled. iii) Connecting up your circuit

(a) Insert the IC sockets into the circuit board and secure them at 2 points each. Insert an IC pin reference card for each IC socket.

(b) Connect the power supply lines for all your chips. Decouple your power lines at each IC. Why? You will need a capacitor of higher value for your 80C188 chip.

(c) Connect up the crystal for your microprocessor. Check that your clock is working. How? Examine the signals at the following pins, X1, X2, CLKOUT.

(d) Properly bias all the input lines to the microprocessor. Note that you have a R-C circuit connected to your RESET and NMI pins. Apply power to your circuit and check the CLKOUT of the 80188. Note that unless you are sure that what you see at the CLKOUT is correct, do not proceed to wire up the rest of the circuit.

(e) Connect up your address/data de-multiplexer, address decoder circuit and memory chips. This should take about 2 hours or so. Ensure that the circuit is soldered carefully (no shorts). It is wiser to invest more time doing a neat job here than to have lots of headache debugging the circuit later.

(f) If no mishap occurs along the way, you should be at this point in about 5 hours. We are now ready to move on to write the bootstrap loader for your stand-alone microcomputer system.

5. WRITING THE BOOTSTRAP LOADER SOFTWARE i) Introduction

Once the hardware is up, the next task is to write the application software and somehow gets the hardware to run it. On a PC, this process is in a way automated and transparent to you. This is because the PC has an operating system which takes care of the loading and starting tasks. However, on a stand-alone system like what you have just constructed, you are responsible for these tasks.

One obvious way that you can do is of course write the application software, compile it to the binary image, burn it onto the EPROM, pluck in the EPROM to your system, power up the system and hope that all goes well. If it is a simple 2-3 pages program you are writing, this will probably take 10-20 iterations. If it is anything longer, you will probably run out of patience before you complete the task. This in a way forces us to look at ways to do soft loading instead of hard loading. In this experiment, we will look at a bootstrap loader to perform the soft loading.

In this experiment we will use the PC as an extension of our hardware card for software development. The overall concept of the scheme is shown in Figure 2. The PC is linked electrically to your hardware card via a RS-232C serial link. Check that on the side of the PC, it is just transmit, receive and ground of either COM1 or COM2. On the side of your hardware card, it is just the transmit, receive and ground of the 80C188. Of course for RS-232C, the communication voltages are +/-15 volts. A 5V to +/-15 V converter has been designed in the circuit to convert the voltages.

With the above hardware connection and the bootstrap loader residing in the EPROM, you can now write the source code of your application program on the PC. This source code can be compiled into the binary image on your PC. Once that is done, you can run one of the serial port service software such as VTERM.EXE HYPERTERMINAL to send the binary image of the application program to the hardware card you had constructed. Note that there is no absolute necessity to use VTERM.EXE or HYPERTERMINAL. You can even write your own COM port service routine. It is not that difficult.

On the side of the hardware card, we know that the image of some application software is coming through the serial line. What the bootstrap loader needs to do is to continually check the serial port for data received. If data is received, it will put them at the appropriate place in memory. Once the file transfer is completed, it will transfer control by making a jump to the appropriate starting location.

With this concept in mind, what we really need to do at this point in time is to define the data structure for the file transfer. A convenient standard is the INTEL HEX code format, which we adopt in this project. The format for file transfer can be summarized in terms of Figure 3. Study the flowchart carefully so that you write the bootstrap loader correctly.

To write the complete bootstrap loader from scrap is really a 2 days job. You would not be able to complete within the few lab sessions. I have therefore made the task easier for you by writing a good part of the program for you, except the file transfer part. Three files are available for you.

“80188.INC” is an “include” file that initialize system I/O area of the 80C188, timer and serial port. The file is well documented. Read the file will give you a good idea of I/O system of the 80C188.

“BOOT86MC.INC” is another “include” file that contains all the macros that you need to use to write the bootstrap loader.

“BOOT86.ASM” is the main program. The structure of the program is all there for you. What I had done is to remove part of the code so that you can have a hand at filling up the “blanks”. Read the program carefully before coming to class and it will give a clear picture as to what to do. ii) Hands-on

(a) Complete the program in “BOOT86.ASM” and compile it using the batch file “BOOT86.BAT”. Burn the binary image into an EPROM and pluck the EPROM into your hardware card.

(b) Apply power to your card and run VTERM on the PC. Press “RESET” of your card. What happens? You can take a look at the demonstration set to find out what should happen. If your set does not react like what the demonstration set does, then obviously something is wrong. It could be hardware or software bugs! You can determine whether it is hardware or software by plucking one of my pre-programmed EPROM onto your set. Note that if you are on your own, you will not have this luxury.

Try sending the file “TEST.HEX” to your card. Does it work like what it is supposed to do? If not, go back and debug your bootstrap loader until it is totally correct.

REFERENCE 1. 80C186/80C188XL Microprocessor User’s Manual, 1995 2. 80C188 Microprocessor datasheet 3. The 8088 Microprocessor Programming Interface, Software, Hardware and Application, Avtar Singh and Walter A Triebel, Prentice Hall, 1989. 4. Intel Microsystem Component Handbook, vol 1 and 2, 1984.

Figure 1. Embedded Computer Systems Design Figure 2. Overall view of the bootstrap loader system

* Running serial port service routine such as * Hardware: basic microprocessor VTERM.exe. system with memory & serial port interface. * Program to be downloaded - in Intel hex format to be sent serially through the serial * Software: a bootstrap loader that keeps port. checking the serial port for data received. On receipt, put data into memory. * Standard commercially available or public domain. * We will be writing this bootstrap loader in this project.

A

SYNCH=3A get char

:? n

y

get no. of bytes to send

get offset address

get type of record sent

00 01 10 11

get byte & jump to start get segment get start put into address address address memory

out A put addr at last byte? NMI vector n loc

y

A A

Figure 3. Flowchart for reading of Intel Hex Code format Pin Layout of Intel 80188 from data sheet of ‘80186/80188 microprocessors’