Menu

8051 Micro-Controller Resources

Links
8052.com Link to a wealth of resources regarding the 8051 micro-controller.
Documentation
UBC Board Layout Schematic diagram of the UBC 8051 micro-controller board.
SDCC Manual for the SDCC C compiler
Data Sheet Complete data sheet for the P89V51RD2 micro-controller chip published by Philips Semiconductors.
8051 Hardware Hardware guide for the Philips 8051 micro-controller chip.
8051 Architecture Architecture guide for the Philips 8051 micro-controller chip.
8051 Programming Programming (assembly) guide for the Philips 8051 micro-controller chip.
Getting Started - Example Applications
Source Code
Hex File

Makefile
Sample source code for making an LED (connected between VCC and P1.0) blink at a frequency of 5 Hz. This source code requires that you link in the utility library.

Source Code
Hex File
Makefile

Sample source code for making an LED (connected between VCC and P1.0) blink at a frequency of between 1 Hz and 10 KHz depending on the voltage read from analog input port 3 using interrupts. This source code requires that you link in the utility library.

Source Code
Hex File
Makefile

Sample source code for displaying something on the LCD screen. Note that a 14-pin connector must be mounted to the back side of the LCD board (the side without the LCD screen) and the cable must be straight through. Positions 15 and 16 on the LCD board should be left unconnected.
Zip File This zip file contains the starter code (makefile, c files, h files) for the APSC 230 robotic bartender term project. This starter code will make the robot scan the area around it and stop when it sees something in front of it. Students can implement their designs by adding / modifying the functions in func.c & func.h and call their functions from main() in robot.c.
Library of Utility Functions
H File Contains descriptions and declarations for all of the external library functions.
Small Lib File Function library compiled using the small memory model
Medium Lib File Function library compiled using the medium memory model
Large Lib File Function library compiled using the large memory model

Small Device C Compiler Studio

SDCC Small Device C Compiler & general command line utilities. If you have a 64-bit machine (XP64 or Vista) replace the make.exe file in the bin directory with the following 64 bit version of make.
Install Software: Download and unzip the zip file into your root "C:\" directory. This will create a new directory named "C:\Dev".
Configure Software: Modify the user path as follows.
  Right click "My Computer", choose "Properties", choose "Advanced", choose "Environment Variables", select "PATH" and click "Edit".
  Add C:\Dev\bin;C:\Dev\SDCC\bin to existing list .
Configure Serial Port: Control Panel / System / Hardware / Device Manager / Ports / COM 1
  Bits per Sec 115200
  Data Bits 8
  Parity None
  Stop Bits 2
  Flow Control None
ECE Flash Used to download your hex file to your micro-controller through a serial port. This is a custom program written specifically for the UBC 8051 microcontroller board and is more likely to work (than Flash Magic) with a USB to Serial port adapter cable that can be purchased to program your micro-controller using a laptop computer.
Flash Magic Used to download your hex file to your micro-controller through a serial port.
Install Software: Download and install Flash Magic software.
Configure Software: Run Flash Magic and set the following options:
  Baud Rate: 115200
  Device : 89V51RD2
Setup HyperTerminal To debug your code, start up a HyperTerminal (under All Programs / Accessories / Communications) and assign the same settings as specified for configuring your serial port. Any "printf()" statements executed by your micro-controller code will appear on your HyperTerminal.
Macro-Assembler
ASM51 ASM51 is an assembler that is executed on the command line (Command Prompt window). You just have to make sure the "ASM51.EXE" file is somewhere in your searchpath and that the "MOD52" file is in the same directory as your source code. If you use ASM51 to assemble your code, you can use the text editor of your choice to edit your source files (I prefer Vim) and either ECE Flash or FlashMagic (available above) to download the hex file to your microcontroller.
CrossIde If you aren't fussy about your text editor, CrossIde is an all-in-one text editor, assembler and dowloader for programming your microcontroller.
LCD Display
Lumex DataSheet To use the LCD display, you must initialize it, position the cursor, and then write a character to the current cursor position.
  To initialize the LCD, follow the sequence shown on page 270 of the D/S. The LCD is wired for 8-bit mode.
  To position the cursor, use the "Set DDRAM Address" instruction on page 271 of the D/S. Note that AC6 determines the row (0 = top, 1 = bottom) and AC0-5 determine the column.
  To write a character, use the "Write Data to RAM" instruction on page 271 of the D/S. The ASCII character (see page 272 of the D/S) is specified by D0-7.
HD44780 Datasheet The microcontroller used on the Lumex LCD board is the HD4470. Details regarding how the instructions listed on the Lumex Datasheet can be used to control the display (CGRAM, DDRAM, etc) is desribed here.
Hints Please refer to the PCB Layout. Pins DB0-7 are connected to Digital I/O port 0 (P0.0 - P0.7). RS is Dig I/O P1.2 and E is Dig 1/O P1.3. When you are using the LCD display, do not use Digital I/O Ports 0, 1.2 or 1.3 for anything else.
  E is toggled (low / high / low) to make the LCD load and execute an instruction.
  R/W is hardwired to low so the 8051 can only write to the LCD memory. It is permanently disabled from reading the LCD memory.
  It is important to execute the necessary delays as specified in the D/S after executing each instruction to avoid unpredicatable results.
Frequently Asked Questions
Question I've loaded a program on my microcontroller but I can't really tell if it is running.
Answer It is always wise to put an "I'm alive" LED between VCC and P1.0 and toggle the state of P1.0 as your program executes. Don't forget the series resistor because shorting P1.0 to VCC can cause unpredictable results.
Question I have Windows XP 64 installed but I can't make the code.
Answer You forgot to update the file "make.exe" with the 64-bit version provided above. Don't forget to rename the file from "make64.exe" to "make.exe".
Question I am having trouble communicating with the 8051 using a USB to Serial converter plugged into my laptop.
Answer USB to Serial converters are not very reliable. Certain converters do not work with certain computers. You can try a different brand of converter or try the converter that you have on another computer. The nGEAR USB2 to RS232 converter seems to work on most computers. A more reliable option is to buy a PCMCIA serial card such as the CB2S650 from StarTech.com.
Question My microcontroller is doing strange things and I can't tell why.
Answer Are you using an output port to turn on an LED with no series resistor? If so, the S/C that occurs when the LED is on will make the microcontroller behave unpredictably.