Instructions on 80251 Microcontroller Board and Software

 

by

Diego Campos (SPRING 2002): 1.0, 2.0, 3.0

Updated by

Matthew Klepeis (SPRING 2003): 4.0

Steve Sanko (SPRING 2005): 4.1

Michael Conlow (SPRING 2011): 4.2

Edited by Dr. Joseph Wunderlich

 

Ver. 4.2

Last update – 3/27/11

 

I.    INSTALLING SOFTWARE*

in251_01

 

 

 

 

 

a.     The microcontroller software (also found in [1] as a CD) is kept in Elizabethtown College’s ITS office (Brian Helm).

b.    Drag and drop entire folder labeled C251eval into your primary drive.

c.     Go into the folder of the copied C251eval file in your drive and look in the Bin folder for the file Uvw251.exe file.  This is the execution file for the Development Environment that will be used.

d.    Double-click the Uvw251 the file and you will see that the computer has not chosen a tool set. Click on OK and select Keil 80251C Compiler Version 2.x.

·         Installation instructions also included in Install.txt folder (seen above).

·         Evaluation version will create programs up to 2KB in length.

 

II.    Our MCB251 Development Board [2]

 

untitled

 

 

a.     Ensure Dip Switches are in the default setting:

 

Switch

Uart Int

Ext Uart

SRC/D2

Page

Monitor

51/151

Map 1

Map 2

LED

A17

ON

X

X

X

 

X

 

 

 

X

X

OFF

 

 

 

X

 

X

X

X

 

 

 

The board must be reset after changing any dip switch settings

 

b.    Technical Data:

Supply Voltage

8V – 12V DC

Supply Current

Typical: 300mA

System Clock

12MHz

Memory

256 KB

128 KB Monitor EPROM

Optional: 256KB User EPROM

CPU

Intel 80C251SB

Temic 80C251G1

Optional: Dallas 80C320, Intel 80C151,

Intel 80C51Fc, or compatible

Peripherals

2 x RS232 Interfaces

 

c.     Basic Block Diagram [3]

IOblockdiagram

 

III.    µVISION SOFTWARE**

 

Overview:

·         Configure MicroVision 251

·         Create and Save source file

·         Create and Save project file

·         Include source file in project

·         Compile and Build project (Completed when “Successfully Linked” screen appears)

 

a.     First, you must configure the settings to use the assembler program. Go to the Options tab and select A251 Assembler. 

in251_02                               

This is the program that will translate the assembly program to machine language.   ** See page 338 in [1].

 

b.    Do not change any of the default settings in the Listing tab (should only have top three options checked) but go to the Object tab.  Select Include debug information and select Source Mode for code generation. Notice the bottom Command Line Options String, this shows you what has been modified from the default assembler settings.

in251_03

Once all has been done, click OK and you are ready to write assembler code.

 

c.     To create a new source file go to the New File icon, click File/New File, or ctrl+n and you will see an Untitled# text editor appear.

a51_win

 

d.    If you are using the software in [1], ALL SOURCE FILES MUST BEGIN WITH THE FOLLOWING LINES OF CODE:

 

$rb(0,1,2,3); space for all register banks

$include(c:\c251eval\asm\reg251s.inc);use 80251 register definitions

 

e.     The following information is from [1] and may require the reader to have access to the text.  The following is covered in section A.5 in the text and explains program segments and the nomenclature for the class types and memory addressing for code.  IF YOU ARE NOT SURE WHAT SEGMENT TO USE, PLEASE READ THE TEXT pgs 313-316.

 

f.     The syntax used for defining segments used per program (be sure only to include segments that will definitely be used, programs with unused included segments will generate errors) is

 

Name_this    SEGMENT            class

 

g.    The segment that is always used is the code class, any other type may be added as the programmer needs but is not necessary.

 

h.     For textbook purposes, the following is used in instructions and should be followed to reduce confusion:

 

Name                                 Class

prog           segment           code

ram            segment           data

eram          segment           edata

b2add         segment           ebit

 

i.      Each segment class has its own characteristics and is very dependent on the needs of the programmer’s uses; they also have their own addressing modes (e.g. direct, indirect memory addressing).  In order of lowest address size to highest (8 to 24), the ebit  class uses 8-bit direct addressing, data uses 8-bit direct and indirect addressing, edata uses 24-bit direct and indirect addressing, and code does 24-bit fetch modes.

 

j.      In order to select a “segment” the class of memory must be set aside for the assembler.  The rseg variable is used to let the assembler know which class is used to assemble the code correctly.  This uses the programmer’s definition of the code segment, for example:

 

