Pierre Auger Project Surface Detector Electronics

Tank Power Controller Board (TPCB) Software

Development Environment

June 13, 2001

# Introduction

This document will briefly describe how to set up the development suite
and test bench for the Tank Power Control (TPC) Board. The TPC board has
as its CPU the Analog Devices ADuC812 microconverter. The term
micorconverter is a term that Analog Devices coined to describe its line
of microcontrollers with multi-channel ADCs and DACs built-in. The
microcontroller core of the ADuC812 is based upon the Intel 8052
microprocessor, which is itself an upgrade of the older standard Intel
8051 8-bit microprocessor. Many different development tools and tons of
literature may be found by performing searches on the 8051 or 8052 CPU
cores.

**ADuC812 Code Development Suite:**

There are several elements of the ADuC812 code development suite. The
easiest way to obtain all of the necessary software is to obtain the
ADuC812 development CD. This CD is provided with the evaluation board
for the ADuC812 microconverter. The CD contains the following elements:

-   ADsim812 simulator

-   ASM51 assembler

-   DeBugV1 & 2 debugger

-   Sample C code

-   Downloader code

-   Documentation

-   Keil Tools \*\*

Alternatively, these files may also be obtained through the Analog
Devices website at following link:
[www.analog.com/industry/microconverter/software.html](http://www.analog.com/industry/microconverter/software.html).
This is the exact location of all of these ADuC812 software components,
but the website might be reorganized and the link that Analog Devices
specifies in the documentation is
[www.analog.com/MicroConverter](http://www.analog.com/MicroConverter).
This link references a page full of all of Analog Devices'
microconverter products, and the ADuC812 software page must be found by
following links. The previously mentioned software elements are the only
software elements necessary to develop any code for the ADuC812. The
reason that there are asterisks by the Keil Tools row is that these
tools will install after the rest complete installation. Upon executing
the setup.exe file, the installation wizard will assist in installing
the top 5 elements without any user input. However, after the top 5 are
completed, the wizard will ask whether to install the Keil tools before
exiting the wizard. It is important that these tools are installed as
the Keil tools provide the C language cross complier and simulator.
Without the Keil tools, software development will be substantially
slower, especially for i/o intensive code. The next few sections of this
document will provide more detail about all of the elements of the
development suite.

**ADsim812 simulator:**

The ADsim812 simulator is the ADuC812 simulator provided by Analog
Devices. It is very useful for preliminary testing of the ADuC812 code,
and especially useful for large programs. This application displays
memory locations, interrupts, disassembled code, special function
registers, and serial port outputs among other things. The simulator
allows the developer to single-step and step over instructions as well
as set memory locations, registers, and interrupts. The simulator can be
very useful for catching algorithm errors or run-time errors within the
code. The simulator takes as its input the raw Intel hex file to specify
the operations of the program. The simulator is found in the folder
C:\\ADuC\\ADsim812

**ASM51 assembler**.

The ASM51 assembler is a simple command line assembler, which takes as
its input a user created \*.asm text file. The assembler outputs a
\*.lst file and \*.hex file, which may be used to review and download
the code respectively. Being a command line assembler, the user must use
a text editor to first create an \*.asm input file. The are many
freeware tutorials and instruction set listings for the 8051 and 8052
cores so this information is not readily provided, but a very useful
link for finding this information is the following:
[www.8052.com](http://www.8052.com/). The assembler is found in the
folder C:\\ADuC\\Asm51.

**DeBugV2 Debugger:**

The installation provides both the DeBugV1 and V2 debuggers, but the TPC
uses a recent ADuC812 firmware update so DeBugV2 is the one that the TPC
uses. The debugger enables the assembly code to be tested in the actual
system and provides the flexibility of modifying registers and single
stepping through the code in real time. The debugger requires that the
download kernel is running in order to operate, so the download jumper
must be in place on the TPC board when attempting to use the debugger.
The debugger uses as its input the \*.lst file that is the output from
the assembler. The debugger is found in the folder: C:\\ADuC\\DeBugV2.

#  Sample C code

Several code samples are given written in the C programming language.
These programs illustrate the operation of the UART, the ADCs, and the
programmable timer and they are very useful for picking out some of the
intricacies of these peripherals. The C code is written specifically for
the Keil cross compiler as some elements are not ANSI standard.

There are also a few code examples written in 8051 assembly language.
These files may be compiled with the ASM51 assembler, and are provide
useful models of the 8051 assembly code structure as well as peripheral
operation.

The C samples are found in C:\\ADuC\\C and the assembly files are found
in C:\\ADuC\\code.

# Downloader code

The downloader provided in the installation is provided with the source
code so the download baud rate may be set to many different values. The
compiled executable is also provided in the event that a C compiler is
not available for the host computer. This pre-compiled executable is set
up to download at 9600 baud. In most cases the pre-compiled executable
is all that is necessary as typical downloads take less than 10 seconds
and the maximum transfer rate with the current TPC crystal is 38400
baud. But the code is provided as an option to speed up download and to
provide a better understanding of the download kernel. The downloader
executable may be found in the folder C:\\ADuC and the source code may
be found in the folder C:\\ADuC\\DownLoad.

# Documentation

The provided documentation includes ADuC812 data sheets, errata sheets,
and app notes. All of these documents are worth reading, but the App.
Notes about writing C-code for the ADuC812 is essential to correctly
configuring the Keil tools to compile correctly. These files may be
found in the directory: C:\\ADuC\\Documentation

# Keil Tools

The Keil tools include the uVision-51 compiler and the dScope-51
simulator. Unfortunately these two tools are only the evaluation
versions of the software so they do not come with manuals and even
worse, the simulator is code limited to 2Kbytes. This problem really
becomes apparent when developing debug versions of the code that might
contain a lot of I/O. In most cases, as long as there is not a great
deal of I/O, 2Kbytes is more than enough to store a program of fairly
complex functionality. The final version of the TPC code occupies only
slightly over 1.2Kbytes. The important things to remember when
installing the Keil tools are as follows: copy includes and headers into
the C51Eval directory and make sure project settings are correct. The
next few paragraphs will briefly explain how to correctly set up the
project settings so that the uVision compiler produces the correct files
for use with the ADuC812 and the dScope simulator.

The next few paragraphs will briefly summarize the contents of the
TechNote file with the filename "uC002.pdf". The actual title of this
Tech/App note is "Writing an ADuC812 Application in C". This might be
slightly misleading as it does not really delve into programming
techniques, but rather how to set up the Keil tools so that the ADuC812
is selected correctly as the target. The first step is to make sure that
the Keil tools are indeed installed correctly. This may be done a couple
of ways: the first way is to look at the start menu where the Keil tools
should appear under program files. The default start menu name is "Keil
PK51 -- Eval", this entry should be present if the installation
completed. The other way would be to search the hard drive for the Keil
tools. The default location of these files is in the folder
"C:\\C51eval", this folder should contain several more folders including
/bin, /am, /lib, and several other.

**uVision Compiler:**

If both of the installation tests yield positive results, then the next
step is to copy over the \*.inc and \*.h files from the C:\\ADuC\\C
directory (which was created in the QuickStart installation). These are
the C header and assembly include files that enable the use of mnemonics
instead of addresses to refer to the special function registers and bits
in the ADuC812. The ADuC812.inc file must be copied to the
C:\\C51eval\\asm folder, and the ADuC812.h file must be copied to the
C:\\C51eval\\bin folder. The next step is to set up the project settings
in the uVision compiler so this application should be started from the
start menu. All changes that must be made to the compiler settings are
done through the Options menu. There are really only four steps to
setting up the compiler:

1)  Setting up the A51 assembler

2)  Setting up the C51 compiler

3)  Setting up the PL/M-51 compiler

