Home | UMT-1 Page


Textbook: MICROCONTROLLER LAB
Programming the 68HC08, 8051, and eZ8 in Assembly Language
Second Edition

Front Cover
ISBN 0-9772246-1-9 (216 pages)

Corrections/Additions to the Second Edition:

page 16, 1.0 Background: On December 7, 2015, NXP and Freescale announced completion of their merger. The company name is now NXP.

page 52, 2.10 Assignment 2a: Do not "incorporate tone beeps..." as this masks the necessity of switch debouncing.

page 54, 2.13 Assignment 2b: Incorporate tone beeps in some fashion (here instead of in 2a).

page 114, 5.7 Assignment 5a: use only sampleZ8.asm (not ioZ8.asm).

page 114, just above 5.8 Assignment 5b: change "input on J17 pin 9" to "input on J15 pin 9".

page 158, flowchart: insert a "Decrement Div10" box above the "Div10 = 0?" decision diamond.

page 203, add this: Make sure the programming settings are: device type "QT", "5 volts, user switched," and "clock driven by P&E interface on pin 13". It can be more finicky than the JK3. Make sure the powerdown is done for at least five seconds. When the chip is blank (erased) it uses a different programming algorithm which is less stringent, so programming may go easier once with a fresh part.


Corrections/Additions to the First Edition:

page 15, under Small Parts: replace "mini-DIN to mini-DIN cable" with "6-pin mini-DIN plug (Digikey CP-2060, Mouser 171-2606); a keyboard extender cable (Digikey AE9875, Mouser 545-P222-010) also helpful"

page 49, bottom. Add the following in a box: "If the simulator or flash programmer software does not recognize the USB Multilink adapter, unplug and replug the USB cable to the pod. Close the program and try again. Make sure the Hardware Type is set to Class 7; the Device Type is set for JK; the Device Power is set to 5 Volts, User Switched; the Device Clock is set to Target self-clocked; the Clock Divider is set to 4; and Target MCU Security bytes is set to Blank Device (second button). Make sure the IRQ jumper is installed, and nothing is connected to the 68HC908JK3's IRQ pin (1). If you get a security failure, it is usually because you haven't waited five seconds after powering down before clicking OK. If you can't get past a security failure, click IGNORE Security Failure and you will then enter Monitor Mode -- but not unsecured. From this point, just erase the device and immediately exit the program. Reenter the program and now you should be able to unsecure it properly."

page 53, top: Before "Demonstrate" add: "The only ioJK3.asm subroutines you can use are input, leds, and digit (not new_key)." After "to eliminate it." add: "The trainer's keypad may not generate detectable bounce; if not, temporarily use one of the DIP switches as your shift button and see if bouncing occurs. If it still doesn't, use a wire to +5v on the appropriate J2 post for the shift operation. After observing switch bounce, fix it in your code. Document.

page 69, bottom: change "with in invalid input" to "with an invalid input"; delete "You can replace lines 20-28 with AIX #1 (that makes it simple!)" and "AIX does it all" at the right. (AIX adds a constant, we need to add a variable here.)

page 70, to the right of Fast: add a period after "holds the answer"

page 80, add the following to the end of section 4.5: "The only instructions which modify flags are ADD, ADDC, SUBB, MUL, DIV, DA, RRC, RLC, SETB C, CLR C, CPL C, ANL C, ORL C, MOV C, and CJNE. See those instruction descriptions and SFR Definition 9.4."

page 107, add the following to the end of the paragraph above section 5.2: "(You cannot use the LDE or LDEI instructions.)"

page 114, first full paragraph, add the following after "18.432 (MHz)": In the Project Settings window, with Category set to Input, select Startup Module Included in Project; select Linker Command File Create New; and make sure that Use C Runtime Library is unchecked. If you save the project on your flash drive, you can reuse it by removing previous .asm files and adding new ones for each assignment.

page 114, just above 5.8 Assignment 5b: change "input on J17 pin 9" to "input on J15 pin 9".

page 132, DJNZ: delete src (the Working Register is both source and destination, and is listed only as dst in the instruction full description)

page 150, step 1: change "near the similar" to "after the similar".

page 151, center: insert "(in address order)" after "ORG to the vector address".

