background image

A N 1 7 9

4

Rev. 0.4

5. Example Source Code

Example source code and register definition files are provided in the “

SiLabs\MCU\Examples\C8051F31x

” 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 

C8051F310.inc and C8051F310.h 

define all SFR registers and bit-addressable control/

status bits. They are installed into the “

SiLabs\MCU\Examples\C8051F31x

” directory during IDE installation. The

register and bit names are identical to those used in the C8051F31x 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 C8051F31x 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 C8051F310 target board about five times a second using the interrupt handler
with a C8051F310 timer. 

Summary of Contents for C8051F310

Page 1: ...F31x Development Kit User s Guide this document 2 Hardware Setup The target board is connected to a PC running the Silicon Laboratories IDE via the Serial Adapter as shown in Figure 1 1 Connect one end of the RS232 serial cable to a Serial COM Port on the PC 2 Connect the other end of the RS232 serial cable to the DB 9 connector on the Serial Adapter 3 Connect the Serial Adapter to the DEBUG conne...

Page 2: ...ith 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 4K bytes 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 ...

Page 3: ...ng 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 Build Make Project from the menu 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 ...

Page 4: ...s are identical to those used in the C8051F31x 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 a...

Page 5: ...r accepts input from 7 to 15 VDC unregulated power adapter J1 34 pin Expansion I O connector J3 Port I O Configuration Jumper Block J4 DEBUG connector for Serial Adapter interface J5 DB 9 connector for UART0 RS232 interface J6 Analog I O terminal block J7 Low pass filter connector J8 Serial Adapter target board power connector J9 J10 External crystal enable connectors J7 PWR Pin 1 Pin 2 DEBUG Pin ...

Page 6: ...et for more infor mation on the use of external oscillators 6 2 Switches and LEDs Two switches are provided on the target board Switch SW1 is connected to the RESET pin of the C8051F310 Pressing SW1 puts the device into its hardware reset state Switch SW2 is connected to the C8051F310 s general purpose I O GPIO pin through jumpers Pressing SW2 generates a logic low signal on the port pin Remove th...

Page 7: ... 4 Target Board DEBUG Interface J4 The DEBUG connector J4 provides access to the DEBUG C2 pins of the C8051F310 It is used to connect the Serial Adapter to the target board for in circuit debugging and Flash programming Table 3 shows the DEBUG pin definitions Pin Description Pin Description Pin Description 1 3 VD 3 3 VDC 13 P1 2 25 P2 6 2 PWM Output 14 P1 3 26 P2 7 3 P0 0 15 P1 4 27 P3 0 4 P0 1 16...

Page 8: ... power to the target board This connection is routed from J4 10 to J8 1 Place a shorting block at jumper J8 2 3 to power the board directly from an AC DC power adapter Place a shorting block at jumper J8 1 2 to power the board from the Serial Adapter Please note that the second option is not supported with either the EC1 or EC2 Serial Adapters 6 8 Low pass Filter J7 The C8051F310 target board feat...

Page 9: ...ts cannot provide power to the target board Table 5 shows the pin definitions for the Serial Adapter s JTAG connector Notes 1 When powering the Serial Adapter via the JTAG connector the input voltage to the JTAG connector s power pin must be 3 0 to 3 6 VDC Otherwise the Serial Adapter must be powered directly by connecting the AC DC adapter to the Serial Adapter s DC power jack 2 The Serial Adapte...

Page 10: ...AN179 10 Rev 0 4 8 Schematic Figure 4 C8051F310 Target Board Schematic ...

Page 11: ...AN179 Rev 0 4 11 Notes ...

Page 12: ...r the functioning of undescribed features or parameters Silicon Laboratories reserves the right to make changes without further notice Silicon Laboratories makes no warranty rep resentation or guarantee regarding the suitability of its products for any particular purpose nor does Silicon Laboratories assume any liability arising out of the application or use of any product or circuit and specifica...

Reviews: