Silicon ChipProgramming The 68HC705C8 Microcontroller - December 1993 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: The future of private motor vehicles
  4. Feature: Sound Blaster Grows Up by Darren Yates
  5. Feature: Electronic Engine Management; Pt.3 by Julian Edgar
  6. Project: Remote Controller For Garage Doors by Branco Justic
  7. Project: Build A Low-Voltage LED Stroboscope by Darren Yates
  8. Project: A Low-Cost 25W Amplifier Module by Darren Yates
  9. Feature: The LM1875 Audio Amplifier IC by Darren Yates
  10. Feature: Remote Control by Bob Young
  11. Feature: Programming The 68HC705C8 Microcontroller by Barry Rozema
  12. Serviceman's Log: Whingeing Willie & the bouncing TV set by The TV Serviceman
  13. Project: Peripherals For The Southern Cross Computer by Peter Crowcroft & Craig Jones
  14. Book Store
  15. Vintage Radio: My no-hassles radio museum by John Hill
  16. Project: Build A 1-Chip Melody Generator by Bernie Gilchrist
  17. Back Issues
  18. Feature: Amateur Radio by Garry Cratt, VK2YBX
  19. Order Form
  20. Product Showcase
  21. Feature: Index to Volume 6
  22. Market Centre
  23. Advertising Index
  24. Outer Back Cover

This is only a preview of the December 1993 issue of Silicon Chip.

You can view 29 of the 96 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Articles in this series:
  • Electronic Engine Management; Pt.1 (October 1993)
  • Electronic Engine Management; Pt.1 (October 1993)
  • Electronic Engine Management; Pt.2 (November 1993)
  • Electronic Engine Management; Pt.2 (November 1993)
  • Electronic Engine Management; Pt.3 (December 1993)
  • Electronic Engine Management; Pt.3 (December 1993)
  • Electronic Engine Management; Pt.4 (January 1994)
  • Electronic Engine Management; Pt.4 (January 1994)
  • Electronic Engine Management; Pt.5 (February 1994)
  • Electronic Engine Management; Pt.5 (February 1994)
  • Electronic Engine Management; Pt.6 (March 1994)
  • Electronic Engine Management; Pt.6 (March 1994)
  • Electronic Engine Management; Pt.7 (April 1994)
  • Electronic Engine Management; Pt.7 (April 1994)
  • Electronic Engine Management; Pt.8 (May 1994)
  • Electronic Engine Management; Pt.8 (May 1994)
  • Electronic Engine Management; Pt.9 (June 1994)
  • Electronic Engine Management; Pt.9 (June 1994)
  • Electronic Engine Management; Pt.10 (July 1994)
  • Electronic Engine Management; Pt.10 (July 1994)
  • Electronic Engine Management; Pt.11 (August 1994)
  • Electronic Engine Management; Pt.11 (August 1994)
  • Electronic Engine Management; Pt.12 (September 1994)
  • Electronic Engine Management; Pt.12 (September 1994)
  • Electronic Engine Management; Pt.13 (October 1994)
  • Electronic Engine Management; Pt.13 (October 1994)
Items relevant to "Build A Low-Voltage LED Stroboscope":
  • Low-Voltage LED Stroboscope PCB patterns (PDF download) [04112931-3] (Free)
Items relevant to "A Low-Cost 25W Amplifier Module":
  • Low-Cost 25A Audio Amplifier Module PCB pattern (PDF download) [01112931] (Free)
Articles in this series:
  • Remote Control (October 1989)
  • Remote Control (October 1989)
  • Remote Control (November 1989)
  • Remote Control (November 1989)
  • Remote Control (December 1989)
  • Remote Control (December 1989)
  • Remote Control (January 1990)
  • Remote Control (January 1990)
  • Remote Control (February 1990)
  • Remote Control (February 1990)
  • Remote Control (March 1990)
  • Remote Control (March 1990)
  • Remote Control (April 1990)
  • Remote Control (April 1990)
  • Remote Control (May 1990)
  • Remote Control (May 1990)
  • Remote Control (June 1990)
  • Remote Control (June 1990)
  • Remote Control (August 1990)
  • Remote Control (August 1990)
  • Remote Control (September 1990)
  • Remote Control (September 1990)
  • Remote Control (October 1990)
  • Remote Control (October 1990)
  • Remote Control (November 1990)
  • Remote Control (November 1990)
  • Remote Control (December 1990)
  • Remote Control (December 1990)
  • Remote Control (April 1991)
  • Remote Control (April 1991)
  • Remote Control (July 1991)
  • Remote Control (July 1991)
  • Remote Control (August 1991)
  • Remote Control (August 1991)
  • Remote Control (October 1991)
  • Remote Control (October 1991)
  • Remote Control (April 1992)
  • Remote Control (April 1992)
  • Remote Control (April 1993)
  • Remote Control (April 1993)
  • Remote Control (November 1993)
  • Remote Control (November 1993)
  • Remote Control (December 1993)
  • Remote Control (December 1993)
  • Remote Control (January 1994)
  • Remote Control (January 1994)
  • Remote Control (June 1994)
  • Remote Control (June 1994)
  • Remote Control (January 1995)
  • Remote Control (January 1995)
  • Remote Control (April 1995)
  • Remote Control (April 1995)
  • Remote Control (May 1995)
  • Remote Control (May 1995)
  • Remote Control (July 1995)
  • Remote Control (July 1995)
  • Remote Control (November 1995)
  • Remote Control (November 1995)
  • Remote Control (December 1995)
  • Remote Control (December 1995)
