Pages

DESIGNING OF EMULATOR FOR 8051 MICROCONTROLLER

 Simulators and Emulators

 Simulations are very useful in the analysis as well as the design of the systems. A variety of simulators and software are available in the market to test the systems of different types. Simulators are just software that estimate the response of the system to some given input on the basis of given characteristics and parameters (mathematical model) of the system. Although simulators perform very well in many cases yet performance depends upon the accuracy of the modeling. In general models are not accurate due to the tolerance in the physical parameters of the system and environment dependent characteristics of the systems etc. Normally simulators do not generate real time results and this problem is more critical while studying the behavior in time domain.

             Although the above is more general discussion yet it is valid for microcontrollers also. Available simulators for microcontroller are helpful to test the programs flow and logical errors etc but fail to test the performance of microcontroller and generate results in some cases such as pulse width measurement, wave form generation (actual time period and duty cycle is not measured), clocking from some external source at timer in put  and serial transmission and reception (simulator transmit whole character at once in one machine cycle and effect of baud rate could not be tested) etc. In such situations emulators are more reliable and helpful.          

Emulators are the interface circuits to test the functionality of some system such as microcontrollers and DSP processors using some software/program at computer to generate inputs and test some of the outputs generated by the actual system. Emulators are useful when some program is to be tested before burning it onto the hardware such as EPROM or EEPROM. They may be used as training kits for beginners also.

As an example, consider the problem that someone programs the microcontroller to perform some task, but when microcontroller executes the program there are some undesirable results due to some error in the program or low performance of the hardware attached (which can’t be tested in some type of simulation). As a result the user has to change the program and burn it once again. In some complex system problem may occur a number of times and it require to burn the program a number of times, as a result there is not only the wastage of time but resources also.

 Sometimes, in the implementations of controllers for some control system, online tuning is required for some parameters and it is very easy when we are using RAM or magnetic memory to store the data (code) as compared to EPROM. In both of above cases, Emulators are very helpful.

HEX files are generated on PC using some assembler or higher level language compiler such as C-51 then opcode is loaded in the RAM through parallel port. Microcontroller may use this RAM as code memory (EPROM). As the microcontroller executes the program, results could be analyzed using some software and interface circuitry between microcontroller and PC. Once all the results are verified and all the parameters are set to some final value the program may be burnt onto the EPROM.

Generic design of Emulator for Microcontroller

The generic design of emulator for microcontroller is based on communication with computer using parallel port. The Hardware section consists of implementation of blocks shown in figure below. (PC to RAM interface). To design and implement this interface study of Parallel port and RAM is necessary.

Emulator for debugging

Generic design of Emulator for Microcontroller

PC Parallel Printer Port


The use of PC Parallel Printer Port is the easiest way of interfacing the home made projects with PC. Parallel Port could be accessed easily using C or C++.Four control signal lines (output signals) and five status signal lines (input signals) along with eight data signal lines (I/O) make interfacing easy. Detailed material is available on the internet in this regard, only few properties of Parallel Port are discussed below.
Description of pin layout of Parallel Port
 Parallel Port pin layout
Parallel Port Registers

Three 8-bit registers are associated with parallel port as shown in above figure. Data register at Base address of parallel port is a read/write register it is used to sent and receive data through parallel port. Status register at Base address + 1 is used for control input signals. Only 5-bits of this register are accessible to the external hardware to send some control signal. Control register at Base address + 2 is used by PC to send control signals to external device. Only 4-bits can be used in this case.

Normal Problems While Using Parallel Port

Although there may be as many problems as users but here I am discussing few problems faced by me while using the parallel port for interfacing.

(i) Operating System

 Although it is very easy to access the parallel using built in functions (outport(…. ) and inport(….))of C and C++ yet all the operating system do not allow the access to parallel port directly. There are methods to access parallel port but parallel and serial port is not accessible using C or C++ functions while working in the windows NT based operating systems such as windows2000, windows XP etc.

 (ii) Enabling in RD/WR mode

Parallel port is enabled in write mode by default and there is no problem in the use of parallel port while sending data out. Results are unexpected when a data byte is read from parallel port without enabling it in read mode. Bit-5 of control register is used to enable read or write mode of parallel port. To understand this see figure below.

 

Bi-Directional Interface PC Parallel Port
Read or Write Mode of PC Parallel Port, Bi-Directional Interface

From the above diagram it is clear that the Bit-5 of control register should be cleared while writing data to parallel port and should be set while reading from parallel port.

SOFTWARE

Software part of the project can be divided into two parts:

(i)              Reading the useful information from HEX file

(ii)            Writing the data on RAM using parallel port 

OBJECTIVES

Main objectives of this project are the following: 

  • Understanding of HEX file format
  • The parallel port interface with external devices.
  • Develop a software to shift the opcode from HEX file to external RAM.
  • Design and implementation of interface circuit between RAM and PC.
  • Interfacing of microcontroller with RAM.
These will be discussed in coming post one by one.

No comments:

Post a Comment

Please ask if you have any question regarding the programming of MCU, or have any problem in development of your electronics project. microcontroller51.blogspot.com