"EMU-II" Emulator



In the first edition of this book, I created a very complex "emulator" which used an external serial EEPROM for storing instructions. This application worked okay, but was very (read "unnecessarily") complex and slow - the best speed I was able to observe was about ten thousand instructions per second. This application takes advantage of the PIC16F876 to read and write its own program memory to download a hex file and allow you to single step through it at a full application speed of 4 MHz. 


This application is not perfect, but it is an excellent tool to see how the PICmicro® MCU works and help you to debug your own applications. The tool itself is wired to a PC/Workstation in exactly the same manner as the YAP-II and requires the same power input. 


Click Here to access the source code on the CD-ROM. When you read the text, you'll see that I came up with the DT Compress utility that converts ASCII table data in the PIC16F87x parts (which can read their own program memory). This code takes an assembler source file (ending in ".asm") and converts "dt" statements into "dw" statements when they have been identified with:
;#CompStart
              
statements. To end the DT Compress operation, the:
;#CompEnd
              
statement is put in. This is shown in the compress.asm" assembler code. Compare this file to compress.inc.
When I laid out the PCB for the EMU-II, I used the same form factor as the YAP-II. This simplified the layout work somewhat, but more importantly, gave me the same peripherals as the YAP-II, which allows the EMU-II to work through many of the same experiments as the YAP-II. The biggest difference between the EMU-II and the YAP-II is the lack of a clock at the PICmicro$reg; MCU connector. For experiments and applications that are put on the PCB's breadboard, they will also have to have their own oscillator.

The EMU-II's primary circuit is shown in the emu-ii.pdf file. The peripheral functions can be found in the yap-iiac.pdf file and are identical to the YAP-II's. 


The bill of materials for the YAP-II is listed in the table below. 