page 166, second paragraph: change "without interrupts" to "without receiver and transmitter interrupts".

page 170, second paragraph, change "no handshaking" to "no flow control or handshaking".

page 170, above Optional Features: after "...the report." add "You can test full-duplex operation by looping the microcontroller's TxD and RxD pins; it should receive its own transmission."

page 186: delete "Optional"; change "Even Better" to "Optional".

page 191, last paragraph: change "9° F" to "8° F."

page 191, add new paragraph to end: "To prevent fluctuating 7-segment displays making the LSD unreadable, update the displayed value at a slow rate -- say, once per second. You still might see variation: this can be minimized by averaging samples over a period of time, as described in section 10.2. For this situation, you might sum 16 to 64 samples, which won't overrun 16-bits with a 10-bit ADC. Round by adding half the number of samples (8 for 16 samples) to the sum prior to shifting the result right to accomplish the division."

page 192, third paragraph from the bottom: change "are 00000 for pin ANA0 and 00001 for ANA1..." to "are 0000 for pin ANA0 and 0001 for ANA1..."

page 193, second full paragraph, change "manner is described" to "manner as described."

page 193, add the following to the beginning of the "Acquire 8-bit samples..." sentence in the first paragraph under The Z8F0421 Task: "Delay a second to let the 8051 release the pin you're using for analog input, and then".

page 193, add the following to the end of the first paragraph under The Z8F0421 Task: "-- or more simply, use Extended Addressing with an Indirect Register Pair to point to the storage location."

page 193, add the following after the first sentence under The C8051F330D Task: "Program the pin which the eZ8 is using for analog input (Scan_Source or Scan_Sink) as an input so that it doesn't load the signal down."

page 194, after the first sentence add: "It is preferable to remove U1 or U4 (if you're using Scan_Source or Scan_Sink for analog input, respectively) so that you don't drive the latch's LE input with a non-digital signal -- which can cause excessive power consumption.

page 194, add a new paragraph after the second paragraph: "Describe the inter-processor communications signaling and provide a timing diagram".

page 196, append new paragraph: "There is also a protocol through which the connected computer informs the keyboard that it wishes to transmit data to the keyboard. The keyboard detects the request and provides clock pulses -- but in this case, the computer outputs to the Data line in synchronism with the clock line. There are separate codes used in this direction (not shown in section 11.3); they control the keyboard's LED's and modes of operation. When receiving communication, the keyboard samples the Data line on its rising clock edge. We won't experiment with keyboard reception here."

page 197, add "Listen to the Keyboard" between the first and second paragraphs.

page 197, second paragraph: change "PTB3 (Audio)" to "PTB0" and delete "You will have to ... been using." and replace it with "Unplug the pod from J18 when running, because it is wired to PTB0."

page 197, append to the Optional section: Convert the scancodes into displayable form and scroll the text (illuminate a decimal point or LED while a key is pressed instead of showing the release codes).

page 197, append new paragraphs: "Send to the Computer. Now reverse roles and be the keyboard (before, the microcontroller was emulating the Computer). Connect to a computer's PS/2 port using a 6-pin mini-DIN plug. Wire only three connections: Ground (pin 3), Clock (pin 5), and Data (pin 1). For this mode of operation, you can continue to use PTB0 for the Data line, but use PTB3 (Audio) for the Clock line. The proper method has the output ports behaving as open collector devices: when the output is low, all is normal (actively sinking current); however, when the output is ostensibly high, instead place the port pin into input mode (which makes it high impedance and neither sourcing nor sinking current). It most likely will work even if you keep the port bits in output mode instead of operating in open collector mode.

Your program should send the keypad (0-9, A-F) codes for make and release to the computer upon depressing and releasing the trainer buttons. Unplug the keyboard from the computer and replace with the trainer connections while a suitable application (like Notepad) is activated to test. You can also use another trainer with the code from the first part of the assignment running to check this half. If the computer uses a USB keyboard, test it first with a PS/2 keyboard; you might have to reboot it with the latter attached and the former disconnected.

I suggest bundling both the receive and transmit pieces into one program; upon reset, check the dipswitches to determine which code to execute."

page 197, above the Optional section: move "Demonstrate" to the new end.


revised 12/18/2012