Silicon Laboratories C8051F04X-DK User Manual

C8051F04x-DK
C8051F04X DEVELOPMENT KIT USERS GUIDE

1. Kit Contents

The C8051F04x Development Kit contains the following items:
• Two C8051F040 Target Boards
• C8051Fxxx Development Kit Quick-Start Guide
• Silicon Laboratories IDE and Product Information CD-ROM. CD content includes:
• Keil 8051 Development Tools (macro assembler, linker, evaluation ‘C’ compiler)
• Source code examples and register definition files
• Documentation
• C8051F04x Development Kit User’s Guide (this document)
• Two AC to DC Power Adapters
• CAN Cable (DB-9 connectors)
• USB Debug Adapter (USB to Debug Interface)
• USB Cable

2. Hardware Setup using a USB Debug Adapter

The target board is connected to a PC running the Silicon Laboratories IDE via the USB Debug Adapter as shown in Figure 1.
1. Connect the USB Debug Adapter to the JTAG connector on the target board with the 10-pin ribbon cable.
2. Connect one end of the USB cable to the USB connector on the USB Debug Adapter.
3. Connect the other end of the USB cable to a USB Port on the PC.
4. Connect the ac/dc power adapter to power jack P1 on the target board.
Notes:
• Use the Reset button in the IDE to reset the target when connected using a USB Debug Adapter.
• Remove power from the target board and the USB Debug Adapter before connecting or disconnecting the ribbon cable from the target board. Connecting or disconnecting the cable when the devices have power can damage the device and/or the USB Debug Adapter.
AC/DC
PC
USB
Cable
USB Debug Adapter
USB DEBUG ADAPTER
StopPower
Run
Adapter
Target Board
Silicon Laboratories
P3.7RESET
PWR
SILICON LABORATORIES
MCU
P1.6
Port 2 Port 0
Port 4Port 3Port 1

Figure 1. Hardware Setup using a USB Debug Adapter

Rev. 0.6 9/06 Copyright © 2006 by Silicon Laboratories C8051F04x-DK
C8051F04x-DK

3. Software Setup

The included CD-ROM contains the Silicon Laboratories Integrated Development Environment (IDE), Keil software 8051 tools and additional documentation. Insert the CD-ROM into your PC’s CD-ROM drive. An installer will auto­matically launch, allowing you to install the IDE software or read documentation by clicking buttons on the Installa­tion Panel. If the installer does not automatically start when you insert the CD-ROM, run autorun.exe found in the root directory of the CD-ROM. Refer to the readme.txt file on the CD-ROM for the latest information regarding known IDE problems and restrictions.

4. Silicon Laboratories Integrated Development Environment

The Silicon Laboratories IDE integrates a source-code editor, source-level debugger and in-system Flash program­mer. The use of third-party compilers and assemblers is also supported. This development kit includes the Keil Software A51 macro assembler, BL51 linker and evaluation version C51 ‘C’ compiler. These tools can be used from within the Silicon Laboratories IDE.

4.1. System Requirements

The Silicon Laboratories IDE requirements:
• Pentium-class host PC running Microsoft Windows 98SE or later.
• One available COM or USB port.
• 64 MB RAM and 40 MB free HD space recommended.

4.2. Assembler and Linker

A full-version Keil A51 macro assembler and BL51 banking linker are included with the development kit and are installed during IDE installation. The complete assembler and linker reference manual can be found under the Help menu in the IDE or in the “SiLabs\MCU\hlp” directory (A51.pdf).

4.3. Evaluation C51 ‘C’ Compiler

An evaluation version of the Keil C51 ‘C’ compiler is included with the development kit and is installed during IDE installation. The evaluation version of the C51 compiler is the same as the full professional version except code size is limited to 4 kB and the floating point library is not included. The C51 compiler reference manual can be found under the Help menu in the IDE or in the “SiLabs\MCU\hlp” directory (C51.pdf).

4.4. Using the Keil Software 8051 Tools with the Silicon Laboratories IDE

