AN140
AN140
I N T E G R A T I N G H I - T E C H 8 0 5 1 TO O L S I N T O T H E S I L I C O N L A B S I D E
1. Introduction
Next, define the HI-TECH assembler, compiler, and
linker as shown in the following sections.
This application note describes how to integrate the
HI-TECH 8051 Tools into the Silicon Laboratories IDE
(Integrated Development Environment). Integration
provides an efficient development environment with
compose, edit, build, download and debug operations
integrated in the same program.
2. Key Points
The Intel OMF-51 absolute object file generated by
the HI-TECH 8051 tools enables source-level debug
from the Silicon Labs IDE.
„ Once HI-TECH Tools are integrated into the IDE they
are called by simply pressing the ‘Assemble/Compile
Current File’ button or the ‘Build/Make Project’
button.
„ See the included software, AN140SW, for an
example using the HI-TECH tools.
„ Information in this application note applies to
Version 2.8 and later of the Silicon Labs IDE and
Version 9.01 and later of the HI-TECH 8051 Tools.
„
3. Create a Project in the Silicon
Labs IDE
A project is necessary in order to link assembly files
created by the compiler and build an absolute ‘OMF-51’
output file. Follow these steps to create a project:
1. Under the ‘Project’ menu, select ‘Add Files to
Project...’. Select the ‘C’ source files that you want to
add and click ‘Open’. Continue adding files until all
project files have been added.
4.1. Assembler Definition
1. Under the ‘Assembler’ tab, if the assembler
executable is not already defined, click the browse
button next to the ‘Executable:’ text box, and locate
the assembler executable. The default location for
the HI-TECH assembler is
“c:\HTSOFT\8051-C_9.01\BIN\C51.EXE”.
2. Enter the processor command line flag directly in the
‘Command Line Flags’ box. This flag designates
which processor the code will be running on. It takes
the form of '--Chip=C8051Fxxx' (For example, the
flag for the C8051F020 processor is
'--Chip=C8051F020').
3. Enter any additional command line flags directly in
the ‘Command Line Flags’ box.
4. See the following figure for the ‘Assembler’ tab with
the default HI-TECH settings and the
‘--Chip=C8051F020' flag.
2. To add files to the build process, right-click on the file
name in the ‘Project Window’ and select ‘Add
filename to build’.
3. Under the ‘Project’ menu, select ‘Save Project As...’.
Enter a project workspace name and click ‘Save’.
4. Configure the Tool Chain
Integration Dialog
Under the ‘Project’ menu select ‘Tool Chain Integration’
to bring up the dialog box shown below. First, select
‘Hi-Tech’ from the ‘Select Tool Vendor’ drop down list.
Rev. 1.3 1/07
Copyright © 2007 by Silicon Laboratories
AN140
AN140
4.2. Compiler Definition
1. Under the ‘Compiler’ tab, if the compiler executable
is not already defined, click the browse button next
to the ‘Executable:’ text box, and locate the compiler
executable. The default location for the HI-TECH
compiler is
“c:\HTSOFT\8051-C_9.01\BIN\C51.EXE”.
2. Enter the processor command line flag directly in the
‘Command Line Flags’ box. This flag designates
which processor the code will be running on. It takes
the form of '--Chip=C8051Fxxx' (For example, the
flag for the C8051F020 processor is
'--Chip=C8051F020').
3. Enter any additional command line flags directly in
the ‘Command Line Flags’ box.
4. See the following figure for the ‘Compiler’ tab with
the default HI-TECH settings and the
‘--Chip=C8051F020' flag.
5. Target Build Configuration
Under the ‘Project’ menu select ‘Target Build
Configuration’ to bring up the dialog box shown below.
4.3. Linker Definition
5.1. Output Filename
1. Under the ‘Linker’ tab, if the linker executable is not
already defined, click the browse button next to the
‘Executable:’ text box, and locate the linker
executable. The default location for the HI-TECH
linker is “c:\HTSOFT\8051-C_9.01\BIN\C51.EXE”.
To customize a default filename or to create a new
filename, click the browse button next to the ‘Absolute
OMF file name:’ edit box. Select a path and enter an
output filename with a ‘.omf’ extension (ex. blinky.omf ).
2. Enter the processor command line flag directly in the
‘Command Line Flags’ box. This flag designates
which processor the code will be running on. It takes
the form of '--Chip=C8051Fxxx' (For example, the
flag for the C8051F020 processor is
'--Chip=C8051F020').
3. Enter any additional command line flags directly in
the ‘Command line flags’ box.
4. See the following figure for the ‘Linker’ tab with the
default HI-TECH settings and the
‘--Chip=C8051F020’ flag.
2
5.2. Project Build Definition
Click the ‘Customize’ button to bring up the ‘Project
Build Definition’ window shown below. This window
allows selection of the files to be included in the build
process. Although, default assemble and compile
selections will be made, ensure that all files have been
correctly included in the build process. Under each tab,
add Files to assemble or compile by selecting the
desired file and clicking the ‘Add’ button. Files are
removed in the same manner.
Rev. 1.3
AN140
5.3. Additional Options
1. If the ‘Enable automatic save for project files before
build.’ box is checked, then all files included in the
project will be automatically saved when the ‘Build/
Make project’ button is pressed.
2. If the ‘Enable automatic connect/download after
build.’ box is checked, then the project will be
automatically downloaded to the target board when
the ‘Build/Make project’ button is pressed.
6. Building the Project
See the included software, AN140SW, for an example
file (blinky.c) created for use with the HI-TECH compiler.
1. After saving all files that have been edited, the
previous revisions will be saved in backup files.
Backups are saved as the name of the file with the
extension #1, #2, #3, and so on up to the number of
backups (N) created and available. ‘#1’ being the
most recent and ‘N’ being the least recent.
2. Click the ‘Assemble/Compile current file’ button to
compile just the current file.
3. Click the ‘Build/Make project’ button to compile and
link all the files in the project.
4. Review the errors and warnings generated during
the build process located in the ‘Build’ tab of the
Output window (typically found at the bottom of the
screen). Double-clicking on an error that is
associated with a line number will automatically
move the cursor to the proper line number in the
source file that generated the error.
Rev. 1.3
3
AN140
7. Source File Example
//-----------------------------------------------------------------------------------// Blinky.c
//-----------------------------------------------------------------------------------// Copyright (C) 2007 Silicon Laboratories, Inc.
//
// AUTH: JM
// DATE: 10 JUNE 03
// Description: This program flashes the green LED on the C8051F020 target board about
// five times a second using the interrupt handler for Timer3.
// Target: C8051F02x
//
// Tool chain: HI-TECH Evaluation 'C'
//
//-----------------------------------------------------------------------------------// Includes
//-----------------------------------------------------------------------------------#include "8051.h"
// SFR declarations
#include "intrpt.h"
// Interrupt declarations
//-----------------------------------------------------------------------------------// Global CONSTANTS
//-----------------------------------------------------------------------------------#define SYSCLK 2000000
// approximate SYSCLK frequency in Hz
static volatile bit LED @ 0x96;
// green LED: '1' = ON; '0' = OFF
//-----------------------------------------------------------------------------------// Function PROTOTYPES
//-----------------------------------------------------------------------------------void PORT_Init (void);
void Timer3_Init (int counts);
interrupt void Timer3_ISR (void);
//-----------------------------------------------------------------------------------// MAIN Routine
//-----------------------------------------------------------------------------------void main (void) {
ROM_VECTOR(TIMER3, Timer3_ISR);
//Interrupt vector TIMER3 (0x73) points to
//TIMER3_ISR for interrupt handling
// disable watchdog timer
WDTCN = 0xde;
WDTCN = 0xad;
PORT_Init ();
Timer3_Init (SYSCLK / 12 / 10);
// Init Timer3 to generate interrupts
// at a 10Hz rate.
EA = 1;
// Enable global interrupts
while (1) {
}
// spin forever
}
4
Rev. 1.3
AN140
//-----------------------------------------------------------------------------------// PORT_Init
//-----------------------------------------------------------------------------------//
// Configure the Crossbar and GPIO ports
//
void PORT_Init (void)
{
XBR2
= 0x40;
// Enable crossbar and weak pull-ups
P1MDOUT |= 0x40;
// enable P1.6 (LED) as push-pull output
}
//-----------------------------------------------------------------------------------// Timer3_Init
//-----------------------------------------------------------------------------------//
// Configure Timer3 to auto-reload and generate an interrupt at interval
// specified by <counts> using SYSCLK/12 as its time base.
//
void Timer3_Init (int counts)
{
TMR3CN = 0x00;
// Stop Timer3; Clear TF3;
// use SYSCLK/12 as timebase
TMR3RLL = -counts;
// Init reload values
TMR3RLH = -counts >> 8;
// Init reload values
TMR3L = 0xff;
TMR3H = 0xff;
// set to reload immediately
// set to reload immediately
EIE2
|= 0x01;
TMR3CN |= 0x04;
// enable Timer3 interrupts
// start Timer3
}
//-----------------------------------------------------------------------------------// Interrupt Service Routines
//-----------------------------------------------------------------------------------//-----------------------------------------------------------------------------------// Timer3_ISR
//-----------------------------------------------------------------------------------// This routine changes the state of the LED whenever Timer3 overflows.
//
interrupt void Timer3_ISR (void)
{
TMR3CN &= ~(0x80);
// clear TF3
LED = !(LED);
// change state of LED
}
Rev. 1.3
5
AN140
8. Include File Example
HI-TECH provides include files for several Silicon Labs device families with the installation of their tools. For any
8051 device you would use the 8051.h file, located by default in the “C:\HTSOFT\8051-C_9.01\include” directory.
When this file is included, the compiler will know which device-specific header file to include based on the
processor command line flag.
6
Rev. 1.3
AN140
DOCUMENT CHANGE LIST
Revision 1.2 to Revision 1.3
Paths updated to support HI-TECH tools Version 9.01.
Screenshots updated to support Silicon Labs IDE Version 2.8.
„ Reference to application note software updated from AN040SW to AN140SW.
„ Command line flag to specify the target device updated from -c8051F020 to --Chip=C8051F020.
„
„
Rev. 1.3
7
AN140
CONTACT INFORMATION
Silicon Laboratories Inc.
400 West Cesar Chavez
Austin, TX 78701
Tel: 1+(512) 416-8500
Fax: 1+(512) 416-9669
Toll Free: 1+(877) 444-3032
Email: [email protected]
Internet: www.silabs.com
The information in this document is believed to be accurate in all respects at the time of publication but is subject to change without notice.
Silicon Laboratories assumes no responsibility for errors and omissions, and disclaims responsibility for any consequences resulting from
the use of information included herein. Additionally, Silicon Laboratories assumes no responsibility for the functioning of undescribed features
or parameters. Silicon Laboratories reserves the right to make changes without further notice. Silicon Laboratories makes no warranty, representation 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 specifically disclaims any and all liability, including without limitation consequential or incidental damages. Silicon Laboratories products are not designed, intended, or authorized for use in applications intended to
support or sustain life, or for any other application in which the failure of the Silicon Laboratories product could create a situation where personal injury or death may occur. Should Buyer purchase or use Silicon Laboratories products for any such unintended or unauthorized application, Buyer shall indemnify and hold Silicon Laboratories harmless against all claims and damages.
Silicon Laboratories and Silicon Labs are trademarks of Silicon Laboratories Inc.
Other products or brandnames mentioned herein are trademarks or registered trademarks of their respective holders.
8
Rev. 1.3
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement