C8051F06x-DK
5. Example Source Code
Example source code and register definition files are provided in the "SiLabs\MCU\Examples\C8051F06x" directory
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.
5.1. Register Definition Files
Register definition files C8051F060.inc and C8051F060.h define all SFR registers and bit-addressable control/
status bits. They are installed into the "SiLabs\MCU\Examples\C8051F06x" directory during IDE installation. The
register and bit names are identical to those used in the C8051F06x 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 C8051F06x 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 C8051F060 target board about five times a second using the interrupt handler
with a C8051F060 timer.
5.3. Data Aquisition Example
The Data Aquisition example can be found in the "SiLabs\MCU\Examples\C8051F06x\C" directory in source file
SAR16data.c. This example illustrates the use of ADC1 and the DMA to acquire and store data. It is intended for
use with the C8051F060TB target board in the development kit. The code measures a signal at the AIN0 input with
the 16-bit SAR ADC0. The data is then sampled at a rate of 100kHz. ADC output data is transferred to XDATA
memory space using the DMA.
5.3.1. Code Description
With the EMIF configured for off-chip XRAM access (on the upper ports), the code moves the ADC data to the
C8051F060TB target boards's SRAM device. Once data acquisition is complete, the code then prompts the user to
press the P3.7 button on the target board when ready to receive the data via the UART0 serial port. The TB fea-
tures an RS-232 transceiver and connector, so the data can be transferred to a PC via its serial port. The code is
set to acquire up to 32768 samples (for 64kbytes of data). The SRAM device can accommodate up to 128kbytes,
but this requires banking (A16 signal on the SRAM).
5.3.2. Target Board Configuration
This example uses RS-232 communications, typically with a PC. A serial cable should be connected to the J5 RS-
232 DB9 connector on the target board and a serial port on a PC. Data can be input from the PC's serial port using
the commonly available program Hyperterminal. The following target board headers must be configured (see
Section 7 on page 10 for schematic):
J1
Connect P3.7 to push-button SW2.
J6, J9
Connect UART0 TX and RX to the J5 DB9 connector.
J11
Enable External Memory Interface SRAM device.
J14[2:3] Connect the SRAM A16 pin to GND.
J17, J28 Set analog input VREF options.
J20[1:2] Enable ±5 V switching power supply by connecting Vin, +5 V, to /SHDN.
4
Rev. 0.7
Need help?
Do you have a question about the C8051F06 Series and is the answer not in the manual?
Questions and answers