Articles in this series:
  • Programming The Motorola 68HC705C8 (July 1993)
  • Programming The Motorola 68HC705C8 (July 1993)
  • Programming the Motorola 68HC705C8 (October 1993)
  • Programming the Motorola 68HC705C8 (October 1993)
  • Programming The 68HC705C8 Microcontroller (December 1993)
  • Programming The 68HC705C8 Microcontroller (December 1993)
Articles in this series:
  • Amateur Radio (November 1987)
  • Amateur Radio (November 1987)
  • Amateur Radio (December 1987)
  • Amateur Radio (December 1987)
  • Amateur Radio (February 1988)
  • Amateur Radio (February 1988)
  • Amateur Radio (March 1988)
  • Amateur Radio (March 1988)
  • Amateur Radio (April 1988)
  • Amateur Radio (April 1988)
  • Amateur Radio (May 1988)
  • Amateur Radio (May 1988)
  • Amateur Radio (June 1988)
  • Amateur Radio (June 1988)
  • Amateur Radio (July 1988)
  • Amateur Radio (July 1988)
  • Amateur Radio (August 1988)
  • Amateur Radio (August 1988)
  • Amateur Radio (September 1988)
  • Amateur Radio (September 1988)
  • Amateur Radio (October 1988)
  • Amateur Radio (October 1988)
  • Amateur Radio (November 1988)
  • Amateur Radio (November 1988)
  • Amateur Radio (December 1988)
  • Amateur Radio (December 1988)
  • Amateur Radio (January 1989)
  • Amateur Radio (January 1989)
  • Amateur Radio (April 1989)
  • Amateur Radio (April 1989)
  • Amateur Radio (May 1989)
  • Amateur Radio (May 1989)
  • Amateur Radio (June 1989)
  • Amateur Radio (June 1989)
  • Amateur Radio (July 1989)
  • Amateur Radio (July 1989)
  • Amateur Radio (August 1989)
  • Amateur Radio (August 1989)
  • Amateur Radio (September 1989)
  • Amateur Radio (September 1989)
  • Amateur Radio (October 1989)
  • Amateur Radio (October 1989)
  • Amateur Radio (November 1989)
  • Amateur Radio (November 1989)
  • Amateur Radio (December 1989)
  • Amateur Radio (December 1989)
  • Amateur Radio (February 1990)
  • Amateur Radio (February 1990)
  • Amateur Radio (March 1990)
  • Amateur Radio (March 1990)
  • Amateur Radio (April 1990)
  • Amateur Radio (April 1990)
  • Amateur Radio (May 1990)
  • Amateur Radio (May 1990)
  • Amateur Radio (June 1990)
  • Amateur Radio (June 1990)
  • Amateur Radio (July 1990)
  • Amateur Radio (July 1990)
  • The "Tube" vs. The Microchip (August 1990)
  • The "Tube" vs. The Microchip (August 1990)
  • Amateur Radio (September 1990)
  • Amateur Radio (September 1990)
  • Amateur Radio (October 1990)
  • Amateur Radio (October 1990)
  • Amateur Radio (November 1990)
  • Amateur Radio (November 1990)
  • Amateur Radio (December 1990)
  • Amateur Radio (December 1990)
  • Amateur Radio (January 1991)
  • Amateur Radio (January 1991)
  • Amateur Radio (February 1991)
  • Amateur Radio (February 1991)
  • Amateur Radio (March 1991)
  • Amateur Radio (March 1991)
  • Amateur Radio (April 1991)
  • Amateur Radio (April 1991)
  • Amateur Radio (May 1991)
  • Amateur Radio (May 1991)
  • Amateur Radio (June 1991)
  • Amateur Radio (June 1991)
  • Amateur Radio (July 1991)
  • Amateur Radio (July 1991)
  • Amateur Radio (August 1991)
  • Amateur Radio (August 1991)
  • Amateur Radio (September 1991)
  • Amateur Radio (September 1991)
  • Amateur Radio (October 1991)
  • Amateur Radio (October 1991)
  • Amateur Radio (November 1991)
  • Amateur Radio (November 1991)
  • Amateur Radio (January 1992)
  • Amateur Radio (January 1992)
  • Amateur Radio (February 1992)
  • Amateur Radio (February 1992)
  • Amateur Radio (March 1992)
  • Amateur Radio (March 1992)
  • Amateur Radio (July 1992)
  • Amateur Radio (July 1992)
  • Amateur Radio (August 1992)
  • Amateur Radio (August 1992)
  • Amateur Radio (September 1992)
  • Amateur Radio (September 1992)
  • Amateur Radio (October 1992)
  • Amateur Radio (October 1992)
  • Amateur Radio (November 1992)
  • Amateur Radio (November 1992)
  • Amateur Radio (January 1993)
  • Amateur Radio (January 1993)
  • Amateur Radio (March 1993)
  • Amateur Radio (March 1993)
  • Amateur Radio (May 1993)
  • Amateur Radio (May 1993)
  • Amateur Radio (June 1993)
  • Amateur Radio (June 1993)
  • Amateur Radio (July 1993)
  • Amateur Radio (July 1993)
  • Amateur Radio (August 1993)
  • Amateur Radio (August 1993)
  • Amateur Radio (September 1993)
  • Amateur Radio (September 1993)
  • Amateur Radio (October 1993)
  • Amateur Radio (October 1993)
  • Amateur Radio (December 1993)
  • Amateur Radio (December 1993)
  • Amateur Radio (February 1994)
  • Amateur Radio (February 1994)
  • Amateur Radio (March 1994)
  • Amateur Radio (March 1994)
  • Amateur Radio (May 1994)
  • Amateur Radio (May 1994)
  • Amateur Radio (June 1994)
  • Amateur Radio (June 1994)
  • Amateur Radio (September 1994)
  • Amateur Radio (September 1994)
  • Amateur Radio (December 1994)
  • Amateur Radio (December 1994)
  • Amateur Radio (January 1995)
  • Amateur Radio (January 1995)
  • CB Radio Can Now Transmit Data (March 2001)
  • CB Radio Can Now Transmit Data (March 2001)
  • What's On Offer In "Walkie Talkies" (March 2001)
  • What's On Offer In "Walkie Talkies" (March 2001)
  • Stressless Wireless (October 2004)
  • Stressless Wireless (October 2004)
  • WiNRADiO: Marrying A Radio Receiver To A PC (January 2007)
  • WiNRADiO: Marrying A Radio Receiver To A PC (January 2007)
  • “Degen” Synthesised HF Communications Receiver (January 2007)
  • “Degen” Synthesised HF Communications Receiver (January 2007)
  • PICAXE-08M 433MHz Data Transceiver (October 2008)
  • PICAXE-08M 433MHz Data Transceiver (October 2008)
  • Half-Duplex With HopeRF’s HM-TR UHF Transceivers (April 2009)
  • Half-Duplex With HopeRF’s HM-TR UHF Transceivers (April 2009)
  • Dorji 433MHz Wireless Data Modules (January 2012)
  • Dorji 433MHz Wireless Data Modules (January 2012)