4)  Setting up the BL51 code banking linker

A51 Assembler:

-   Select "include debug information"

-   Select "define 8051 SFRs"

-   Select "standard" macro processor

-   Deselect everything else

C51 Compiler

-   Select "include debug information"

-   Select "include extended debug information"

-   Select "enable ANSI integer promotion rules"

-   From interrupt vectors select "include in object" and set interval
    "8" offset "0"

-   Deselect everything else

PL/M-51 compiler

-   Select "include debug information"

-   Select "include interrupt vectors"

-   From code select "Compact: 2K Functions, 64K program"

-   From optimization level select "Level 2"

-   Deselect everything else

BL51 Code banking linker: Linking tab

-   Select "include local symbols"

-   Select "include public symbols"

-   Select "include line numbers"

-   Deselect everything else

This procedure only needs to be completed once before the first project
is created to set this as the default project setting. All following
projects will keep these settings and compile correctly for the ADuC812
and the dScope simulator.

**dScope Simulator:**

The final step in setting up the Keil tools is to understand the
necessary simulator settings. Unfortunately the dScope simulator must be
set up every time a project is simulated. Fortunately, the setup
procedure is only one step. Before simulating any project, the dScope
simulator must have the correct target selected. This is accomplished by
selecting the correct CPU driver from the File menu. Upon selecting
"Load CPU driver" from the File menu, a pull-down menu will appear. The
file "8052.dll" must be selected to correctly simulate the ADuC812
device. The final step is to select the built project and simulate it.
The important thing to remember here is that the built project is the
project name with no file extension.