Lab 1: Implementing a Simple Counter Using the 8051
October 11, 2001

Name: Joe Schmoe
Login: schmoe

Contribution

My contribution to the lab: 50%
Description: I worked on wiring the circuit on the breadboard, while my partner started working on the code. Once I was finished, I helped my partner to complete the code.

My partner's contribution to the lab: 50%
Description: My partner worked on the C code for the counter and looked over my circuit wiring to ensure I had wired it correctly.

Summary

In this lab, we leared how to write a simple C program for the 80X51 micro-controller, compile it using C51 compiler, and emulate it on an emulator using PDS51. The program we wrote was used to control a simple 4-bit up-down counter, capable of counting from 0 to 15, which was displayed in decimal format on the LCD. The counter works as follows:

  1. Reset: when high, resets the counter dataout to "0000"
  2. Updown: decides whether the counter counts up or down
  3. Load: makes the counter count from the 4-bit input Datain
  4. Datain: which is a 4-bit input count

Steps and Implementation

  1. Wire up the circuit using the schematic provided.
  2. Download io.c, io.h, and count.c files.
  3. Modify the count.c file to complete the functionality of the 4-bit counter as well as implement the PrintInt() function to display the counter value on the LCD.

    To implement the PrintInt() function we need to convert the 4-bit counter value to a decimal string that can then be displayed on the LCD. The following are the operations that we performed for the conversion:

    ch[0] = ...
    ch[1] = ...

  4. Compile and link the C files using the following commands:

    c51 count.c
    c51 io.c
    bl51 count.obj, io.obj to count.omf

  5. Use the PDS51 emulator to test the functionality of the counter.

Results

We successfully completed the lab such that our circuit functioned as it was supposed to. However, in the process of completing the lab, we ran into a problem when we forgot to connect the GND of the emulator's header. We also had some initial trouble in figuring out the code for PrintInt(). Once we fixed the software and hardware bugs our circuit worked correctly.

Code/Schematics

attach your code/schematics