To perform source-level debugging with the IDE, you must configure the Keil 8051 tools to generate an absolute object file in the OMF-51 format with object extensions and debug records enabled. You may build the OMF-51 absolute object file by calling the Keil 8051 tools at the command line (e.g. batch file or make file) or by using the project manager built into the IDE. The default configuration when using the Silicon Laboratories IDE project manager enables object extension and debug record generation. Keil 8051 Tools Into the Silicon Laboratories IDE CD-ROM for additional information on using the Keil 8051 tools with the Silicon Laboratories IDE.
To build an absolute object file using the Silicon Laboratories IDE project manager, you must first create a project. A project consists of a set of files, IDE configuration, debug views, and a target build configuration (list of files and tool configurations used as input to the assembler, compiler, and linker when building an output object file).
in the “SiLabs\MCU\Documentation\Appnotes” directory on the
Refer to Applications Note
AN104 -
Integrating
The following sections illustrate the steps necessary to manually create a project with one or more source files, build a program and download the program to the target in preparation for debugging. (The IDE will automatically create a single-file project using the currently open and active source file if you select defined.)
2 Rev. 0.6
Build/Make Project
before a project is

4.4.1. Creating a New Project

1. Select Project
New Project to open a new project and reset all configuration settings to default.
C8051F04x-DK
2. Select File
ognized extension, such as .c, .h, or .asm, to enable color syntax highlighting.
3. Right-click on “New Project” in the Project Window. Select Add files to project. Select files in the file
browser and click Open. Continue adding files until all project files have been added.
4. For each of the files in the
build, right-click on the file name and select appropriate (based on file extension) and linked into the build of the absolute object file.
Note:
Right-click on “New Project” in the groups or add customized groups. Right-click on the group name and choose to be added. Continue adding files until all project files have been added.

4.4.2. Building and Downloading the Program for Debugging

1. Once all source files have been added to the target build, build the project by clicking on the Build/Make
Project button in the toolbar or selecting Project
Note: After the project has been built the first time, the Build/Make Project command will only build the
files that have been changed since the previous build. To rebuild all files and project dependencies, click on the Rebuild All button in the toolbar or select Project
2.
Before connecting to the target device, several connection options may need to be set.
Connection Options
the appropriate adapter in the “Serial Adapter” section. Next, the correct “Debug Interface” must be selected. C8051F04x button to close the window.
New File to open an editor window. Create your source file(s) and save the file(s) with a rec-
Project Window
If a project contains a large number of files, the “Group” feature of the IDE can be used to organize.
Project Window
that you want assembled, compiled and linked into the target
Add file to build
. Select
. Each file will be assembled or compiled as
Add Groups to project
Add file to group
. Add pre-defined
. Select files
Build/Make Project from the menu.
Rebuild All from the menu.
window by selecting
family devices use the JTAG debug interface. Once all the selections are made, click the OK
Options→Connection Options...
in the IDE menu. First, select
Open the
3. Click the
4. Download the project to the target by clicking the Download Code button in the toolbar.
Note: To enable automatic downloading if the program build is successful select Enable automatic con- nect/download after build in the Project
build process, the IDE will not attempt the download.
5. Save the project when finished with the debug session to preserve the current target build configuration,
editor settings and the location of all open debug views. To save the project, select Project->Save Project
As... from the menu. Create a new name for the project and click on Save.
Connect
button in the toolbar or select
Target Build Configuration dialog. If errors occur during the
Debug→Connect
from the menu to connect to the device.
Rev. 0.6 3
C8051F04x-DK

5. Example Source Code

Example source code and register definition files are provided in the “SiLabs\MCU\Examples\ during IDE installation. These files may be used as a template for code development. Example applications include a blinking LED example which configures the green LED on the target board to blink at a fixed rate. A Area Network (CAN)
application example is also included with the C8051F04x development kit.
C8051F04x
” directory
Controller

5.1. Register Definition Files