Part Description
U1 PIC16F877-04/P
PIC16F876-04/SP
U2 18 Pin Socket/ZIF Socket
U4 78L12 +12 Volt Regulator in a TO-92 Package
U5 Maxim MAX232 RS-232 Interface
U6 7805 +5 Volt Regulator in a TO-92 Package
Y1 4 MHz Ceramic Resonator with Internal Capacitors
CR2 - CR5, CR7 1N914 Silicon Diode
CR4 1N4001 Silicon Diode
CR1, CR6 5mm LED, Any Type
LED3 10 LED "Bargraph" Display
T1 2N3904 NPN Bipolar Transistor
Q5 2106A P-Channel MOSFET (Digi-Key Part Number: ZVP2106A-ND)
R1 10K, 1/4 Watt Resistors
R2, R7 220 Ohm, 1/4 Watt Resistors
R35, R10, R13 330 Ohm, 1/4 Watt Resistors
POT1 - POT2 10K, Single Turn PCB Mount Potentiometer (Digi-Key Part Number: 3310Y-1-103-ND
SIP1 - SIP2 220 Ohm, x9 Common Pin SIP
C3 0.1 uF Capacitors (Any Type)
C4 - C8 1.0 uF Capacitors (Any Type)
C1 - C2 10 uF, 35 Volt, Electrolytic Capacitors
CSPKR 0.47 uF, 16 Volt, Tantalum Capacitor
SPKR Piezo Speaker (Digi-Key Part Number: P9922-ND)
SW1 SPDT PCB Mount Switch
SW2, BUT1, BUT2 Momentary On, PCB Mount Push Buttons
J1 2.5 mm PCB Mount Power Socket
J2 9-Pin Female PCB Mount D-Shell
J3, J5 19x1 Female IDC Connector
J4, J6 5x1 Female IDC Connector
Miscellaneous PCB Board, Serial Cable, Power Supply
The nineteen pin connector wired to the PICmicro MCU is defined as:

Pin Function
1 Gnd
2 Vcc
3 _MCLR - No High Programming Voltage
4 - 6 RC3 - RC5
7 - 11 RA0 to RA4
12 - 19 RB0 to RB7. Note: RB6 and RB7 cannot be loaded during programming operation

Operation

Once the display is active, then the commands listed in the following table can be entered. Note that "Parameters" in square brackets ("["/"]") are optional. All numeric data is in hexadecimal and register addresses can either be a hex address or a register name. When register data is displayed, the information will either be in hex or binary format depending on which format is appropriate for the register. 


Command Parameters Comments
H
Display List of Commands
D
Download Application Hex File
! [D | A] Reset Emulated Part with "A"nalog or "D" PORTA I/O Pins
1 [Address] Single Step starting at current Program Counter or Specified Address
  • If "Enter" pressed/"Carriage Return" Sent without a command then Single Step from current Program Counter is invoked
J [Address] Single Step starting at current Program Counter or Specified Address
  • If Instruction to single step is a subroutine "call", then Execution resumes at the instruction after the call instruction
  • If breakpoint is encountered within the subroutine, then Execution will stop at that breakpoint
G [Address] Start Executing at current Program Counter or Specified Address
  • If breakpoint is encountered, then Execution will stop at that breakpoint
I Address Set Program Counter to specified Address
R
Display the Primary Special Function Registers in the PICmicro MCU
S Register Display the contents of 16 Registers starting at "Register" Address
E Register Display and optionally change the contents of the specified Register
B [Address] Toggle a breakpoint at either the specified address or the current Program Counter
C
Clear all the Breakpoints in the Emulator
U [Address] Disassemble the 22 instructions starting at either the current Program Counter or the specified address
+ [Address] Load hex values that are to be entered into Program Memory either Starting at the current Program Counter or the specified address
The operation of the application is quite straightforward with the only non-intuitive operation being the application download operation. To load a new application into the EMU-II's Program Memory, carry out the following steps:
  1. Enter "D"/CR ("Enter" if a PC is being used). The EMU-II will return with a message saying that Program Memory is being cleared
  2. When the EMU-II requests the application to be downloaded, use the Terminal Emulator to send a "Text File" "Hex File". This operation will be picked up by the EMU-II and the application code will be stored into the Program Memory devoted to the operation
The Download operation will not typically have any feedback as to the status of the operation. This can make the operation worrisome but note that after the application hex file has been sent, the EMU-II will poll incoming serial data for five seconds to ensure the host system (PC) download was not pre-empted by another task. No characters should be entered in the PC keyboard until the EMU-II prompt (which will be at address 0) has been displayed.
The following register names have been built into the EMU-II to allow for some symbolic application debugging:

Bank 0 Bank 1
Address Register Name Address Register Name
0x000 INDF 0x080 INDF
0x001 TMR0 0x081 OPTION (2)
0x002 PCL 0x082 PCL
0x003 STATUS 0x083 STATUS
0x004 FSR 0x084 FSR
0x005 PORTA 0x085 TRISA
0x006 PORTB 0x086 TRISB
0x007 PORTC 0x087 TRISC
0x008 PORTD (1) 0x088 TRISD (1)
0x009 PORTE (1) 0x089 TRISE (1)
0x00A PCLATH 0x08A PCLATH
0x00B INTCON 0x08B INTCON
0x00C PIR1 0x08C PIE1
0x00D PIR2 0x08D PIE2
0x00E TMR1L 0x08E PCON
0x00F TMR1H 0x08F Zero (3)
0x010 TCON1 0x090 Zero (3)
0x011 TMR2 0x091 SSPCON2
0x012 TCON2 0x092 PR2
0x013 SSPBUF 0x093 SSPADD
0x014 SSPCON 0x094 SSPSTAT
0x015 CCPR1L 0x095 Zero (3)
0x016 CCPR1H 0x096 Zero (3)
0x017 CCP1CON 0x097 Zero (3)
0x018 RCSTA (4) 0x098 TXSTA (4)
0x019 TXREG (4) 0x099 SPBRG (4)
0x01A RCREG (4) 0x09A Zero (3)
0x01B CCPR2L 0x09B Zero (3)
0x01C CCPR2H 0x09C Zero (3)
0x01D CCP2CON 0x09D Zero (3)
0x01E ADRESH 0x09E ADCRESL
0x01F ADCON0 0x09F ADCON1
The following notes apply to the registers:
  1. Registers and I/O Ports are Not Available in the PIC16F876
  2. Register is known as "OPTION_REG" in Microchip Documentation/Tools
  3. No special functions devoted to these registers, 0x000 always returned upon register read
  4. Registers used by the EMU-II. These registers along with the registers EEPROM registers (EEDATA, EEDATH, EEADR, EEADRH, EECON1 and EECON2) should never be accessed except using the functions listed below
As indicated in the notes above, the USART and EEPROM registers should never be accessed by an application. Instead, the following functions should be used for serial communications with the PC Host and for accessing the Data EEPROM. The Program Memory EEPROM must never be accessed. The serial port registers are enabled for non-interrupt communications at 1200-8-N-1 and should not be modified in any way.

Address Function Name Description
0x07B0 SerialPoll If Character Received and not yet read, return with the carry flag set
0x07C0 SerialRead Wait until a character has been received and return it in "w"
0x07D0 SerialWrite Send the Character in "w" out serially to the host
0x07E0 EERead Read the Data EEPROM at the Address specified in FSR
0x07F0 EEWrite Write the Data EEPROM with the value in "w" at the Address specified in FSR

EMU-II Application Specification

Applications written for generic PICmicro MCU applications can be debugged using the EMU-II with very little modification. The EMU-II was designed to minimize the need for developing applications that had to be modified for both EMU-II operation and actual application operation. 

To create applications that can be debugged on the EMU-II, the following rules must be followed:
  1. "nop" as the first instruction at address 0x0000
  2. Variables should start at 0x020 rather than 0x00C as is possible in some devices
  3. Use the USART and EEPROM functions listed above and do not access the Special Function Registers that control these functions directly
  4. For variables that are accessed from either Bank 0 or Bank 1, use address range 0x070 to 0x07E


Ideally, applications should not access any registers in Bank 2 or Bank 3 as the EMU-II state variables are stored in these banks along with the EEPROM access control registers.
As noted above, applications cannot be larger than 1,792 (0x0700) instructions. It is recommended that applications use the:
__CONFIG
             
statement to specify the operating characteristics of the application even though it will be ignored by the EMU-II. The config and __IDLOCS data will be stored within the EMU-II for programming into a PICmicro MCU.

No comments:

Post a Comment

Labels

PROJECTS 8086 PIN CONFIGURATION 80X86 PROCESSORS TRANSDUCERS 8086 – ARCHITECTURE Hall-Effect Transducers INTEL 8085 OPTICAL MATERIALS BIPOLAR TRANSISTORS INTEL 8255 Optoelectronic Devices Thermistors thevenin's theorem MAXIMUM MODE CONFIGURATION OF 8086 SYSTEM ASSEMBLY LANGUAGE PROGRAMME OF 80X86 PROCESSORS POWER PLANT ENGINEERING PRIME MOVERS 8279 with 8085 MINIMUM MODE CONFIGURATION OF 8086 SYSTEM MISCELLANEOUS DEVICES MODERN ENGINEERING MATERIALS 8085 Processor- Q and A-1 BASIC CONCEPTS OF FLUID MECHANICS OSCILLATORS 8085 Processor- Q and A-2 Features of 8086 PUMPS AND TURBINES 8031/8051 MICROCONTROLLER Chemfet Transducers DIODES FIRST LAW OF THERMODYNAMICS METHOD OF STATEMENTS 8279 with 8086 HIGH VOLTAGE ENGINEERING OVERVOLATGES AND INSULATION COORDINATION Thermocouples 8251A to 8086 ARCHITECTURE OF 8031/8051 Angle-Beam Transducers DATA TRANSFER INSTRUCTIONS IN 8051/8031 INSTRUCTION SET FOR 8051/8031 INTEL 8279 KEYBOARD AND DISPLAY INTERFACES USING 8279 LOGICAL INSTRUCTIONS FOR 8051/8031 Photonic Transducers TECHNOLOGICAL TIPS THREE POINT STARTER 8257 with 8085 ARITHMETIC INSTRUCTIONS IN 8051/8031 LIGHTNING PHENOMENA Photoelectric Detectors Physical Strain Gage Transducers 8259 PROCESSOR APPLICATIONS OF HALL EFFECT BRANCHING INSTRUCTIONS FOR 8051/8031 CPU OF 8031/8051 Capacitive Transducers DECODER Electromagnetic Transducer Hall voltage INTEL 8051 MICROCONTROLLER INTEL 8251A Insulation Resistance Test PINS AND SIGNALS OF 8031/8051 Physical Transducers Resistive Transducer STARTERS Thermocouple Vacuum Gages USART-INTEL 8251A APPLICATIONs OF 8085 MICROPROCESSOR CAPACITANCE Data Transfer Instructions In 8086 Processors EARTH FAULT RELAY ELECTRIC MOTORS ELECTRICAL AND ELECTRONIC INSTRUMENTS ELECTRICAL BREAKDOWN IN GASES FIELD EFFECT TRANSISTOR (FET) INTEL 8257 IONIZATION AND DECAY PROCESSES Inductive Transducers Microprocessor and Microcontroller OVER CURRENT RELAY OVER CURRENT RELAY TESTING METHODS PhotoConductive Detectors PhotoVoltaic Detectors Registers Of 8051/8031 Microcontroller Testing Methods ADC INTERFACE AMPLIFIERS APPLICATIONS OF 8259 EARTH ELECTRODE RESISTANCE MEASUREMENT TESTING METHODS EARTH FAULT RELAY TESTING METHODS Electricity Ferrodynamic Wattmeter Fiber-Optic Transducers IC TESTER IC TESTER part-2 INTERRUPTS Intravascular imaging transducer LIGHTNING ARRESTERS MEASUREMENT SYSTEM Mechanical imaging transducers Mesh Current-2 Millman's Theorem NEGATIVE FEEDBACK Norton's Polarity Test Potentiometric transducers Ratio Test SERIAL DATA COMMUNICATION SFR OF 8051/8031 SOLIDS AND LIQUIDS Speed Control System 8085 Stepper Motor Control System Winding Resistance Test 20 MVA 6-digits 6-digits 7-segment LEDs 7-segment A-to-D A/D ADC ADVANTAGES OF CORONA ALTERNATOR BY POTIER & ASA METHOD ANALOG TO DIGITAL CONVERTER AUXILIARY TRANSFORMER AUXILIARY TRANSFORMER TESTING AUXILIARY TRANSFORMER TESTING METHODS Analog Devices A–D BERNOULLI’S PRINCIPLE BUS BAR BUS BAR TESTING Basic measuring circuits Bernoulli's Equation Bit Manipulation Instruction Buchholz relay test CORONA POWER LOSS CURRENT TRANSFORMER CURRENT TRANSFORMER TESTING Contact resistance test Current to voltage converter DAC INTERFACE DESCRIBE MULTIPLY-EXCITED Digital Storage Oscilloscope Display Driver Circuit E PROMER ELPLUS NT-111 EPROM AND STATIC RAM EXCITED MAGNETIC FIELD Electrical Machines II- Exp NO.1 Energy Meters FACTORS AFFECTING CORONA FLIP FLOPS Fluid Dynamics and Bernoulli's Equation Fluorescence Chemical Transducers Foil Strain Gages HALL EFFECT HIGH VOLTAGE ENGG HV test HYSTERESIS MOTOR Hall co-efficient Hall voltage and Hall Co-efficient High Voltage Insulator Coating Hot-wire anemometer How to Read a Capacitor? IC TESTER part-1 INSTRUMENT TRANSFORMERS Importance of Hall Effect Insulation resistance check Insulator Coating Knee point Test LEDs LEDs Display Driver LEDs Display Driver Circuit LM35 LOGIC CONTROLLER LPT LPT PORT LPT PORT EXPANDER LPT PORT LPT PORT EXTENDER Life Gone? MAGNETIC FIELD MAGNETIC FIELD SYSTEMS METHOD OF STATEMENT FOR TRANSFORMER STABILITY TEST METHODS OF REDUCING CORONA EFFECT MULTIPLY-EXCITED MULTIPLY-EXCITED MAGNETIC FIELD SYSTEMS Mesh Current Mesh Current-1 Moving Iron Instruments Multiplexing Network Theorems Node Voltage Method On-No Load And On Load Condition PLC PORT EXTENDER POTIER & ASA METHOD POWER TRANSFORMER POWER TRANSFORMER TESTING POWER TRANSFORMER TESTING METHODS PROGRAMMABLE LOGIC PROGRAMMABLE LOGIC CONTROLLER Parallel Port EXPANDER Paschen's law Piezoelectric Wave-Propagation Transducers Potential Transformer RADIO INTERFERENCE RECTIFIERS REGULATION OF ALTERNATOR REGULATION OF THREE PHASE ALTERNATOR Read a Capacitor SINGLY-EXCITED SOLIDS AND LIQUIDS Classical gas laws Secondary effects Semiconductor strain gages Speaker Driver Strain Gages Streamer theory Superposition Superposition theorem Swinburne’s Test TMOD TRANSFORMER TESTING METHODS Tape Recorder Three-Phase Wattmeter Transformer Tap Changer Transformer Testing Vector group test Virus Activity Voltage Insulator Coating Voltage To Frequency Converter Voltage to current converter What is analog-to-digital conversion Windows work for Nokia capacitor labels excitation current test magnetic balance voltage to frequency converter wiki electronic frequency converter testing voltage with a multimeter 50 hz voltages voltmeter

Search More Posts

Followers