Silicon Laboratories F321DC Computer Accessories user guide

N for the Keil toolset.

ToolSt ic k- F 321DC

5.2. Keil Demonstration Toolset

5.2.1. Keil Assembler and Linker

The Keil demonstration toolset assembler and linker place no restrictions on code size.

5.2.2. Keil Demonstration C51 C Compiler

The evaluation version of the C51 compiler is the same as the full version with the following limitations:

Maximum 4 kB code generation.

There is no floating point library included.

When initially installed, the C51 compiler is limited to a code size of 2 kB, and programs start at code address

0x0800. Refer to AN104: Integrating Keil Tools into the Silicon Labs IDE" for instructions to change the limitation to 4 kB and have the programs start at code address 0x0000.

5.3. Configuration Wizard 2

The Configuration Wizard 2 is a code generation tool for all of the Silicon Laboratories devices. Code is generated through the use of dialog boxes for each of the device's peripherals.

Figure 4. Configuration Wizard 2 Utility

The Configuration Wizard 2 utility helps accelerate development by automatically generating initialization source code to configure and enable the on-chip resources needed by most design projects. In just a few steps, the wizard creates complete startup code for a specific Silicon Laboratories MCU. The program is configurable to provide the output in C or assembly.

For more information, please refer to the Configuration Wizard 2 documentation. The documentation and software


5.4. Keil uVision2 and uVision3 Silicon Laboratories Drivers

As an alternative to the Silicon Laboratories IDE, the uVision debug driver allows the Keil uVision2 and uVision3

IDEs to communicate with Silicon Laboratories on-chip debug logic. In-system Flash memory programming integrated into the driver allows for rapidly updating target code. The uVision2 and uVision3 IDEs can be used to start and stop program execution, set breakpoints, check variables, inspect and modify memory contents, and single-step through programs running on the actual target hardware.

For more information, please refer to the uVision driver documentation. The documentation and software are

5.5. ToolStick Terminal

The ToolStick Terminal program provides the standard terminal interface to the target microcontroller's UART.

However, instead of requiring the usual RS-232 and COM port connection, ToolStick Terminal uses the USB interface of the ToolStick Base Adapter to provide the same functionality.

In addition to the standard terminal functions (send file, receive file, change baud rate), two GPIO pins on the target microcontroller can be controlled using the Terminal for either RTS/CTS handshaking or software-configurable purposes (see the demo software for an example).

See Section "6.8. Using ToolStick Terminal" on page 12 for more information. The software is available on the

ToolSt ic k- F 321DC

6. ToolStick C8051F321 Daughter Card Features Demo

The ToolStick kit includes a few simple code examples. The example described in this section is titled

F321DC_FeaturesDemo. The purpose of this example is to guide a new user through the features and capabilities of the IDE and demonstrate the microcontrollers on-chip debug capabilities. The F321DC_FeaturesDemo example code uses the potentiometer on the daughter card to vary the blinking rate of the LED. The first part of this demo shows how to use the IDE to connect and download the firmware, view and modify registers, use watch windows, use breakpoints, and single step through code. The second part of the demo shows how to use ToolStick

Terminal to receive UART data from the daughter card and how to use the GPIO pins.

6.1. Hardware Setup

Connect the ToolStick hardware to the PC using the steps below while taking note of the recommendations in

Section 1:

1. Connect the ToolStick Base Adapter to the ToolStick C8051F321 Daughter Card.

2. If available, connect the USB extension cable to the ToolStick Base Adapter.

3. Connect the ToolStick to a USB port on a PC.

See Figure 5 below for an example hardware setup using the C8051F330 ToolStick Daughter Card.

Figure 5. Hardware Setup Example


6.2. Connecting to the Device and Downloading Firmware

This section describes how to open the IDE, open and build a project, connect to a device and download the

1. Open the Silicon Laboratories IDE from the Start Programs Silicon Laboratories menu.

2. In the IDE, go to Project Open Project.

3. Browse to the default location, C:SiLabsMCUToolStickF321DCFirmware.

5. In the IDE, select Project Rebuild Project.

6. Go to Options Connection Options.

7. Select USB Debug Adapter for the Serial Adapter and C2 for the Debug Interface, and then click OK.

8. Go to Debug Connect.

9. Download the code using the download button on the menu bar or use alt-D.

Once these steps are completed, the firmware is built into an object file (step 5) and downloaded to the device

(step 9). The device is now ready to begin executing code. If all of these steps were followed successfully, the Go option is enabled in the Debug menu. A green circle icon in the IDE toolbar also indicates that the device is ready to run. If one of the steps leads to an error, make sure that the ToolStick is properly inserted in a USB port and start again with step 6.

6.3. Running and Stopping Code Execution

Once the IDE is connected to the device and the firmware is loaded, the IDE can start and stop the code execution.

The following steps can be performed using the buttons on the toolbar or using the options in the Debug menu.

1. To start code execution, click the green Go button on the toolbar or use the Debug Go menu option. The green LED on the daughter card will start to flash. The debug commands in the IDE (single-step, multiple-step, set breakpoint, and others) are disabled when the device is running. While the firmware is running, the potentiometer on the daughter card can be turned to alter the blinking speed of the LED. The switch labeled S1 can also be pressed to toggle the ADC on and off. When the ADC is off, the blink rate or brightness of the LED will not change.

2. To stop code execution, click the red Stop button on the toolbar or use the Debug Stop menu option. The device will halt code execution and all of the registers and pins on the device will hold their state.

All debug windows and watch windows are refreshed when the device is stopped. If any of the values in these windows have changed since the last time the device was halted, the new value is shown in red text instead of black text.

ToolSt ic k- F 321DC

6.4. Viewing and Modifying Registers

All registers on the device can be viewed and modified when the device is in a halted state. The registers are grouped together according to which peripheral or part of hardware they belong. As an example, this guide shows how to open the ADC0 Debug Window and disable the ADC0 directly from the IDE.

1. Open the ADC0 Debug Window from the View Debug Windows SFRs ADC0 menu option. The

ADC0 Debug Window appears on the right-hand side of the IDE. In this window, the ADC0CN register is shown. This register is used to enable and configure the on-chip ADC. When the firmware is running, the

ADC0CN register reads as 0x82 indicating that the ADC is running.

2. In the debug window, change the value of ADC0CN from 0x82 to 0x02. This value turns off the ADC on the target microcontroller.

3. To write this new value to the device, select Refresh fr