Q) I'm trying to read the timing diagrams and can't figure out a few of the acronyms. A search didn't provide any answers. What are PCH, PCL, and DPH?

A) PCH and PCL are the program counter higher and lower bytes respectively. PC is a 16-bit register used to tell the 8051 where to fetch the next instruction. PCL is output from port0 on the first cycle of the program fetch while PCH is output on port2 throughout the fetch.

DPH (and DPL) are the higher and lower bytes of the data pointer (DPTR is the same register when you speak of it in 16-bit terms). For example, the two instructions:

MOV DPH, #10h


are equivalent to the one instruction

MOV DPTR, #102Ah

Referring to DPL and DPH is useful if you want to save their values to the other 8-bit registers of the 8051, for instance.

A document which defines the acronyms used in the timing diagrams will be available on the course web site.



Q) The Emily52 test files have the instruction ORG. The instruction sheet for the 8051 does not list this instruction. What is it?

A) ORG is one of a few assembler directives. They tell the assembler where to start a portion of your program. Another type of directive would be labels. The microcontroller does not understand what the label "myFunction" is, but the assembler does and assigns it a particular address. That address is then passed on to the microcontroller.

An example:

       ORG $0000
       SJMP myFunction

       ORG $2000
       MOV A, #44h

The microcontroller never sees the label nor the ORG statements, but your code will be loaded at the right places (myFunction replaced with the address 2000 hex). Other such directives understood by the ASM51 assembler include DB and STRZ.

Look them up in the ASM51 manual to see what they are used for.



Q) To recap, the 8051 sends out the memory address through port0 to the EPROM (does not go through the 373 since the 8051 is wired to the Q outputs?). ALE then goes active and the EPROM grabs the address. ALE goes inactive, the 8051 releases the bus (via PSEN?) to the EPROM and the EPROM writes the data through the 373 (is connected to the D inputs) to the 8051.

A) Yes and no: the 8051 does send out PCL via port0 which is latched by the 373 by ALE. This ensures that during the second cycle of the fetch, the address seen by the EPROM is constant and valid. On the second cycle, the 8051 makes port0 an input port so that the data values from the EPROM can be read. (port2 does not need to be latched because it stays the same throughout that particular fetch). NOTE that the data from EPROM does not return through the 373 but is enters directly through port0.



Q) I've written the code for Lab #2, but I'm having problems with simulation. Basically, Timer1 isn't running.

A) What you're missing is something that's explained in section 3.4 of the Emily52 documentation. Emily52 does not by default handle SFRs like the timers - you need additional SFR emulation code (which we don't have) if you want to see the SFRs actually operate. For this class, use Emily52 to test basic code flow and as much non-SFR operation as possible; then, test out your code on the real hardware.



Q) How can I test my interrupt service routines with Emily52?

A) Note that Emily52 include a 'V' command which allows you to vector to the ISR for any of the interrupt sources. Since we don't have SFR emulation code (see the question above), we can't make Emily52 automatically vector to the ISR, but we can do it by hand.