0
\$\begingroup\$

I have been studying the 8032 microcontroller. It is mentioned that 8032 doesn't have internal ROM. Now there are few questions I have

  • Do we need an external ROM to execute programs necessarily? Can't we use the 256 byte internal RAM?

  • Suppose I am using the 8032 microcontroller with an external ROM2732 and also using a latch for storing the address (lower order) of port P0.(which may transfer address/data). Now after enabling EA and connecting the PSEN how does 8032 execute the program? What happens if I turn on the system ?(How does the program counter of 8032 microcontroller executes intructions? From which address of external memory the program should be read ?

I have read these manuals- Intel 8032H Keil , Atmel 80C32E.

\$\endgroup\$
2
\$\begingroup\$

If you look at a typical 80(C)32 circuit below (from here):

enter image description here

You can see that the 8032 talks to external EPROM, RAM and EEPROM via a bus - 8 bit data and 16 bit address. The latter is latched and thus demultiplexed with the HCT573. There were some chips with the latch built in designed to be used with the 8031/8032 but the above was the more common configuration- using low-cost standard memory chips. There's also a bit of "glue" logic to decode the addresses and to generate the proper signals for the memories (the HCT138 and the quad NAND).

It is vital that the glue logic is designed such that the EPROM resides at address 0 because after a reset, execution always begins by the 8032 fetching the first byte of the instruction from that address. This is a function of hardware in the 8032 and cannot be changed. Typically the instruction is a 3-byte LJMP instruction that jumps to the beginning of the program. We call that the "RESET VECTOR". Other vectors occupy the bytes immediately above the reset vector- for the external interrupt service routine and timer interrupt service routine.

In those days, the EPROM would be programmed (written to) by a separate programmer outside of the circuit and then typically plugged into a socket. No in-circuit programming in those days. The RAM and EEPROM could be written by the micro, but the program would have to be loaded into the EPROM before any of that was possible.

\$\endgroup\$
3
  • \$\begingroup\$ .:I will +1 it. Can you please elaborate the glue logic part. It seems that LJMP will move to beginning of the program? But here program is in external memory. Here is this kind of instruction used? I mean simple the instructions are fetched from external memory and placed in the IR,decoded and executed? Where is the case of LJMP here? \$\endgroup\$ – user2736738 Apr 8 '15 at 17:45
  • 1
    \$\begingroup\$ The glue logic just ensure that it's the EPROM that's selected when the address is 0000. In the above configuration, whenever A15 = 0 the EPROM is selected. LJMP is a 3-byte instruction that takes an address anywhere in the 16 bit memory space of the 8031, but typically you might just jump over the other vectors, so the following two bytes after the LJMP would contain an address near the start of the EPROM. You don't typically muck around with addresses directly- you use an assembler that keeps track of them via symbolic labels. \$\endgroup\$ – Spehro Pefhany Apr 8 '15 at 18:01
  • 1
    \$\begingroup\$ "Glue logic" is a slang term used to refer to the smaller logic functions that are required between the processor and memories. \$\endgroup\$ – Peter Bennett Apr 8 '15 at 18:18
2
\$\begingroup\$

No, you can't use the internal RAM to hold code. The 8051/8032 uses a Harvard architecture, which means that it has completely separate memory spaces for code and data. Instructions are fetched from code space, but the RAM resides in data space.

Now after enabling EA and connecting the PSEN how does 8032 execute the program?

The 8032 fetches instructions from code space. Since EA is asserted, these fetches (memory reads) appear on the external memory bus, with PSEN asserted. When PSEN is NOT asserted on an external memory read operation, it is a data-space read.

What happens if I turn on the system?

The 8032 begins fetching instructions from code space address 0.

How does the program counter of 8032 microcontroller executes intructions?

The program counter is simply responsible for holding the address of the next instruction to be executed. Other parts of the CPU execute the instructions.

From which address of external memory the program should be read?

Address 0.

If you want to use interrupts in your program, there are other addresses in low code-space memory that are reserved for them, so the code that you execute on reset will eventually have to "jump around" those reserved addresses.

\$\endgroup\$
2
  • \$\begingroup\$ This is the answer to first question. I will +1 it. Could you please elaborate on the second part of the question? That part I can't get any clue. \$\endgroup\$ – user2736738 Apr 8 '15 at 17:13
  • \$\begingroup\$ See edit above. \$\endgroup\$ – Dave Tweed Apr 8 '15 at 17:32
2
\$\begingroup\$

The 8032, which is a variant of the 8052, has no internal ROM for program storage. Instead, an external ROM/EPROM/EEPROM must be used to hold the program.

Two ports are used to access external memory: Port 0 (lines P0.0-P0.7) emit the the low 8 bits of a 16-bit 64K address, and also serve as the read/write 8-bit data bus after the address has been latched by the external memory.

P2 (lines P2.0-P2.7) are used to emit the high 8-bits of the 16-bit 64K address.

Although the 8032 has 256 bytes of internal RAM, this can be extended by adding a RAM chip onto the external address bus also.

The external address line \$\mathsf{\small \overline{\text{EA}}}\$ is held low to indicate whether that an access is being made to external program memory, otherwise external RAM is assumed.

To execute code out of external memory, the address from the program counter is output on the Port 0 and Port 2 data lines; then during the read cycle, the byte(s) retrieved from the ROM on read into Port 0 and executed by the processor.

Only one instruction is fetched at a time.

\$\mathsf{\small \overline{\text{PSEN}}}\$ is a strobe used during the external program memory access.

\$\endgroup\$
5
  • \$\begingroup\$ .:But how does it execute program that reside in external memory? Look I am not getting how the PC will cop up when the program is in external memory. I mean at each m/c cycle it fetches some number of byte. Then after fetching it is the program is executed immediately or the whole program is fetched at once> if that is the case where will it be stored? \$\endgroup\$ – user2736738 Apr 8 '15 at 17:23
  • \$\begingroup\$ .: So initially PC=0000h. It starts to fetch bytes at each m/c cycle and then executes it? So in the ROM always we should burn the program from address 0000h otherwise we would be unable to correctly execute it. \$\endgroup\$ – user2736738 Apr 8 '15 at 17:31
  • \$\begingroup\$ @learner. Correct. Usually there will be a jump at address to the "real"start of the code. \$\endgroup\$ – tcrosley Apr 8 '15 at 17:32
  • \$\begingroup\$ .: I will +1 your answer. But if program is executed instruction by instruction how will forward reference like this will be managed? L1:JNZ L2 .. L2:..... \$\endgroup\$ – user2736738 Apr 8 '15 at 17:34
  • 1
    \$\begingroup\$ The JNZ instruction (and other Jump and Branch instructions) load the destination address of the Jump into the program counter, so the processor will fetch the next instruction from that address, rather than the instruction immediately after the Jump. \$\endgroup\$ – Peter Bennett Apr 8 '15 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.