AP0806720 XC88x Cookery Book
AP0806720 XC88x Cookery Book
AP0806720 XC88x Cookery Book
0, August 2007
AP08067
XC886/XC888
XC888 Starter Kit "Cookery-Book" for a
"Hello world" application. You can do the
“Hello world” example in this document with
the evaluation version of the KEIL tool
chain.
Microcontrollers
Edition 2008-07-11
Published by
Infineon Technologies AG
81726 München, Germany
© Infineon Technologies AG 2008.
All Rights Reserved.
LEGAL DISCLAIMER
THE INFORMATION GIVEN IN THIS APPLICATION NOTE IS GIVEN AS A HINT FOR THE
IMPLEMENTATION OF THE INFINEON TECHNOLOGIES COMPONENT ONLY AND SHALL NOT BE
REGARDED AS ANY DESCRIPTION OR WARRANTY OF A CERTAIN FUNCTIONALITY, CONDITION OR
QUALITY OF THE INFINEON TECHNOLOGIES COMPONENT. THE RECIPIENT OF THIS APPLICATION
NOTE MUST VERIFY ANY FUNCTION DESCRIBED HEREIN IN THE REAL APPLICATION. INFINEON
TECHNOLOGIES HEREBY DISCLAIMS ANY AND ALL WARRANTIES AND LIABILITIES OF ANY KIND
(INCLUDING WITHOUT LIMITATION WARRANTIES OF NON-INFRINGEMENT OF INTELLECTUAL
PROPERTY RIGHTS OF ANY THIRD PARTY) WITH RESPECT TO ANY AND ALL INFORMATION GIVEN
IN THIS APPLICATION NOTE.
Information
For further information on technology, delivery terms and conditions and prices please contact your nearest
Infineon Technologies Office (www.infineon.com).
Warnings
Due to technical requirements components may contain dangerous substances. For information on the types
in question please contact your nearest Infineon Technologies Office.
Infineon Technologies Components may only be used in life-support devices or systems with the express
written approval of Infineon Technologies, if a failure of such components can reasonably be expected to
cause the failure of that life-support device or system, or to affect the safety or effectiveness of that device or
system. Life support devices or systems are intended to be implanted in the human body, or to support
and/or maintain and sustain and/or protect human life. If they fail, it is reasonable to assume that the health
of the user or other persons may be endangered.
AP08067
XC88x Starter Kit "Cookery-Book"
AP08048
Revision History: 2006-07 V2.0
Previous Version: none
Page Subjects (major changes since last revision)
Introduction:
With this step-by-step book you should be able to get your first useful program in less than 2 hours.
The purpose of this document is to gain know-how of the microcontroller and the tool-chain.
Additionally, the "hello-world-example" can easily be expanded to suit your needs.
You can connect either a part of - or your entire application to the Starter Kit Board.
You are also able to benchmark any of your algorithms to find out if the selected microcontroller
fulfils all the required functions within the time frame needed.
Note:
The style used in this document focuses on working through this material as fast and easily as
possible. That means there are full screenshots instead of dialog-window-screenshots; extensive use
of colours and page breaks; and listed source-code is not formatted to ease copy & paste.
The New
XC800-Family
Designed to Make the Difference
Note:
Just by comparing the different sources of block diagrams, you should be able
to get a complete picture of the product and to answer some of your initial questions.
“Cookery-book“
For your first programming example for the XC888 Starter Kit Board:
Your
program:
Chapter/
Step *** Recipes ***
Feedback
7.) Feedback
Ordering information:
Distribution Worldwide:
http://www.infineon.com/cms/en/corporate/company/location/index.html
Note:
Do not connect now!
This is just information! We are going to connect the board later!
Reason:
When the ULINK is already connected to the Starter Kit Board, the Starter Kit Board must be
supplied with power for the ULINK to work properly.
For the power supply we are going to use the USB cable – by connecting the USB cable a USB
driver is needed.
USB Cable [used for: UART communication (the RS232 serial interface is available via USB); the
USB connection works also as the power supply].
Note:
For further information, please refer to the XC888 Board Manual, V2.1, Sept 2006 .
1.)
Download the DAvE-update-file (.DIP) for the required microcontroller
@ http://www.infineon.com/DAvE
2.)
3.)
View
Setup Wizard
Default: • Installation
Forward>
Select: • I want to install products from the DAvE’s web site
Forward>
Select: D:\DAvE\XC888-2007-08-14
Forward>
Select: Available Products
click D XC888CLM
Forward>
Install
End
4.) DAvE is now ready to generate code for the XC888CLM microcontroller.
Start the program generator DAvE and select the XC888CLM microcontroller:
File
New
8-Bit Microcontrollers
select XC888CLM
Create
Choose the Project Settings as you can see in the following screenshots:
Note:
CPU clock is 24 MHz.
1
2
96 MHz
9,6
MHz 20
Note:
48 48
fSYS/4
24
24
9,6 96 24
48 24
24
48
Note:
fSYS = 96 MHz
CLKREL: The clock division factor fSYS/4 (see DAvE screenshot page 17) is inclusive the fixed
divider factor of 2.
*
*U
Note:
* = Interrupt Structure 2 applies to Timer 2, Timer 21, UART1, LIN, external interrupts 2 to 6,
ADC, SSC, CCU6, Flash, MDU, CORDIC and MultiCAN interrupt sources.
There is a slightly different behavior between MODE=0 and MODE=1 in setting/clearing the
pending interrupt request bit.
*U = If an interrupt node is shared with another interrupt node, the ISR code will be generated in
the SHARED_INT.C file.
Exit and Save this dialog now by clicking the close button:
Note:
The RS232 serial interface (UART pins P1.0 and P1.1) is available via the USB port which converts
the TTL-UART-signals to USB-signals
(using a SILICON LABS CP2102 ”Single-Chip USB To UART Bridge”).
USB port
Note:
Validate each alphanumeric entry by pressing ENTER.
Priority
Note:
For the serial communication with a terminal program running on your Personal-Computer the
printf-function is used. The printf-function uses Software-Polling-Mode therefore we do not need to
configure any interrupts.
Interrupt Priorities:
Interrupt Priority:
6 NMI
5 Interrupt Priority 3
4 Interrupt Priority 2
3 Interrupt Priority 1
2 Interrupt Priority 0
1 Main
Main refers to routines that run prior to any interrupt and can be interrupted by any interrupt.
Each interrupt source can be programmed to any of the four interrupt priorities (0-3).
An interrupt that is currently being serviced can only be interrupted by a higher-priority interrupt,
but not by another interrupt of the same or lower priority.
Hence, an interrupt of the highest priority cannot be interrupted by any other interrupt request.
In any case, the NMI always has the highest priority (above level 3) and its priority cannot be
programmed.
Note:
You can change function names (e.g. UART_vInit) and
file names (e.g. UART.C) anytime.
Exit and Save this dialog now by clicking the close button.
Note:
The LEDs on IO_Port_3 will be blinking (if selected in the main menu)
with a frequency of about 1 second (done in the Timer_0-Interrupt-Service-Routine).
Therefore we have to configure Timer_0.
Note:
We need 183 Timer_0 overflows to achieve an approximate 1 second delay.
This will be handled in the Timer_0 interrupt function.
183 * 5461,333 µs = 0,9994 s.
Priority
Interrupt of Timer_0
is enabled, ET0 = 1
Note:
Timer_0 has a dedicated interrupt vector address (000BH), interrupt node and its own interrupt
status flag TF0.
The vector is used to service the corresponding interrupt node request – when enabled (ET0=1),
which means: the interrupt system will hardware-generate an LCALL to the appropriate service
routine at 000BH.
TF0 will be automatically cleared by hardware (the core) once its pending interrupt request is
serviced.
The processor acknowledges an interrupt request by executing a hardware generated LCALL to the
appropriate service routine (interrupt vector address).
In some cases, hardware also clears the flag that generated the interrupt, while in other cases, the
flag must be cleared by the user’s software (e.g. see DAvE Source Code).
The hardware-generated LCALL pushes the contents of the Program Counter (PC) onto the stack
(but it does not save the PSW) and reloads the PC with an address that depends on the source of the
interrupt being vectored to (interrupt vector addresses see User’s Manual).
Program execution returns to the next instruction after calling the interrupt when the RETI
instruction is encountered. The RETI instruction informs the processor that the interrupt routine is
no longer in progress, then pops the two top bytes from the stack and reloads the PC.
Execution of the interrupted program continues from the point where it was stopped.
Note that the RETI instruction is important because it informs the processor that the program has
left the current interrupt priority level.
A simple RET instruction would also have returned execution to the interrupted program, but it
would have left the interrupt control system on the assumption that an interrupt was still in progress.
In this case, no interrupt of the same or lower priority level would be acknowledged.
Note:
The LEDs are connected to IO_Port_3.
Port 3: Port Function: click 9 Use P3.0 as general IO - Port Direction: click ~ Out
Port 3: Port Function: click 9 Use P3.1 as general IO - Port Direction: click ~ Out
Port 3: Port Function: click 9 Use P3.2 as general IO - Port Direction: click ~ Out
Port 3: Port Function: click 9 Use P3.3 as general IO - Port Direction: click ~ Out
Port 3: Port Function: click 9 Use P3.4 as general IO - Port Direction: click ~ Out
Port 3: Port Function: click 9 Use P3.5 as general IO - Port Direction: click ~ Out
Port 3: Port Function: click 9 Use P3.6 as general IO - Port Direction: click ~ Out
Port 3: Port Function: click 9 Use P3.7 as general IO - Port Direction: click ~ Out
File
Save
Save
Generate Code:
File or click
Generate Code
File - Exit
Save changes?
click Yes
Application Note 44 V2.0, 2007-08
AP08067
XC88x Starter Kit "Cookery-Book"
Open
Target: click/check 9 Use On-chip ROM & Target: click/check 9 Use On-chip XRAM
In general, the lower address spaces (6000H – 6FFFH and 7000H – 7FFFH) should be
used for D-Flash bank(s) contents that are intended to be used as program code.
Alternatively, the higher address spaces (A000H – AFFFH and B000H – BFFFH) should
be used for D-Flash bank(s) contents that are intended to be used as data.
Note:
The HEX-File could be used while working with the program
XC800_FLOAD for OnChip-Flash-Programming
via RS232-interface [Bootstrap Loader (BSL) Mode via UART].
Note:
With the cod-file you can do the following:
1.) position the mouse on the source code you are interested in
2.) click right mouse button and select Open Linker COD File
3.) see the result: Assembler-Code of your C-Source-Code
Note:
First we are going to use the simulator.
Utilities: Configure Flash Menu Command: click ~ Use Target Driver for Flash Programming,
Select: Infineon XC800 ULINK Driver
Note:
For OnChipFlashProgramming and OCDS-Debugging we are going to use the ULINK (“Keil-
ULINK-JTAG-Interface”).
Note:
For OnChipFlashProgramming and OCDS-Debugging the Infineon-USB-JTAG-Wiggler-Box could
be used instead of the Keil-ULINK-JTAG-Interface.
For the Infineon USB-JTAG-Wiggler-Box the Infineon DAS Client for XC800 must be selected:
For OnChipFlashProgramming via UART the program XC800_FLOAD.EXE could be used instead
of the Keil-ULINK-JTAG-Interface or the Infineon-USB-JTAG-Wiggler-Box.
For more information, please see your Starter Kit CD.
OK
OK
Note:
To make the ULINK work properly,
the XC888 Evaluation Board must be supplied with power.
We are going to do this in chapter 6.
Note:
DAvE doesn’t change code which is inserted between ‘// USER CODE BEGIN’ and ‘//
USER CODE END’. Therefore, whenever adding code to DAvE’s generated code, write it
between ‘// USER CODE BEGIN’ and ‘// USER CODE END’.
If you wish to change DAvE´s generated code or add code outside these ‘USER CODE’
sections you will have to insert/modify your changes each time after letting DAvE
regenerate code!
Double click MAIN.C and insert the following code in the main function:
P3_DATA=LED_OFF;
while(RS232_wait);
Double click MAIN.C and insert the following code in the main function into the while(1) loop:
printf(menu);
select=input();
switch (select)
{
case '1': blinking=OFF; P3_DATA=LED_ON, printf(message1); break;
case '2': blinking=OFF; P3_DATA=LED_OFF, printf(message2); break;
case '3': blinking=ON, printf(message3); break;
}
#define OFF 0
#define ON 1
#define LED_ON 0xFF
#define LED_OFF 0x00
#include <stdio.h>
#include <ctype.h>
TI=1;
++ Timer_0_interrupt_counter;
if(RS232_wait)
RS232_wait--; // 183 * Timer_0-overflow = 183 * 5461,333 µs = 0,9994
Project
Close Project
File
Exit
5.) Using the Simulator (first we will test our program with the Keil Simulator):
Open
Note:
From now on just open your µVision project (not the DAvE project).
µVision will automatically recognise if there has been a code regeneration done by DAvE!
OK
or click
Debug - Start/Stop Debug Session
OK
Start program-execution:
Debug – Run
View - Serial Window – UART #0
Peripherals - I/O-Ports – Port3
Peripherals – Timer – Timer0
Note:
By activating (clicking) the UART #0-window you can then type
1, 2 or 3 and see the result in the Parallel-Port-3-window.
File – Exit
Note:
Since our program runs as expected in the simulator we can now use real hardware.
Using ULINK [used for: OnChipFlash-Programming and Debugging (using the JTAG interface)]:
Connect the USB Cable (the RS232 serial interface is available via USB; the USB connection
works also as the power supply):
Note:
A USB driver is needed the first time while connecting the Starter Kit Board via the USB cable with
your computer.
Therefore a pop-up window might appear to prompt for a driver:
If so, please insert the XC88x Starter Kit CD check ; CD-ROM drives and click Next
Or select the USB driver from the directory SK88xCLM_CDV3_1\Driver of your XC88x Starter
Kit CD:
Note:
Skip this step when the USB driver is auto-detected and auto-installed.
Note:
A default COM Port is generated after the USB driver is installed.
Using a Windows 2000 operating system, we are now going to search for the COM Port which was
generated after connecting our XC888 Evaluation Board:
Device Manager:
COM16
Note:
As we can see in the screenshot above:
our COM Port for UART/RS232 communication with the Starter Kit Board via USB is COM16 !
Additional information:
Using a SILICON LABS CP2102 ”Single-Chip USB To UART Bridge”:
Note:
IC2 soldered on the XC888 Starter Kit is a Silicon Labs CP2102 chip (Single-Chip USB To UART
Bridge) using Virtual COM Port Device Drivers.
Using Virtual COM Port drivers, the data format and baud rate are set during COM port
configuration on the PC.
Supported Data Formats and Baud Rates (Source: CP2102 Data Sheet):
The CP2102 Virtual COM Port (VCP) device drivers allow a CP2102-based device to appear as a
COM port to the PC’s application software.
The application software (e.g. Docklight) running on the PC accesses the CP2102-based device as it
would access a standard hardware COM port.
Every CP2102 device is delivered with a unique Serial Number making it possible to use more than
one XC888 Starter Kit at the same time.
That means every Starter Kit gets its own Virtual COM Port.
Note:
For further information, please refer to the XC888 Board Manual, V2.1, Sept 2006 .
For further information, please refer to the SILICON LABS CP2102 Datasheet .
Open
1
OK
OK
Note:
1: When the ULINK is already connected to the XC888 Starter Kit Board,
the Starter Kit Board must be supplied with power for the ULINK to work properly.
If the power supply is not connected to the Board,
you will see no information in the JTAG Device Chain window.
Note:
Now we need a terminal program which is able to handle COM16!
As an example of “any terminal program” we are going to use Docklight.
Docklight can be downloaded @ http://www.docklight.de .
Project Settings:
Communication: Communication Mode: click ~ Send/Receive
Project Settings:
Communication: Communication Mode: Send/Receive on comm. channel: select COM16
Project Settings: Communication: COM Port Settings: Baud Rate: select 9600
Project Settings: Communication: COM Port Settings: Parity: select None
Project Settings: Communication: COM Port Settings: Parity Error Char.: select (ignore)
Project Settings: Communication: COM Port Settings: Data Bits: select 8
Project Settings: Communication: COM Port Settings: Stop Bits: select 1
Project Settings:
Communication Filter: Contents Filter: click ~ Show all original communication data
OK
Click:
Note:
Docklight is now ready for serial communication!
Go back to µVision:
OK
OK
OK
Click LEDs ON or click LEDs OFF or click LEDs BLINKING and check the
result on your Evaluation Board:
Conclusion:
In this step-by-step book you have learned how to use the XC888 board together with the Keil tool
chain.
Now you can easily expand our ”hello world” program to suit your needs!
You can connect either a part of - or your entire application to the Starter Kit Board.
You are also able to benchmark any of your algorithms to find out if the selected microcontroller
fulfils all the required functions within the time frame needed.
Note:
There are step-by-step books for 8 bit microcontrollers (e.g. XC866 and XC88x), 16 bit
microcontrollers (e.g. C16x and XC16x) and 32 bit microcontrollers (e.g. TC1796 and TC1130).
All these step-by-step books use the same microcontroller resources and the same example code.
This means: configuration-steps, function-names and variable-names are identical.
This should give you a good opportunity to get in touch with another Infineon microcontroller
family or tool chain!
There are even more programming examples using the same style available [e.g. ADC-examples,
CAPCOM6-examples (e.g. BLDC-Motor, playing music), Simulator-examples, C++ examples]
based on these step-by-step books.
Contact Details (this section may remain blank should you wish to offer
feedback anonymously):
______________________________________________________
______________________________________________________
______________________________________________________
If you have any suggestions please send this sheet back to:
email: [email protected]
FAX: +43 (0) 4242 3020 5783
Your suggestions:
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________