This section describes the necessary compiler toolchain setup based on the Keil µVision IDE.
Device
It is critical for device flashing and programming to select the correct version of the µC. This dialogue also allows you to select the extended linker and assembler. Doing so is imperative to perform the necessary link time optimisations to fit the libraries into the limited memory of the device.
Keil µVision Device options dialogue
Target
The target dialogue lets you select several CPU architecture and memory layout settings.
The following options need to be set:
- Xtal (MHz):
- This needs to be set to your external oscillator frequency, otherwise flashing and debugging might be unreliable
- Memory Model: Small
- This setting means that variables are by default assigned to the first 128 bytes of directly addressable RAM, variables can still be mapped to different memory sections manaully as described in Memory Limitations
- Code ROM Size: Large: 64K program
- This setting allows up to 64k of program data to be written to the device
- Use On-chip ROM
- Use On-chip XRAM
- Use multiple DPTR registers
- This allows the compiler to reduce address writes of reoccuring pointer targets by using multiple pointer registers
- Safe address extension SFR in interrupts
- XRAM/xdata access is not atomic. Thus interrupts using XRAM can interrupt and corrupt XRAM access of functions. This setting preserves the XRAM address registers and thus protects them from corruption
Keil µVision Target options dialogue
C51
The C51 is the C compiler configuration dialogue. The following settings are not obligatory for use of the HSK libraries, but recommended.
- Preprocessor Symbols
- Define:
__xdata
, __pdata
, __idata
- This input field allows passing on preprocessor definitions to the preprocessor
- The empty
__xdata
, __pdata
, __idata
defines allow C51 to ignore SDCC style memory assignments, this is useful to make such assignments where C51 does not support them
- Code Optimization
- Level: 11: Reuse Common Exit Code
- The highest level of optimisation, allowing the compiler the largest reduction of memory use
- Select
4
or lower for debugging, all the common code eliminations prevent the debugger from mapping large chunks of C code to assembler code, making the program flow difficult to follow
- Emphasis: Favor speed
- Surprisingly this often produces smaller code than the
favor size
setting
- Global Register Coloring
- This setting allows the compiler to optimise register use throughout the entire application, reducing memory use and improving performance
- Linker Code Packing
- Activates a link time optimisation, after linking the application, the linker will replace long distance jumps with short jumps where applicable
- Warnings: Warninglevel 2
- Enable ANSI integer promotion rules
Keil µVision C51 options dialogue
LX51 Locate
LX51 is the extended linker of the C51 compiler tool chain, the Locate dialogue is used to map memory ranges. The form can also be used to assign portions of code to fixed addresses.
- User Memory Layout from Target Dialog
- This option assigns the XC878 memory types to the appropriate address ranges
- User Classes: PDATA (X:0xF000-X:0xF0FF)
- This option maps the
pdata
memory into the first 256 bytes of xdata
Keil µVision LX51 Locate options dialogue
LX51 Misc
The Misc dialogue holds the remaining linker settings.
- Overlay
- This field can be used to add calls through function pointers to the call tree as is necessary for callback functions, the syntax is described in the µVision Help section OVERLAY Linker Directive
- Manually filling this field can be avoided by running the
uVisionupdate
.sh script
- Misc controls: REMOVEUNUSED
- This linker flag saves memory by discarding unused functions
Keil µVision LX51 Misc options dialogue
Inline Assembler
Inline assembler has to be activated for Groups or single files individually. The Group Options can be found in the context menu of a Group.
To activate an option in this menu it needs to be unchecked and checked again.
- Generate Assembler SRC File
- This option causes the compiler to generate assembler code instead of an object file
- Assemble SRC File
- This option causes the compiler to assemble the generated assembler code
Keil µVision Group options dialogue
Device Programming and Debugging
To program or debug the device via On Chip Debug Support (OCDS) the Infineon Direct Access Server (DAS), a hardware access middleware, is required. The programming and debugging options can also be selected from the target options. Use the following settings in the Utilities tab:
- Use Target Driver for Flash Programming
- Infineon DAS Client for XC800
Keil µVision LX51 Utilities options dialogue
- See also
- Infineon DAS Tool Interface website: http://www.infineon.com/das/
Select Settings
to enter the "Infineon XC800 DAS Driver Setup". The default options are mostly fine. Make sure of the following options:
- DAS Server: UDAS
- Target Debug Options
- Miscellaneous Options
- Disable Interrupts during Steps
- Frequently occuring interrupts like timer interrupts make step by step debugging completely useless
Keil µVision Infineon XC800 DAS Driver Setup
The Debug tab of the target options can be used to choose between in-simulator debugging and on-chip debugging.