CSE 466 Lab1 - "Rudy"

Goals

  1. Become familiar with the Keil 8051 development tools, particularly use of the simulator and compiler.
  2. Become familiar with the laboratory equipment (oscilloscope, flash programmer).
  3. Write a simple program for the 89C55.

Instructions

  1. Setup the hardware as shown in the diagram above. Be sure to connect GND, VCC, and !EA to the appropriate voltage levels.

  2. Hook up the logic probe to Power and Ground on the protoboard, plug in the power, and test the logic probe by touching it to power and ground.

  3. Build the power-on reset circuit recommended in the AT89 Series Hardware Description. 10uF and 33KOhm are reasonable component values.

  4. Hook up the LED and push buttons as shown in the diagram above. What is the purpose of the resistors on the switches?

  5. Connect the oscillator to XTAL1 as shown above.  Use the scope to look at the signal generated by the oscillator. Does the frequency match whatever is printed on the oscillator case?  Measure and record the ALE frequency.  How does ALE compare to the oscillator frequency? If ALE is not moving, check your reset circuit. Now, use the scope to see if you can determine the oscillator clock frequency by observing the power supply pin on the 8051. Why does this happen?

  6. Open the Keil2 development environment (eval version).  Select "New Project" from the Project menu and give the project a name. It is highly recommended that the project is named lab1.uv2.   Be sure to save the project in a network drive that is accessible to you. When prompted to select the device to use for the project, select 89C55.  Right click on the target folder at the left side of your screen and select "Options for target".  In the box that pops up set Xtal to the frequency of your crystal.  Set the memory model to "Small" and the Code Rom Size to "Compact". Now click the OUTPUT tab and select the "create hex file" check box. "HEX" is the binary format that will be programmed into your microcontroller.

  7. Create a new file and call it "main.c".  Under the Project menu select add file and add the newly created source file to your project.  At the top of your source file add the line "#include <At89x55.h>".  This tells the compiler to include macro definitions appropriate to the 89C55.  Go ahead and open the file At89x55.h to get an idea of the macros that are defined.  All of the macro are defined to be SFR addresses on the chip.  For example, the address for Port 0 is assigned to P0.  If you want to access just the least-significant bit (pin) of Port 0, you can use the macro P0_0.  Use Port 1 for the LED display and Port 3 for the 2 push buttons.

  8. Write a simple program to generate a decimal counter on the display using a simple software delay loop. The display should increment once a second. Use the simulator to figure out the proper delay before testing it in hardware. Its worth spending a little time to learn about the various features of the debugger.

  9. In the debugger, open the disassembly window and look at the assembly code generated by the compiler (view->disassembly).  Hit reset on the simulator and single step through the assembly.  Does the code do anything other than what your C code specified?  If so, what does it do? (It's ok if you don't understand the specific assembly instructions, just try to make some sense of what is happening by stepping through the code and looking at the code.)

  10. Burn it into your processor.  Load the hex file generated by your build onto a floppy disk (it will have the same name as your project name, with a .hex extension).  Take the floppy and your chip to the black programmer.  Place the chip in the holder.  Make sure the device that is selected is the Atmel 89C55.   From the File menu select Name and give the name of your file (i.e. "a:\lab1.hex").  From the File menu select Load to load the file into a buffer.  Hit ESC to go back to a higher menu. From the PROM menu select Program to program the chip with the code in the buffer.

  11. Use the oscilloscope to verify that your delay loop is working as expected (That your counter is incrementing once a second), and to ensure that you are not exceeding the max power dissipation of the LED. How much peak current is passing through the display segment? and what is the peak power that is being dissipated by the led?

  12. Modify your program to use the push button as an up/down controller.  

Turn-In (Neatness Counts)

Last update: 10/1/2001 3:44 PM