Microelectronics and Reliability, Vol. 16, pp. 413-417. Pergamon Press, 1977. Printed in Great Britain.
A COMPLETE MICROCOMPUTER ON A CHIP P. Pittman Mostek UK Limited, Masons House, 1 Valley Drive, Kingsbury Road, London NW9
Tile MK 3870 from Mostek is a complete 8 bit microcomputer on a single MOS integrated circuit. Utilising state of the art, ion-implanted, n-channel silicon gate technology and advanced circuit design techniques, a truely versatile, cost effective microcomputer has been achieved. The device, however, does not stand alone; identical instruction sets gi~ing both software and timing compatibility with the existing F8 microprocessor allow expansion into multichip configurations suitable for both high and low volume production. A complete line of inexpensive hardware and software is offered which can be used to emulate or prototype the single chip microcomputer. The device contains many features which reduce system cost. The single 5 volt power supply (witb 10% tolerance) allows it to fit into any standard TTL logic environment. Programming speed and flexibility is guaranteed with the 2K bytes of ROM, 64 bytes of scratchpad, binary timer and interrupt. The versatility and economy of the device allow it to servicp an unusually wide spectrum of control, logic replacement and data processing applications. The main architectural features of the MK 3870 microcomputer are illustrated in figure i. The provision of a 2K byte ROM for program storage means that this device can tackle considerably more complex applications than has been possible with other single chip microcomputers. Of the 64 bytes of RAM for variable data storage, 12 may be addressed directly by various data transfer, arithmetic and logical instructions of the 70-plus instruction set. Those that are not directly accessible may be addressed indirectly using the Indirect Scratchpad Address Register (ISAR). some of these registers can be used for special functions. For example, it is possible to transfer data between certain of these and the Program Counter, Stack Register and Data Counter Registers. This enables the programmer to easily create a 'software stack' in the scratchpad if additional subroutine levels are required. The Stack Register allows single level subroutine calls or interrupts to be handled without additional processing. The Data Counters are two separate ii bit registers which may be used to indirectly fetch data values from the program memory area, thereby allowing easy access to tables of data in ROM. The provision of a second Data Counter means that two such tables may be handled simultaneously. Furthermore, being a full II bits in length, there are no paging limitations for addressing. The 4 input/output ports are bidirectional to give increased flexibility in interfacing to peripheral devices. One of these ports has a strobe pulse associated with it, allowing a simple peripheral handshaking scheme to be implemented. While complete instruction operation and timing compatibility has been maintained with the previous F8 microprocessor chip set, there are several n e w f e a t u r e s now incorporated into the timer and interrupt operation. The timer, which derives its reference from the CPU clock, uses an 8-bit binary counter with a software programmable prescaler variable from 2 to 200. The timer interrupt and the external interrupt may be enabled individualy or simultaneously, each having their own unique vector address and with the timer having highest priority. By programming the appropriate combinations of timer and interrupt facilities it is possible to, not only generate time delays or count external events, but measure pulse widths and periods. The processor's on-chip clock generator may be controlled by an external crystal, LC or RC components or by its own internal source if timing accuracy is not required. The special Test pin on the package has a 3-1evel operation allowing the internal ROM and ALU operation to be monitored on an I/O port and allowing external instructions to be forced in, overriding the internal ROM. Applications There are numerous applications which may be performed by a circuit such as this, especially when one considers the very low cost of the device. However, the timer and interrupt facilities suggest some very useful applications in the M.R ,I
413
414
P. Pittman
field of speed and frequency control or measurement in addition obvious process control and data handling applications.
to the more
Speed control of an A.C. motor Using the external ~nterrupt facility to detect 50 HZ. mains crossing points, and using the timer to generate a delay proportional to the phase angle, it is possible to generate a triac triggering pulse to control the speed of an A.C. motor. The CPU may receive two interrupts, one every iO ms from the 50 HZ. zero crossings, and one from the timer. When a zero crossing occurs, the phase angle is converted to a timer value by the processor. If this value is zero then the triac is triggered irmnedia~ely. If not zero, it is loaded into the timer register and the triac is triggered after the time delay has elapsed and the timer interrupt occurs. The flowchart for the two interrupt routines in shown in figure 2. These programs, whidl form the main control loop, require less than 40 bytes of memory. Speed me@surement
of a rotatin$
shaft
Using a slotted disk on a shaft and a simple photocell arrangement as shown in figure 3, a pulse may be generated, the width of which is inversely proportional to the speed of shaft revolution. This time may be conveniently measured using the pulse width measurement mode of the MK 3870 microcomputer. A minimum timer prescale of 2 will give the best resolution and by loading the counter register with its maximum value, interrupts can be generated to the processor every 256 microseconds. The total number of interrupts during the measurement period may be counted in software, the remaining least significant bits of the time period being always h e l d by the timer register. Simple arithmetic processing can convert this value to an actual speed measurement. The time measurement would be accurate to + 1 microsecond. Less than 40 bytes of program are required to set up the timer and obtain a figure for the time to complete one revolution of the shaft. An auto-ran$in$
frequency meter
Putting the MK 38,70 into the "event counter" mode allows pulses down to 1 microsecond duration to be counted. This means that square waves up to 5OOK HZ. may be directly measured. ~ e n the counter counts down to zero an interrupt is generated and the counter is automatically loaded from the preload register. Using this mode of operation a simple autoranging frequency meter may be constructed, as shown in figure 4, having a range from D.C. to 500K HZ. External prescalers may also be controlled by the processor, thus increasing the operating range. The circuit shown can range over 4 decade scales using 3 measurement times of 0.i, 1.0 and I0 seconds. Accuracy is a function of the IK HZ. reference frequency which may be derived from the 4.0 MHZ. CPU clock. This system may be implemented with a program of only 250 bytes. Development
Aids
An important part of any successful microcomputer family is good development and prototyping equipment. The MK 3870 microcomputer from Mostek is supported by a comprehensive software development system which resides on a single printed circuit board. ROM resident assembler and debug programs with flexible I/O assignments and also a text editor make this low cost system very powerful. The Applications Interface Module expands the facilities of the basic Software Development Board to give an in-circuit emulation capability. This emulator allows programs to be single stepped or executed in real time under control of user entered software breakpoints. The users ROM of the final single chip microcomputer is simulated in RAM to allow easy program debuging and modification. The next stage in the development cycle would be to use a PROM-based emulator for the single chip. Because of the compatibility with the multichip F8, a true emulation may be achieved using this family of components and standard IK x 8 EPROMS. A new I/O device for the family fully reproduces the timer and interrupt facilities of the MK 3870. This multichip, PROM based emulator is one of the prototyping aids available from Mostek. The board has a connecting cable terminating in a 40 pin D.I.L. which can be plugged into the single chip microcomputer socket on the users application, thereby giving an absolutely true emulation of the final mask programmed device.
plug
A Complete Microcomputer on a Chip
415
Single chip microcomputers will open up more and more applications where, until now, an electronic solution to a problem was not cost effective. The replacement of mechanical or electromechanical control systems will increase rapidly, as will the replacement of many simple conventional electronic analogue and digital systems. The evolution of the MK 3870 represents a significant step forward in this direction.
MK 3870 Single Chip F8
FEATURES • Software compatible with existing F8 family • Single +5 volt ±10% power supply • 2Kx8 mask programmable ROM • 64x8 scratchpad RAM • 32 bits (4 ports) bidirectional TTL compatible [/0 • Ready strobe provides handshake capability with Port 4 • Binary readable timer Modulo "N" Pulse width measurement Event counter Software selectable prescaler
MK 3870 Emulator EXT RESET
I I I
I-I ,,~,TO
[ L I--1
P,0
I"1
L ;!,;'~--e--I$TROI[
PORT 4
J
PORT EXT S IN--T
• Vectored interrupts (4 modes) External Internal External and internal Interrupts disables • Versatile single phase clocks 4MHz R-C L-C Crystal (standard 3.58 Mlqz may be used) Internal time base (no external components) • Low Power (Typ 300 mW) • Standard 40-pin plastic or ceramic package Fig. I.
Architectural features of the MK 3870 microcomputer.
4]6
P. Pittman
I,IN50TERRUPT ltz, I I
CHANGE INT, EDGE I
LITIMER NTERRUPIT
ICONVERT PHASEANC,1
{ UL" I ,,TRIAC
r PULSE I TRIAC
L
SET TIMER
L
L EXIT l
I
I., EXIT FIG,2
FLOWCHART FOR MOTOR SPEED CONTROL PROGRAM,
~ 4
LAMP
F-1
SHAFT .~...DISC
LINT
MK3870 F
PHOTOCELL~ HOLE FIG,
3
~
MEASURINGTHE SPEED OF A ROTATING SHAFT,
4
DISC
A Complete Microcomputer
on a Chip
417
4,0 MHz,
MK3870
i
o-IJjj_t ,0 KHz,
" 7406 4
4,7K INT
FREQU~.~,%__ INPUT"
V
5V.
1 KHZ,
INPUT CONDITIONING
FIG, 4
AUTORANGING FREQUENCY METER,
REFERENCE