Lesson 3 Programming the Motorola 68HC705C8 microcontroller In Lesson 2, we covered the following topics: (1) Mne­monics; (2) Addressing Modes; and (3) the 6805 Instruction Set. This month, we look further at addressing modes. By BARRY ROZEMA Table 1 Opcode Mnemonic A. Mode No. Bytes No. Cycles A6 LDA IMM 2 2 C6 LDA EXT 3 4 86 SWI INH 1 10 C7 STA EXT 3 5 CC JMP EXT 3 3 43 COMA INH 1 3 A3 CPX IMN 2 2 42 MUL INH 1 11 Before moving into new territory, let’s first take a look at the answers to the exercises in Lesson 2. Exercise 1: fill in the blank spaces in Table 2 (Lesson 2). A look at the instruction set in Lesson 2 and/or the op code map on page 30 of the Motorola MC68HC705C8 technical summary (BR594/D) should have given you the information to get the re­sults shown in Table 1. You should also have modified your programs in last months lesson to get the following results. Each exercise is a modifica­tion of the previous program. You add the same instructions on to the program with a change to the data. The flow charts have the new or modified processes shown with an asterisk (*). Exercise 2: rewrite the flow chart and the program to make the LEDs give a smooth inward pattern; ie, to make the LEDs close in one bit at a time instead of two. To do this, you will need to examine the bit pattern to get the hex values. Table 2 shows the bit map. Notice that the bits come “on” one bit at a time in an inward direction. The asterisks show the data that’s added to give a smoother display pattern. Table 3 shows the modified program. To do this, you need to change the immediate byte that sets the time delay. Remember, the time delay uses a subroutine that is in the MAL-4 monitor ROM. There are seven time delay subrou­tines and each one is set by loading the accumulator before jumping to the subroutine. You may have found that experimenting with various delay values by changing the immediate byte in the LDA #$?? instruction quickly became rather tedious. A better way is to make the delay time adjustable while the program is running. To do this, you load the accumulator with the value of the input port instead of a fixed value; ie, you use extended addressing instead of imme­diate. The PORT A input port address is $0000. The instruction looks like this: LDA $$0000. The modified process is shown with an asterisk in the flow chart of Fig.2 and Table 4 shows the modified program. Note: remember to enable PORT A by turning switch 7 of DIP SW2 (Bit 6) on. Kitt scanner Exercise 4: rewrite the flow chart and the program to make an 8-bit “Kitt” scanner; ie, one LED on at a time switching from left to right and back again. Better visual effect This program will need to produce a display with a pattern like the one in Exercise 3: experiment with the time the bit map of Table 5. If you make the delay to give a better visual effect. time delay adjustable as in exercise 3, Table 2 the program will repeat the following instructions. B7 B6 B5 B4 B3 B2 B1 B0 HEX A6 xx LDA #$xx 0 0 0 0 0 0 0 0 $00 C7 00 01 STA $$0001 1 0 0 0 0 0 0 1 $81 * C6 00 00 LDA $$0000 CD 14 D9 JSR $$14D9 1 1 0 0 0 0 1 1 $C3 The xx will contain the pattern data. 1 1 1 0 0 1 1 1 $E7 * There are 14 patterns to be displayed 1 1 1 1 1 1 1 1 $FF before the program starts again. The December 1993  53 Table 3 ADDRESS CODE LABEL MNEMONIC OPERAND COMMENT 0030 A600 START LDA #$00 0032 C70001 STA $$0001 Clear accumulator & store at output 0035 A632 LDA #$32 0037 CD14D9 JSR $$14D9 003A A681 LDA #$81 003C C70001 STA $$0001 003F A632 LDA #$32 0041 CD14D9 JSR $$14D9 0044 A6C3 LDA #$C3 0046 C70001 STA $$0001 0049 A632 LDA #$32 004B CD14D9 JSR $$14D9 004E A6E7 LDA #$E7 0050 C70001 STA $$0001 0053 A632 LDA #$32 0055 CD14D9 JSR $$14D9 0058 A6FF LDA #$FF 005A C70001 STA $$0001 005D A632 LDA #$32 005F CD14D9 JSR $$14D9 Set time delay 50 ($32) x ACC = 0.5 seconds 0062 CC0030 JMP $$0030 Jump to start ADDRESS CODE LABEL MNEMONIC OPERAND COMMENT 0030 A600 START LDA #$00 0032 C70001 STA $$0001 Clear accumulator & store at output 0035 C60000 LDA $$0000 0038 CD14D9 JSR $$14D9 003B A681 LDA #$81 003D C70001 STA $$0001 Set time delay 50 ($32) x ACC = 0.5 seconds Load accumulator & store at output Set time delay 50 ($32) x ACC = 0.5 seconds Load accumulator & store at output Set time delay 50 ($32) x ACC = 0.5 seconds Load accumulator & store at output Set time delay 50 ($32) x ACC = 0.5 seconds Load accumulator & store at output Table 4 Fig.1: the flow chart for Exercise 2. The program first turns on the two outside LEDs at the output port, then turns the remaining LEDs on to give a smooth inward pattern; ie, the LEDs close in one bit at a time. Set time delay input port A times ACC Load accumulator & store at output 0040 C60000 LDA $$0000 0043 CD14D9 JSR $$14D9 0046 A6C3 LDA #$C3 0048 C70001 STA $$0001 004B C60000 LDA $$0000 004E CD14D9 JSR $$14D9 0051 A6E7 LDA #$E7 0053 C70001 STA $$0001 0056 C60000 LDA $$0000 0059 CD14D9 JSR $$14D9 Addressing modes 005C A6FF LDA #$FF In Lesson 2, we covered the following three addressing modes: Inherent, Immediate and Extended. This lesson, we will introduce another 005E C70001 STA $$0001 0061 C60000 LDA $$0000 0064 CD14D9 JSR $$14D9 Set time delay input port A times ACC 0067 CC0030 JMP $$0030 Jump to start program will take 14 x 11 bytes = 154 bytes plus two jumps (one jump to go back to the start and one to jump to the RAM at location $0100). The last jump is needed because the MAL-4 only has 144 bytes of user RAM at page zero ($0030 - $00BF) – see the memory map in the November 1993 issue of SILICON CHIP. 54  Silicon Chip Set time delay input port A times ACC Load accumulator & store at output Set time delay input port A times ACC Load accumulator & store at output Set time delay input port A times ACC Load accumulator & store at output Table 2 B7 B6 B5 B4 B3 B2 B1 B0 HEX 0 0 0 0 0 0 0 1 $01 0 0 0 0 0 0 1 0 $02 0 0 0 0 0 1 0 0 $04 0 0 0 0 1 0 0 0 $08 0 0 0 1 0 0 0 0 $10 0 0 1 0 0 0 0 0 $20 0 1 0 0 0 0 0 0 $40 1 0 0 0 0 0 0 0 $80 0 1 0 0 0 0 0 0 $40 0 0 1 0 0 0 0 0 $20 0 0 0 1 0 0 0 0 $10 0 0 0 0 1 0 0 0 $08 0 0 0 0 0 1 0 0 $04 0 0 0 0 0 0 1 0 $02 addressing mode called “Direct” or “Zero Page”. Direct Addressing Mode Symbol for Direct add­r ess­ ing: $ or Z or none. The CPU requires two bytes of data to process this instruc­tion. The first byte is the op-code, while the second byte is the Low address of the operand in memory. This is like the ex­tended addressing mode except that you can only address zero page. The CPU sets the High address to $00 and so you can only address data from $0000 to $00FF. The CPU requires the operand (byte) which is “directly” at zero page in memory. The memory location for this byte is known at the time the program is writ­ten. The opcode for direct addressing is found in Lesson 2, Table 1, column 5. In these lessons, we will use the “Z” symbol to indicate Direct addressing (Z for Zero page). The mnemonics will have a “Z” tacked on the end of them, eg: ADDZ, ANDZ, ORAZ, EORZ, LDAZ, STAZ and LDXZ. The MAL-4 can make good use of zero page (Direct) address­ing. Most of the user RAM is located at zero page, as are all of the input/output, timer, watchdog and other control registers. Thus, it is possible to write programs that use more direct (zero page) addressing than extended. This saves one byte of program each time you use direct instead of extended addressing. The program in Table 6 is the same as in Table 3 from Lesson 2 except that direct addressing was used instead of ex­tended addressing, were possible. The four asterisks (*) in Table 6 indicate instructions with direct (zero page) addressing. The first three (STAZ $01) are used because the output port (PORT B) is at address $0001 which is in zero page of memory. The last in­ struction (JMPZ $30) is used because our program is written in zero page RAM, from $0030. Running the program Load the program into the MAL-4 and run it from location $0030. The output port LEDs should flash in the pattern described in Lesson 2. If not, go back and check that the program Table 6 ADDRESS CODE LABEL MNEMONIC OPERAND COMMENT 0030 A600 0032 B701 START LDA #$00 * STAZ $01 Clear accumulator & store at output 0034 A632 LDA #$32 0036 CD14D9 JSR $$14D9 0039 A6C3 LDA #$C3 003B B700 STAZ $00 003D A632 LDA #$32 003F CD14D9 JSR $$14D9 0042 A6FF LDA #$FF 0044 B700 STAZ $01 0046 A632 LDA #$32 0048 CD14D9 JSR $$14D9 Set time delay 50 ($32) x ACC = 0.5 seconds 004B BC30 JMPZ $30 Jump to start * * * Set time delay 50 ($32) x ACC = 0.5 seconds Load accumulator & store at output Set time delay 50 ($32) x ACC = 0.5 seconds Load accumulator & store at output Fig.2: this modified flow chart will provide a better visual effect than the flow chart shown in Fig.1. In this case, the time delays have been set by loading the accumulator with the value of the input port instead of a fixed value. has been entered correctly. If there are problems, Mode 2 (the disassemble mode) may help you find your mistake. Things to do In Lesson 4, we will continue with addressing modes and we will explain relative addressing. Make sure that you read up on 8-bit 2’s complement negative numbers. Finally, rewrite all your programs in Exercises 2-4 to use direct addressing were possible. Note SC the saving on memory. December 1993  55