Register definition files C8051F040.inc and C8051F040.h define all SFR registers and bit-addressable control/ status bits. They are installed into the “SiLabs\MCU\Examples\C8051F04x” directory during IDE installation. The register and bit names are identical to those used in the C8051F04x data sheet. Both register definition files are also installed in the default search path used by the Keil Software 8051 tools. Therefore, when using the Keil 8051 tools included with the development kit (A51, C51), it is not necessary to copy a register definition file to each project’s file directory.

5.2. Blinking LED Example

The example source files blink.asm and blinky.c show examples of several basic C8051F04x functions. These include; disabling the watchdog timer (WDT), configuring the Port I/O crossbar, configuring a timer for an interrupt routine, initializing the system clock, and configuring a GPIO port. When compiled/assembled and linked this pro­gram flashes the green LED on the C8051F040 target board about five times a second using the interrupt handler with a C8051F040 timer.
4 Rev. 0.6
C8051F04x-DK

5.3. Controller Area Network (CAN) Application Example

Configuration and use of the CAN controller is documented in the Bosch CAN User’s Guide, located in the “Documen­tation” directory on the CD-ROM. Accessing the CAN controller (i.e., accessing the CAN RAM, CAN registers, and
moving data to and from the CAN controller) is documented in Silicon Laboratories’ C8051F04x data sheet.
An example CAN application is included in the “Examples\C8051F04x” directory. Each C8051F040 target board fea­tures a push button (labeled P3.7) and a LED (labeled P1.6). After the two target boards are connected together via the provided CAN bus physical layer (i.e. cable, connectors, and CAN transceiver), the example application sends CAN messages between the two target boards containing the state of the push buttons. In this example, each CAN controller has two of the 32 message objects configured: one to send a control signal based on the state of its target board push button, and one to receive a control signal from the other target to see if it should turn on/off its own LED. When a target board receives a message that the push button on the other target board is depressed, it lights its own LED. When a target board receives a message that the push button on the other target board is not depressed, it turns off its own LED. In this way, the push button on one target board controls the LED on the other target board as a virtual control link via a CAN bus.

5.3.1. Setting-up the Application

1. Connect the target boards together at the CAN DB-9 connectors using the CAN cable provided in the
development kit, as shown in Figure 2 on page 6. The correct cable has a male connector on both ends. Take care not to connect the CAN cable to the RS232 DB-9 connector. See Figure 3 on page 7 for the location of the CAN DB-9 connector.
2. Compile and link the can1.c example located in the “Examples\C8051F04x” directory on the CD-ROM.
Choose one of the target boards as Target Board #1. Connect to Target Board #1 and download the can1 project to the C8051F040, following the steps outlined in Section 4.4 on page 2. Once downloaded, close this project in the IDE and disconnect the Debug Adapter from Target Board #1.
3. Connect the Debug Adapter to the other target board, Target Board #2. Open a new project in the IDE and
load can2.c into the C8051F040 device, just as was done in step 2 for Target Board #1. Take care not to load can1.c into both devices. Disconnect the Debug Adapter from this board.
You should now have can1.c loaded into Target Board #1, and can2.c loaded into Target Board #2. The CAN cable should be connected to both boards at the CAN DB-9 connectors.

5.3.2. Running the Application

1. Start the application by resetting the device on each target board. Do this by depressing the RESET push
button on each target board. As can1.c executes on Target Board #1, and can2.c runs on Target Board #2, the devices are now nodes on a CAN bus.
2. Pressing the P3.7 push button on Target Board #1 will light the LED on Target Board #2. Likewise, when
the push button on Target Board #1 is released, the LED on Target Board #2 will turn off. This will work on either target board.
Once this example is running, you have established a simple CAN network with two nodes. When one C8051F040 device senses the push button on its target board is pressed, it sends a “0x11” in the first byte of a CAN message data field. When the button is released, the first byte of the CAN message data field is “0x00”. When a C8051F040 device receives a message, it checks whether this byte has a value of “0x11” or “0x00”. When the byte is “0x11”, the device turns on its LED by setting P1.6 high. When the byte is “0x00”, the device turns off its LED by setting P1.6 low.
Rev. 0.6 5
Loading...
+ 11 hidden pages