rseg ram          ; select data memory access (from user def)

 

k.     In the assembly software, numbers can be signified between hex, decimal, and binary using the h and b characters at the end of the number.  As in regular 8086 assembly, 111h, 111, and 111b are all different numbers.

 

l.      After making any programs, one must save the source file correctly.  Since this is an assembler source code, we will use the .a51 extension for any files we create (versus the .c extension for C code).

 

m.   Go to the SaveAs and another window will appear prompting for the name of the source file and destination to be saved.

 

n.     Also, Save File as Type must be looked at for the right type of extension.

 

win_savas2win_savas

      win_a512

 

o.    However, this is not the only thing required.  A project file must also be created as the workspace to assemble the source files.  This is constructed in the same manner and needs to be in the same path as the source file.  Merely go to the Project tab and select New Project ending with the .prj extension.

win_savprj            win_savprj2

 

p.    The next step will be to add Source Files to the project.  The following window will prompt you to Add files into your project.

 

win_adprj

 

q.    After clicking Add, you will be prompted for the type of file (.c or .a51) to be adding, make sure its .a51.

 

r.      Finally, click on Open All to have the assembler actively edit and compile the code without having to add to projects.  Then click Save to have these configurations stored.

 

 

 

IV.    EXAMPLE PROGRAM  

a.     A example that will introduce use of dScope, the debugging software that lets us look at individual bits in memory while the program runs.

b.    Create source code and name it Math1.a51  using the following code, which compares a running loop count to a max loop count.

$rb(0,1,2,3)                            ;Set aside space for register banks
$include(c:\c251eval\asm\reg251s.inc)   ;80251 definitions


prog segment code     ;Default code segment ff:0000-07ffh

  mov WR0, #0000h     ;Clear word-register0 for the running loop count
  mov WR2, #000Ah     ;Set word-register2 to 10 for the max loop count


rseg prog             ;Declare start of the code segment

check:                ;Check loop status 
  cmp WR0, WR2        ;Compare the values stored in both registers
  jne incrmt          ;Jump to the increment section if the two

                      ;registers were not equal
  sjmp done           ;Short jump to done when the registers are equal

incrmt:

  inc WR0,#01h       ;Increment the running loop count by one
  sjmp check         ;Short jump back to check

done:

  NOP                ;No operation, end of code

 

 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


c.     After the code has been typed, saved, and project created, code added, then we are ready to build the assembled code.  You may click on the Build All button that has three downward arrows.

win_build

 

 

 

 

d.    if you get errors, the compiler will pop up a window with errors and their locations, merely double clicking the marked areas in red highlight will show you what part of code is in error in green highlight

 

Error prompted:    win_error 

 

 

    Error Shown:    win_solution

 

 

e.     After code is compiled successfully the following screen is shown.

 

linked

 

V.    dScope DEBUGGER

 

win_dicon

 

a.     Next we are to use the dScope debugger to see if the code worked.  Click on the dScope icon.

b.    In the dScope window, under Setup select MC80251.

c.     A series of windows will open, one blue, white, and the other grey with registers and contents being shown.  Before we begin, we will talk about the Peripherals  window which will help us figure out how the code works on the actual prototyping board.

d.    Begin by loading the CPU driver, this is done by clicking File, load, then selecting the .dll that best resembles the type of 80251 chip that is on the board.  For default purposes, choose “mon251.dll”. 

 

*Note: Error: Target System Not Found - Be sure the correct port is selected and the Baudrate is set at 57600. Additionally, check that the serial cable is plugged into the External Serial Jack (“RS232”) on the Microcontroller Board.

 

e.     From the Peripherals menu, select the Configuration command. Make sure there is a checkmark in the box next to Enable serial break.

f.     Next, look at the command window.  Enter “load then the project name only, without the extension (e.g. “one”). If this fails simply go to File then load the compiled hex object file.

 

g.    After this is done, the blue window will show the contents of the code that was added to the project.  In order to go through the program for the right information, we will use the Peripherals menu and the Module window.

h.     First, notice the Regs window, it displays contents in memory, R0 – PSW1.  These are recognizable as the R0-R4 registers, wide registers, stack and stack pointer.  The first tip in debugging is stepping through the code to see changes in memory contents.

i.      The first two lines of code move numbers into registers.  This can be seen by double clicking on the line of code in the Module window until the line turns yellow.  Making sure that this line is AFTER the red “current line”, we can step through using the StepInto! Icon/button on the  toolbar.

 

win_stepbug

 

