SECTION 8.2: DESIGN AND TEST OF DS89C4xO TRAINER
In this section we show connections for 8051-based systems using chips such as the AT89C51 and DS89C4xO. If you decide to wire-wrap one of these, make sure that you read Appendix B on wire wrapping.
AT89C51/52-based trainer connection
In systems based on an AT89C51/52-type microcontroller, you need a ROM burner to burn your program into the microcontroller. For the AT89C51, the ROM burner can erase the flash ROM in addition to burning a program into it. In the case of the 8751, you also need an EPROM erasure tool since it uses UV-EPROM. To burn the 8751, you need to erase its contents first, which takes approximately 20 minutes for U V-EPROM. For the AT89C51, this is not required since it has flash ROM.
Figure 8.5 shows the minimum connection for the 8751 or 89C51-based system. Notice that “EA=VCC” indicates that an 8751 or 89C51 has on-chip ROM
for the program. Also notice the PO connection to pull-up resistors to ensure the availability of PO for I/O operations. If you need to use a momentary switch for RESET, refer to Figure 8-3 (b).
DS89C4xO family
The DS89C4xO chip from Maxim Dallas Semiconductor is an 8051 type microcontroller with on-chip flash ROM. It also has a built-in loader allowing it to download programs into the chip via the serial port, therefore eliminating any need for an external ROM burner. This
important feature
makes the DS89C4xO chip an ideal candidate for 8051-based home development systems.
important feature
makes the DS89C4xO chip an ideal candidate for 8051-based home development systems.
Table 8-4: On-Chip Flash ROM Size for the
DS89C4xO Family from Maxim-Dallas
Semiconductor. See www.maxim-ic.com
DS89C4xO Family from Maxim-Dallas
Semiconductor. See www.maxim-ic.com
DS89C4xO flash ROM size
While all DS89C4xO chips share the same features, they come with different amounts of on-chip ROM. Table 8-4 shows the on-chip ROM size for various DS89C4xO chips. Refer to
Figure 8-5. Minimum Connection for 89C51/52-Based Systems
the web site www.maxim-ic.com for further information. Notice that while the AT89C51 comes with 4K bytes of on-chip ROM, and the AT89C52 comes with 8K bytes, the DS89C4xO has 16K bytes of on-chip ROM. Also notice that the DS89C430 is a replacement for the DS89C420 with the bugs fixed.
Example 8-2
Find the address space for the on-chip ROM of the following chips, (a) AT89C51, (b) AT89C52, and (c) DS89C420 30
Solution:
AT89C51 has 4K bytes of on-chip ROM. That gives us 4 x 1024 = 4,096 bytes.
Converting the 4096 to hex, we get 1000H. Therefore, the address space is 0000 -
OFFFH.
AT89C52 has 8K bytes of on-chip ROM. That gives us 8 x 1024 = 8,192 bytes.
Converting the 8,192 to hex, we get 2000H. Therefore, the address space is 0000 -
1FFFH.
DS89C420/30 has 16K bytes of on-chip ROM. That gives us 16 x 1024 = 16,384
bytes. Converting the 16,384 to hex, we get 4000H. Therefore, the address space is
0000 – 3FFFH.
Key features of the DS89C4xO
The following are some of the key features of the DS89C4xO chip taken from the Maxim-Dallas Semiconductor web site (http://www.maxim-ic.com.) We will look at many of these features and show how to use them in future chapters.
1. 80C52 compatible
8051 pin- and instruction-set compatible
Four bidirectional I/O ports
Three 16-bit timer counters
256 bytes scratchpad RAM
2. On-chip flash memory
(a)16KBforDS89C420/30
32KB for DS89C440
64KB for DS89C450
3. In-system programmable through the serial port
1KB SRAM for MOVX
4. ROMSIZE Feature
Selects internal program memory size from 0 to 64K
Allows access to entire external memory map
Dynamically adjustable by software
5. High-speed architecture
1 clock per machine cycle
DC to 33MHz operation
Single-cycle instruction in 30 ns
Optional variable length MOVX to access fast/slow peripherals
Two full-duplex serial ports
Programmable watchdog timer
13 interrupt sources (six external)
Five levels of interrupt priority
Power-fail reset
Early warning power-fail interrupt
DS89C4xO trainer connection
We selected the DS89C4xO for an 8051 Trainer because it is inexpensive but powerful, and one can easily wire-wrap it to be used at work and home. The connection for the DS89C4xO Trainer is shown in Figure 8-6.
If you decide not to wire-wrap the trainer yourself, you can buy this DS89C4xO-based Trainer from the www.MicroDigitalEd.corn web site.
Using the DS89C4xO for development is more advantageous than using the
8751 or 89C51 system for the following two major reasons.
1. Using the DS89C4xO for an 8051 microcontroller allows us to program the
chip without any need for a ROM burner. Because not everyone has access to
a ROM burner, the DS89C4xO is an ideal home-development system. The
advantage of the DS89C4xO is that it can be programmed via the COM port of
a PC (x86 IBM or compatible PC) while it is in the system. Contrast this with
the 89C51 system in which you must remove the chip, program it, and install
it back in the system every time you want to change the program contents of
the on-chip ROM. This results in a much longer development time for the 89C51 system compared with the DS89C4xO system.
2. The two serial ports on the DS89C4xO allow us to use one for PC interfacing with the chip, and the other for data acquisition.
Figure 8-6. DS89C4xO Trainer (for MAX232 connection, see Section 10.2)
Notice from Figure 8-6 that the reset circuitry and serial port connections are the same as in any 8051 -based system. However, the extra circuitry needed for programming are two transistors, a switch, and 10K and IK-ohm resistors. In fact, you can add these components to your 8751/89C51 system and use it as a DS89C4xO system by simply plugging a DS89C4xO chip in the socket. The switch allows you to select between the program and run options. We can load our program into the DS89C4xO by setting the switch to Vcc, and run the program by setting it to Gnd.
Figure 8-6 shows the connection for the 8051 Trainer from www.MicroDigitalEd.com. The Trainer provided by this web site has both of the serial ports connected and accessible via two DB-9 connectors. It also has 8 LEDs and 8 switches along with the PO – P3 ports, all of which are accessible via terminal blocks. It also comes with an on-board power regulator.
See the following Web site for the DS89C4xO Trainer: www.MicroDigitalEd.com
Communicating with the DS89C4xO trainer
After we build our DS89C4xO-based system, we can communicate with it using the HyperTerminal software. HyperTerminal comes with Microsoft Windows 98. NT. 2000. and XP.
Using HyperTerminal with the DS89C4xO
Assuming that your serial cable has a DB-9 connector on both ends, we take the following steps to establish communication between the DS89C4xO Trainer and HyperTerminal.
Figure 8-7. Screen Capture from HyperTerminal for DS89C4xO Trainer
With the trainer’s power off. connect the COM1 port on the back of your PC
to one end of the serial cable.
The other end of the serial cable is connected to the DB-9 connection on the
DS89C4xO Trainer designated as SERIAL=0. After you connect your
DS89C420 Trainer to your PC. power up the trainer. Set the switch to the pro
gram position.
In Windows Accessories, click on HyperTerminal. (If you get a modem instal
lation option, choose ‘”No”.)
Type a name, and click OK (or HyperTerminal will not let you go on).
For “Connect Using” select COM1 and click OK. Choose COM2 if COM1 is
used by the mouse.
Pick 9600 baud rate, 8-bit data, no parity bit. and 1 stop bit.
Change the “Flow Control” to NONE or Xon Xoff. and click OK. (Definitely
do not choose the hardware option.)
Now you are in Windows HyperTerminal. and when you press the ENTER key
a couple of times, the DS89C4xO will respond with the following message:
DS89C420 LOADER VERSION 1.0 COPYRIGHT (C) 2000 DALLAS
SEMICONDUCTOR>
If you do not see “>” after pressing the ENTER key several times, go through the above steps one more time. Then, if you do not get “>”, you need to check your hardware connections, such as the MAX232/233. See the end of this section for some troubleshooting tips.Loading and running a program with the DS89C4xO Trainer
After we get the “>” from the DS89C4xO, we are ready to load the program into it and run. First, make sure that the file you are loading is in Intel hex format. The Intel hex format is provided by your 8051 assembler/compiler. More about Intel hex format is given in the next section.Erase command for the DS89C4xO
To reload the DS89C4xO chip with another program, we first need to erase its contents. The K (Klean) command will erase the entire contents of the flash ROM of the chip. Remember that you must use the “>K” command to erase the ROM before you can reload any program. You can verify the operation of the “>K” command by using the Dump command to display ROM contents on screen. You should see all FFs in all the locations of ROM after applying the “>K” command.
Go to www.MicroDigitalEd.com to see the above steps presented with screen shots.Loading the program
After making sure that you have the switch on the program position and you have the “>” prompt on your screen, go through the following steps to load a program:
At the “>” prompt, enter L (L is for Load). Example: “>L” and press Enter.
In HyperTerminal, click on the Transfer menu option. Click on Send Text File.
Select your file from your disk. Example: “C:test.hex”
Wait until the loading is complete. The appearance of the “GGGG>” prompt
indicates that the loading is good and finished.
Now use D to dump the contents of the flash ROM of the DS89C4xO onto the
screen. Example: >D 00 4F
The dump will give you the opcodes and operands of all the instructions in your program. You can compare this information with the information provided by the list file. In the next section, we will examine the Intel hex file and compare it with the list file of the test program.
Running the program
Change the switch to the run position, press the reset button on the DS89C4xO system, and the program will execute. Use a logic probe (or scope) to see the PO, PI, and P2 bits toggle “on” and “off continuously with some delay in between the “ON” and “OFF” states.Test program for the DS89C4xO in Assembly and C
To test your DS89C4xO hardware connection, we can run a simple test i which all the bits of PO, PI, and P2 toggle continuously with some delay ir between the “on” and “off states. The programs for testing the trainer in bot Assembly and C are provided below. Notice that the time delay is for a DS89C4x based on the 11.0592 MHz crystal frequency. This time delay must be modifie for the AT89C51/52 chips since DS89C4xO uses a machine cycle of 1 clock per: od instead of the 12 clock periods used by the AT89C51/52 chip.
DS89C4xO commands
There are many commands embedded into the DS89C4xO loader. The most widely used among them are L, K, and D. Here is the summary of their operations.
L Load standard ASCII Intel hex formatted data into flash memory.
K Erases the entire contents of flash memory.
D <begin> <end> Dumps the Intel hex file.
We have shown the use of the L (load), K (klean), and D (dump) commands earlier. A complete list of commands and error messages can be obtained from www.MicroDigitalEd.com.Some troubleshooting tips
Running the test program on your DS89CxO-based trainer (or 8051 system) should toggle all the I/O bits with some delay. If your system does not work, follow these steps to find the problem.
With the power off, check your connection for all pins, especially Vcc and GND.
Check RST (pin #9) using an oscilloscope. When the system is powered up,
pin #9 is low. Upon pressing the momentary switch it goes high. Make sure the
momentary switch is connected properly.
Observe the XTAL2 pin on the oscilloscope while the power is on. You should
see a crude square wave. This indicates that the crystal oscillator is good.
If all the above steps pass inspection, check the contents of the on-chip ROM
starting at memory location 0000. It must be the same as the opcodes provid
ed by the list file of Figure 8-8. Your assembler produces the list file, which
lists the opcodes and operands on the left side of the assembly instructions.
This must match exactly the contents of your on-chip ROM if the proper steps
were taken in burning and loading the program into the on-chip ROM.