10-30-2021 08:54 AM
Good day!
I am currently using Multisim 14.2 to simulate/demonstrate interfacing the 8051 MCU to an external ROM (27C64E250-883). I wanted to upload the code to the external ROM (by checking the Load machine code file only into attached XROM in MCU Code Manager) and was able to confirm that using the memory viewer. However, the assembly code does not seem to work anymore with that configuration. I also tried wiring the ROM to the MCU but to no avail. I have attached a screenshot of the simulation I am currently working on. The assembly code is as follows:
ORG 0H
START: CPL P1.0 ; complement the bit value at P1.0
ACALL DELAY ; call delay
SJMP START ; do it again
DELAY: MOV R4,#01H
WAIT1: MOV R3,#31H
WAIT2: MOV R2,#255H
WAIT3: DJNZ R2,WAIT3
DJNZ R3,WAIT2
DJNZ R4,WAIT1
RET
END
Is there something I am missing in the wiring connection or in the assembly code to make it work? Can Multisim simulate the signals in an actual hardware setup?
10-31-2021 10:08 AM
Hi MrDL2394,
First, I would like to clarify something about your code although this is not your main problem. Do you intend to write
WAIT2: MOV R2,#255
or
WAIT2: MOV R2,#0FFH
instead of
WAIT2: MOV R2,#255H
Did you encounter an error message during assembly or did the tools that you used displayed a warning but proceeded to generate code?
Regarding your main problem, I don't have the application Multisim (Desktop), I am only a user of Multisim Live which has limited features especially for Free Subscription user like me. I don't exactly know how Multisim simulates circuits with MCU. As I understand, there must be a working circuit aside from a correct code in order to run the simulation successfully. If this is the case then your circuit may be incomplete.
First, you don't have a clock source since XTAL1 and XTAL2 are both left floating. You can connect a crystal network on these pins, you can use an oscillator module, or you may simply utilize a square wave generator. Second, with RST pin left floating, you don't have a RESET circuit. You can connect an RC network or a µP/µC RESET module/subcircuit to RST. This will make the MCU start properly. A simple RC RESET network can be constructed by connecting a 10 µF capacitor from RST to Vcc and an 8.2 kΩ to 10 kΩ resistor from RST to ground (GND). Depending on the exact MCU that you are using, you may be able to reduce the value of the capacitor and the pull-down may not be required. The positive terminal of the capacitor should be connected to Vcc while the negative terminal goes to RST. Manual RESET button can be added by connecting a normally open push-button switch across the capacitor. Further refinement can be made but I will not proceed with that right now.
You have to verify if Multisim requires these components for complete circuit simulation or if RESET and clock source for MCU can just be simulated in software as well. Note also that for newer 8051 MCUs, RESET and clock can be generated internally so you don't have to add them in your circuit.
Another flaw that I see in your circuit is the latch that you use to demultiplex the data and low-order address buses. You used a 74LS373, for this and other functionally equivalent circuit using bipolar transistors, install a pull-up resistor network at the eight output lines (which are used as A7 to A0). The EPROM that you are using might work without the pull-up network (check the specifications to be sure) but if you will expand your system, you are not always guaranteed that the devices will work. If you don't like installing the pull-up resistor network you can use a 74HCT373 or other functionally equivalent latch from 74HCT family.
Best regards,
G. Goodwin
10-31-2021 01:37 PM
Hello GGoodwin,
Thanks for your reply and for pointing out that mistake in the assembly code, I will change it to:
WAIT2: MOV R2,#0FFH
However, I have tried incorporating your suggestions of adding the usual external components (XTAL for clock source, RC network for RESET, pull-up resistors connected to A0 to A7) in an actual hardware setup and it did not change the circuit's behavior in the simulation. I presume that Multisim simulates both the clock source and RESET functionality internally already.
To elaborate further, I have done the following test scenarios:
1) Program is loaded in MCU and EAVPP is floating: The LED blinks as expected.
2) Program is loaded entirely in ROM and EAVPP is grounded: The LED does not blink at all. The program is indeed loaded in the XROM (using Memory view) but the MCU cannot seem to access the program despite the external circuit made (please see attached image). The MCU memory view seems to indicate that PC is wandering beyond the expected last memory address of the program (higher than 12H). I was expecting that it should have been able to read the contents of the XROM.
3) Program is loaded both in MCU & XROM and EAVPP is grounded: In this case, I set the IROM of 8051 to 1 KB and intentionally made the program larger than that to see if the MCU will eventually access the XROM. It appears to have the same behavior as scenario no. 2, PC goes beyond 3FFH but does not read the instruction in XROM.
I am still not sure how to make scenario no.2 work in simulation. Could it be that Multisim is not capable of simulating the program placed entirely in an external ROM? I cannot seem to find anywhere or in the documentation how it is supposed to be done. I really hope that someone with the experience of using Multisim and interfacing an XROM with 8051 could give me some hints on how to go about it or at least point me to relevant documentation.
Thanks again for the response, it's much appreciated :))
11-02-2021 09:07 AM
It seems like this
... I presume that Multisim simulates both the clock source and RESET functionality internally already.
is true. Based on this
To elaborate further, I have done the following test scenarios:
1) Program is loaded in MCU and EAVPP is floating: The LED blinks as expected.
and from your original post, simulation is running properly with program in internal ROM. However, if you will make further experiments with clock source and RESET circuits, I suggest these
I am still not sure how to make scenario no.2 work in simulation. Could it be that Multisim is not capable of simulating the program placed entirely in an external ROM?
I cannot give a definite answer as of this time since I don't have Multisim (Desktop) and I've only read few of the previous posts of other members regarding this topic. It's possible that Multisim is initially capable of simulating code in internal program memory only and the capability to execute code in external ROM is a (very near) future upgrade, but I have not read any documentation or posting about this.
I cannot seem to find anywhere or in the documentation how it is supposed to be done.
Documentation might be scarce or hard to find but control of executing entirely from external program memory is simply through /EA.
The additional recommendations that I can give right now are:
I currently run out time for this, I'll try to continue maybe after two days. You can post the results or any observation you made when you conduct further experiments.
11-04-2021 10:09 AM - edited 11-04-2021 10:10 AM
This is the continuation to my previous reply.
3) Program is loaded both in MCU & XROM and EAVPP is grounded: In this case, I set the IROM of 8051 to 1 KB and intentionally made the program larger than that to see if the MCU will eventually access the XROM. It appears to have the same behavior as scenario no. 2, PC goes beyond 3FFH but does not read the instruction in XROM.
You may want to try experimenting using both internal and external program memory again but with a code containing an explicit jump to external location. Like your third setup, Vpp/~EA will be strapped to ground. Basically, you will use the same circuit but I strongly suggest that you install 10 kΩ pull-up resistor networks to AD7..AD0 and A7..A0, this is to avoid possible sources of problems since I cannot closely monitor this forum and reply immediately. If you will continue experimenting with a clock source I hope you will follow my suggestion in the first part of this reply.
Here is my simple modification, consisting of only four (blue) lines, to your code:
ORG 0H
LJMP XPMemStart ; jump to external program memory
ORG 1000H
XPMemStart:
CPL P1.0 ; complement the bit value at P1.0
ACALL DELAY ; call delay
SJMP XPMemStart ; do it again
DELAY: MOV R4,#01H
WAIT1: MOV R3,#31H
WAIT2: MOV R2,#255H
WAIT3: DJNZ R2,WAIT3
DJNZ R3,WAIT2
DJNZ R4,WAIT1
RET
END
I simply relocated the instruction blocks that perform the blinking of LED to the start of memory location occupied by the external EPROM. The instruction at the RESET vector is simply a jump to external program memory. I think the assembler you are using will allow you to use just JMP for SJMP and LJMP, nevertheless, I used an explicit LJMP.
You will load the binary image at address 0000H to internal memory. The size, if I am not mistaken, is only 3 bytes. You will then load the binary image starting at 1000H (4096 decimal) to the EPROM. Be careful in interpreting this, the binary image of the code starting at 1000H (4096 decimal) should be loaded to the EPROM memory location 0000H onward. To make it even clearer, the code for CPL P1.0 should be at EPROM memory location 0000H.
Because the EPROM is the only device attached to external memory bus, there is no need to add a decoder even though the EPROM is mapped to 1000H.
The EPROM starting address of 1000H is based on the original 80(C)51/87(C)51/89C51 and similar parts which contains only 4 KB of internal memory. I believe, based on you previous reply, that the simulation tools will allow you to modify that.
11-06-2021 08:58 AM
In my previous reply, I mentioned that the binary image of the code starting at 1000H (4096 decimal) should be loaded to the EPROM memory location 0000H onward and that there is no need for additional decoder in the circuit. That is correct but I forgot that there is a need for rewiring. Instead of just appending the modification, I decided to describe the three options available when loading the binary image into the EPROM and the pros and cons of each option.