j.      The Go! Icon has the same effect, except that it goes straight to the yellow line, you cannot see intermediate changes in the Regs window with this.  Furthermore, the Regs window is not the only way to view memory, the Peripherals lets you view Special Function Registers (SFR’s) and is a convenient way of looking at Timers.

            

Changes in register window actually appear blue. Notice R0 and R4 contents changing, Sts and Sec values incrementing.

 

VI.    PERIPHERALS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

a.     If your code has timers whatsoever, selecting the Timer 0/1 option will present a Timer window with the ability to change its functionality of counter or timer, 16-13-8 bit counter/timer, counter or timer, and even the high and low bits.  This is especially useful when using the 80251 in sending serial data and communication.  Eventually this is used to view baud rates and whether the Timer is operational.

b.    The toolbox Reset feature lets you clear everything from stack memory and start clean.

c.     Finally, the Serial I/O windows are used to configure data sent via serial port and the other to view data being sent and at what rate.  This is done using, again, the Peripherals menu, which will allow the user to view contents of SBUF, SCON, SADDR, and SADEN.  In order to use the serial port SFR one must configure the T1 or T2 timers as baud-rate generators, and the program must be in Go! Mode.

d.     

 

win_ser

 

e.     Right clicking the Serial I/O window allows changing the data transmitted as hex or ascii (default).  In order to transmit data, one must use a one byte, typically ascii, if more than that must be used then SBUF must be used in the command window.

f.     In order to input serial data to SBUF, one must type “sin = “ then the data to be transmitted.

 

VII.    PARRALLEL PORTS

 

 

 

 

 

 

 

 

 

a.     I/O-Ports in Peripherals lets you view the bits that are set on the parallel ports of the microcontroller.  P0 is the fundamental port in which to view the LED’s light up on the protoboard.  However, by viewing the contents, one may make sure the program is configured to correctly light in sequence.

b.    The Setup option in Peripherals lets you set the debugger as close to the board as possible.  This lets you simulate the environment as close as the real one as possible such as choosing the type of mode you wish the program to operate (source or binary), and at what framsize (doesn’t matter).

c.     The interrupt system window lets you view the interrupt flags and interrupt-enable bits, and interrupt-control bits.  Each one may be set or cleared by clicking on the corresponding source then selecting which bit to be set with.

 

d.    Finally, in order to set Crystal Frequency, the following must be typed in the command window:

 

xtal = frequency

where frequency is in hertz, full number (no Mhz or khz, if 12Mz,

 then frequency = 12000000)

 

e.     The previous is especially useful when using programs that requires the 80251 to match a reception or transmitting frequency.

 

VIII.    Status LED’s

 

a.     The status LED’s are accessed through the variable P1

b.    An 8 bit number can be displayed in binary simply by moving the number into P1 as demonstrated by the following line of code:

 

mov     P1,#0Ch

 

*Note: For hex numbers greater than 9, the letter must be preceded by a Zero

 

 

 

 

IX.    8051(highlighted) and 80251 INSTRUCTION SET [2]

 

programref1

programref2

programref3

programref4

 

 

 

programref5programref6

programref7programref8

programref10programref10

 

programref11programref12

 

X.    8051 Memory Map [4]:

 

http://www.computer-solutions.co.uk/info/images/8051%20Memory%20Map.JPG

 

 

 

8051 Memory Map close-up of Address space 0000h to 00FFh [5]:

 

http://www.base2software.com/eiarchives/ie200208/8051%20Mem%20Map.jpg

 

 

XI.    8051 Chip Pin-out[6]:

http://www.edsim51.com/8051Notes/8051/images/8051Pinout.GIF

 

 

 

XII.    Our 80251 Development Board:

251

 

 

 

untitled

 

 

 

XIII.    REFERENCES

 

[1]  Ayala, Kenneth.  The 80251 Microcontroller. Prentice-Hall: Upper Saddle River, 2000.

[2]  8XC251SA, 8XC251SB, 8XCC251SP, 8XX251SQ Embedded Microcontroller User’s Manual.  Intel, 1996.

[3] MCB251 Evaluation Board User’s Guide 07.97, Keil Software.

[4] “8051 Tutorial” by Computer Solutions Ltd 1a New Haw Road, Addlestone, Surrey KT15 2BZ, England http://www.computer-solutions.co.uk/info/micro-search/8051/8051_tutorial.htm

[5] “Embeeded insight archives“ by Base2software design inc. http://www.base2software.com/eiarchives/ie200208/ie200208.htm

[6] “The 8051” by James Rogers 2006 http://www.edsim51.com/8051Notes/8051/parallelInputOuput.html