TC1766 Starter Kit: "Cookery Book" for a hello world application using Altium's TASKING classic TriCore™ toolset

Application Note, V2.0, October 2008
AP32133
TC1766
TC1766 Starter Kit: "Cookery Book" for a
hello world application using Altium’s
TASKING TriCore toolset
Microcontrollers
Edition 2008-11-14
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.
AP32133
TC1766 "Cookery Book" for a hello world application
AP32110
Revision History:
Previous Version:
Page
2008-10
none
Subjects (major changes since last revision)
V2.0
We Listen to Your Comments
Any information within this document that you feel is wrong, unclear or missing at all?
Your feedback will help us to continuously improve the quality of this document.
Please send your proposal (including a reference to this document) to:
[email protected]
Application Note
3
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Table of Contents
Page
Note: Table of Contents see page 10.
Introduction:
This “Application Note” / “Appnote” is a Hands-On Training / Cookery Book / step-by-step book.
It will help inexperienced users to get the TC1766 / TC176x / TC116x Family Starter Kit up and
running.
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 TC1766 Starter Kit.
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.
Have fun and enjoy TriCore!
Application Note
4
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Application Note
5
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
TC1766 Block Diagram (Source: Product Marketing)
Application Note
6
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
TC1766 Block Diagram (Source: Product Sheet)
Application Note
7
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
TC1766 Block Diagram (Source: User’s Manual)
Application Note
8
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
TC1766 Block Diagram (Source: DAvE)
Note:
Just by comparing the different sources of block diagrams, you should be able to get a complete
picture of the TC1766 microcontroller and to answer some of your initial questions.
Application Note
9
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
“Cookery Book“
For your first programming example for the TC1766 Starter Kit Board:
Your
program:
Chapter/
Step:
1.)
*** Recipes ***
TC1766 Board
Power Supply, Jumper Setting, Serial cable to the notebook, pls-Debugger
2.)
DAvE – program generator
DAvE installation (mothersystem) + DAvE Update-installation for TC1766 (DIP-file)
3.)
Using DAvE
Microcontroller initialization for your programming example
4.)
Using the TASKING Development Tools (C/C++/EC++ Compiler)
Programming of your application with Altium’s TASKING TriCore tool chain (EDE) - v2.3r1
Locating programs into the 1,5 MByte OnChipProgramFlash (PFLASH), using OnChipSRAM)
5.)
Using the pls Debugger
Using the pls Debugger to download (program into Flash) and run your program
Feedback
6.)
Feedback
Application Note
10
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
1.) TC1766 Starter Kit Board:
Application Note
11
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Screenshot of the TC1766 Starter Kit homepage:
http://www.infineon.com/cms/en/product/channel.html?channel=db3a304312dc768d0112e71c6215
0b30
Application Note
12
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Connecting the TC1766 Starter Kit:
1. Connect a Power Supply:
The TC1766 Board requires an external power supply.
A (un)regulated DC power supply from 5,5 to 60 Volts can be connected to the power connector.
500 mA are sufficient for the TC1766 Starter Kit.
2. Connect a RS-232 Serial Cable
(1:1; 9-pin Sub-D plug – 9-pin Sub-D connector; the “Hello World” example uses this interface):
3. Connect the pls-Debugger (Flash-Programming und Debugging):
For further information, please refer to the TriBoard TC176X User’s Manual,V1.0, June 2005.
Application Note
13
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Jumper Settings (Jumper JP501):
Source: TriBoard TC176X User’s Manual, V1.0, June 2005
pls-Debugger
Jumper JP501
1-2 … Enable On-Board Wiggler (use parallel-on-board-interface)
2-3 … Disable On-Board Wiggler (use pls-Debugger)
pls-Debugger
pls-Debugger (see next page)
Application Note
14
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Jumper JP501
1-2 … Enable On-Board Wiggler (use parallel-on-board-interface)
2-3 … Disable On-Board Wiggler (use pls-Debugger)
pls-Debugger
pls-Debugger
Application Note
15
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
TC1766 Execution-Environment = OnChipFlash:
Jumper Settings (HW-Configuration DIP-Switch):
HW Configuration DIP-Switch:
1, 3, 4, 6 : ON
2, 5, 7, 8 : OFF
Application Note
16
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
TC1766 Execution-Environment = OnChipFlash:
Application Note
17
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Accessories for the TC1766 Starter Kit: Extension Boards
“TriBoard+XC16x-Adapter-Board” to have access to all microcontroller pins.
Stencils are available with the Board
Ordering information:
Name: TriBoard+XC16x-Adapter-Platine.
The price is approximately € 32 per extension board (3 required).
Purpose: extension boards are used for easy measuring of the signals on the extension connectors
to have access to all microcontroller pins and/or to connect either a part of – or the entire
application to the TC1766 Starter Kit.
You can order them at:
TQ Components GmbH
Schulstraße 29a
D-82234 Weßling
Deutschland
T: +49-8153-9308-161
Mr. Rolf Müller
Application Note
18
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
stencil
stencil
Application Note
stencil
19
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
2.) DAvE – Installation for TC1766 microcontrollers:
Install DAvE (mothersystem):
Download the DAvE mothersystem setup.exe @ http://www.infineon.com/DAvE
and execute setup.exe to install DAvE .
Note:
Abort the installation of Acrobat Reader.
Application Note
20
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Install the TC1766 microcontroller support/update (TC1766 DIP file):
1.)
Download the DAvE-update-file (.DIP) for the required microcontroller
@ http://www.infineon.com/DAvE
Unzip the zip-file “TC176x_series_v1.0.zip” and save “ TC176x_Series.dip “
@ e.g. D:\DAvE\TC1766\ TC176x_Series.dip.
Application Note
21
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
2.)
Start DAvE - ( click
)
3.)
View
Setup Wizard
Default: • Installation
Forward>
Select: • I want to install products from the DAvE’s web site
Forward>
Select: D:\DAvE\TC1766
Forward>
Select: Available Products
click D TC176x_Series
Forward>
Install
End
4.) DAvE is now ready to generate code for the TC1766 microcontroller.
Application Note
22
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
3.) DAvE - Microcontroller Initialization after Power-On:
Start the program generator DAvE and select the TC1766 microcontroller:
File
New
32-Bit Microcontrollers
TC1766
Create
Application Note
23
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Choose the Project Settings as you can see in the screenshots:
General: Compiler Settings:
For the Tasking Compiler check/choose
Application Note
Tasking in the Compiler Settings:
24
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
System Clock: CPU Clock will be 80 MHz:
System Clock: External Clock Frequency: External clock frequency check/insert 15 [MHz]
Note:
We strongly suggest that you check first to see if your board is equipped with a 15 MHz Crystal
(default).
Note:
The final result should be 80 MHz CPU Clock and 80 MHz System Clock
Application Note
25
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Interrupt System: CPU Global Interrupt Enable: tick
Application Note
26
Enable globally the interrupt system (IE)
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
PCP System: (do nothing)
Application Note
27
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Pad Driver: (do nothing)
Application Note
28
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Startup Configuration: Hardware Booting Scheme: Boot type (external pins CFG[3:0])
select Normal Internal Start. Jump to internal flash (CFG[3:0] = 0010)
Note:
Application Note
29
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Notes: If you wish, you can insert your comments here.
Exit and Save this dialog now by clicking
Application Note
the close button:
30
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Configuration of the ASC0:
The configuration window/dialog can be opened by clicking the specific block/module.
Note:
ASC0 is used for the serial communication with a terminal program running on your host computer.
Application Note
31
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Module Clock: Module Disable Request: untick
Disable the ASC0 module
Module Clock: Module Run Mode Clock Control: choose System clock/1 (=80,0000 MHz)
Module Clock: Sleep Mode Enable Control: tick Disable the sleep mode
Application Note
32
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Pin Selection: Alternate Pin Selection: click Configure pins ASC0_RXD0 and ASC0_TXD0
Application Note
33
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Pin Selection: Alternate Pin Selection: Configure pins ASC0_RXD0 and ASC0_TXD0:
ASC0_RXD0: ASC0_RXD0 Pin Selection: click Use pin P3.0 as ASC0 receive input signal
Pin Selection: Alternate Pin Selection: Configure pins ASC0_RXD0 and ASC0_TXD0:
ASC0_RXD0: Pull Device: P3.0 pull device: select Tristate
Application Note
34
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Pin Selection: Alternate Pin Selection: Configure pins ASC0_RXD0 and ASC0_TXD0:
ASC0_TXD0: ASC0_TXD0 Pin Selection: click Use pin P3.1 as ASC0 output signal
Exit and Save this dialog now by clicking
Application Note
the close button.
35
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Control: Receiver Enable: tick
Application Note
Enable receiver (REN)
36
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Baud Rate: Baud Rate: Required baud rate [kBaud] insert 9,600 < ENTER >
Baud Rate: Baud Rate Selection Bit / Fractional Divider: tick Use fractional divider
Note:
Validate each alpha numeric entry by pressing ENTER.
Application Note
37
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Interrupts: (do nothing)
Note:
For the serial communication with a terminal program running on your host computer the myprintf
function is used. The myprintf function uses Software-Polling-Mode therefore we do not need to
configure any interrupts for this task.
Application Note
38
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Functions: Initialization Function: tick ASC0_vInit
Functions: Function Library (Part 1): tick ASC0_vSendData
Functions: Function Library (Part 1): tick ASC0_usGetData
Functions: Function Library (Part 1): tick ASC0_ubTxBufFree
Note:
You can change function names (e.g. ASC0_vInit) and
file names (e.g. ASC0.c) anytime.
Application Note
39
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Parameters: (do nothing)
Notes: If you wish, you can insert your comments here.
Exit and Save this dialog now by clicking
Application Note
the close button.
40
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Configuration of the STM:
The configuration window/dialog can be opened by clicking the specific block/module.
Note:
The LED on Port_1 Pin_0 will blink (after program start and if selected in the main menu)
at a frequency of 1 second (done in the STM-Interrupt-Service-Routine).
Therefore we now have to configure the STM.
Application Note
41
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Module Clock: Sleep Mode Enable Control: tick
Disable the sleep mode for the STM module
Module Clock: Module Run Mode Clock Control: Clock divider for normal operation mode:
select System clock / 4 ( = 50 ns)
Application Note
42
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Resolutions: (do nothing)
Application Note
43
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
CMP0: Compare Register Size of CMP0: Number of bits for compare: insert 25 <ENTER>
CMP0: Compare Register 0: Required compare value (CMP0): insert 20000000 <ENTER>
Note:
20.000.000 * 50 ns = 1 s
Application Note
44
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
CMP1: (do nothing)
Application Note
45
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Interrupt Control: Compare Register CMP0 Interrupt Control:
tick Enable request on compare match with CMP0
Interrupt Control: Interrupt Control of STMIR0: tick
Application Note
46
Enable SRC0 interrupt
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Interrupts: drag and drop STM SRN 0 from Level 0 to CPU Interrupt: Level 9
Note:
The LED on Port_1 Pin_0 will blink (after program start and if selected in the main menu)
at a frequency of 1 second (done in the STM-Interrupt-Service-Routine STM_viSRN0).
Application Note
47
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Functions: Initialization Function: tick
STM_vInit
Note:
The LED on Port_1 Pin_0 will blink (after program start and if selected in the main menu)
at a frequency of 1 second (done in the STM-Interrupt-Service-Routine STM_viSRN0).
Application Note
48
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Parameters: (do nothing)
Notes: If you wish, you can insert your comments here.
Exit and Save this dialog now by clicking
Application Note
the close button.
49
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Port Configuration:
The configuration window/dialog can be opened by clicking the specific block/module.
Note:
The User LED (orange) is
connected to Port_1 Pin_0.
Application Note
50
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Ports: click Configure Port 1
Application Note
51
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Ports: Configure Port 1:
Port 1: Functionality: tick
Application Note
Use P1.0 as general IO, General Direction: click
52
Out
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Input Characteristic: (do nothing)
Application Note
53
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Output Characteristic: (do nothing)
Application Note
54
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Parameters: (do nothing)
Notes: If you wish, you can insert your comments here.
Exit and Save this dialog now by clicking
Application Note
the close button.
55
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Functions: Initialization Function: tick IO_vInit
Functions: Function Library (Part 1): tick IO_vSetPin
Functions: Function Library (Part 1): tick IO_vResetPin
Functions: Function Library (Part 1): tick IO_vTogglePin
Application Note
56
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Parameters : (do nothing)
Notes: If you wish, you can insert your comments here.
Exit and Save this dialog now by clicking
Application Note
the close button.
57
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Save the project:
File
Save
Save project: Save in C:\TC1766 [ create new directory
File name: TC1766 (2)
(1) ]
1
2
Save
Application Note
58
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Generate Code:
File
Generate Code
or
click
DAvE will show you all the files he has generated
(File Viewer opens automatically).
Application Note
59
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Application Note
60
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Close DAvE:
File
Exit
Save changes?
click
Yes
Application Note
61
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
4.) Using the TASKING - EDE Development Tools:
Write programs for execution from OnChipFlash (PFLASH)
Application Note
62
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Install the Tasking Development Tools TriCore v2.3r1
Start Tasking EDE, select directory and include the DAvE Files:
If you see an open project – close it: File – Close Project Space
Application Note
63
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
File - Change Directory…
Select a Directory: choose C:\TC1766
OK
Application Note
64
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
File - New Project Space…
Create a New Project Space: Filename: insert TC1766
OK
Application Note
65
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Click:
“Add new project to project space”
Application Note
66
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Add New Project to Project Space: Filename: insert TC1766
OK
Application Note
67
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Click:
“Add existing files to project”
Application Note
68
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Select One or More Files to Add to Project: select ASC0.c
Select One or More Files to Add to Project: select ASC0.h
Select One or More Files to Add to Project: select IO.c
Select One or More Files to Add to Project: select IO.h
Select One or More Files to Add to Project: select MAIN.c
Select One or More Files to Add to Project: select MAIN.h
Select One or More Files to Add to Project: select STM.c
Select One or More Files to Add to Project: select STM.h
Select One or More Files to Add to Project: select TC1766Regs.h
Open
Application Note
69
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
OK
Application Note
70
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Application Note
71
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Configure Compiler, Assembler, Linker, Locater and Build – Control:
Project – Project Options
Processor: Processor Definition: Target processor: select TC1766B
Application Note
72
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Processor: Bypasses: CPU Functional Problem Bypasses:
tick All bypasses TC1762/TC1764/TC1766
Application Note
73
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Processor: Startup: (do nothing)
Application Note
74
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Processor: Startup: Startup Code: (do nothing)
Application Note
75
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Processor: Startup: Startup Code: Trap Vectors: (do nothing)
Application Note
76
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
C Compiler: Preprocessing: deactivate (click to untick)
Application Note
77
Automatic inclusion of .sfr file
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
C Compiler: Language: (do nothing)
Application Note
78
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
C Compiler: Debug Information: (do nothing)
Application Note
79
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
C Compiler: Code Generation: (do nothing)
Application Note
80
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
C Compiler: Optimization: Optimization level: select No optimization
Application Note
81
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
C Compiler: Allocation: (do nothing)
Application Note
82
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
C Compiler: Warnings: (do nothing)
Application Note
83
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
C Compiler: MISRA-C: (do nothing)
Application Note
84
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
C Compiler: Miscellaneous: (do nothing)
Application Note
85
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: (do nothing)
Application Note
86
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Output Format: (do nothing)
Application Note
87
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Script File: (do nothing)
Application Note
88
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Script File: Special Areas: RESET start address: insert 0xA0000000 (PFLASH)
Linker: Script File: Special Areas: Libraries start address: insert 0xA0080000 (PFLASH)
Linker: Script File: Special Areas: Interrupt table start address: insert 0xA0100000 (PFLASH)
Linker: Script File: Special Areas: Trap table start address: insert 0xA0102000 (PFLASH)
Linker: Script File: Special Areas: CSA start address: insert/check 0xD0000000 (LDRAM)
PMU_PFLASH
PMU_PFLASH
PMU_PFLASH
PMU_PFLASH
DMI_LDRAM
Application Note
89
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Additional information: Program Memory / Data Memory:
The On Chip PMU_PFLASH memory has a capacity of 1.504 KBytes:
The On Chip DMI_LDRAM memory has a capacity of 56 KBytes.
DMI_LDRAM
PMU_PFLASH
Application Note
90
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Application Note
91
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Additional information: Interrupt Vector Table:
Remember:
Application Note
92
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Additional information: Interrupt Vector Table:
Interrupt Vector Table:
Note:
PN … Priority Number (CPU Interrupt Level)
Note:
Click here to see the Map File
Application Note
93
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Additional information: TRAP Vector Table:
TRAP Vector Table:
Note:
1 Word = 32 Bits
1 Word = 4 Bytes
8 Words = 32 Bytes
Note:
Click here to see the Map File
Application Note
94
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Additional information: Program Memory (Source: User’s Manual):
The on-chip PMU_PFLASH memory has a capacity of 1.504 KBytes:
Application Note
95
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Additional information: Program Memory (Source: User’s Manual):
The on-chip PMU_PFLASH memory has a capacity of 1.504 KBytes:
Application Note
96
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Additional information: Program Memory (Source: User’s Manual):
The on-chip PMU_PFLASH memory has a capacity of 1.504 KBytes:
Application Note
97
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Additional information: Program Memory (Source: User’s Manual):
The on-chip PMU_PFLASH memory has a capacity of 1.504 KBytes:
Note:
There is a typing error in Table 8-2, page 8-6, TC1766 User’s Manual, System Units (Vol. 1 of 2).
The correct address range for the 1.504 Kbyte PMU_PFLASH is A000 0000H - A017 7FFFH.
Application Note
98
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Script File: Defines/Stack/Heap: (do nothing)
Application Note
99
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Script File: Internal Memory: change from brom to PMU_BROM
(
)
Linker: Script File: Internal Memory: change from ovram to PMU_OVRAM (
)
Linker: Script File: Internal Memory: change from ldram to DMI_LDRAM (
)
Linker: Script File: Internal Memory: change from spram to PMI_SPRAM
(
)
Linker: Script File: Internal Memory: change from pram to PCP_PRAM
(
)
Linker: Script File: Internal Memory: change from pcode to PCP_CMEM
(
)
Application Note
100
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Script File: Internal Memory: Name: insert PMU_PFLASH
Linker: Script File: Internal Memory: Alloc: select ON
Linker: Script File: Internal Memory: Type: select ROM
Linker: Script File: Internal Memory: Size: insert 1504k
Linker: Script File: Internal Memory: Address insert 0xA0000000
Application Note
101
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Script File: Internal Memory: Name=PCP_PRAM: Alloc: select OFF
Linker: Script File: Internal Memory: Name=PCP_CMEM: Alloc: select OFF
Application Note
102
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Additional information: Memory (Source: User’s Manual):
Application Note
103
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Script File: External Memory: (do nothing)
Application Note
104
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Script File: Sections: (do nothing)
Application Note
105
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Script File: Output Sections: (do nothing)
Application Note
106
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Script File: Reserved: (do nothing)
Application Note
107
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Map File: tick
Memory usage info
Note:
Click here to see Memory usage info
Application Note
108
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Script File: Libraries: (do nothing)
Application Note
109
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Script File: Optimization: (do nothing)
Application Note
110
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Script File: Warnings: (do nothing)
Application Note
111
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Linker: Script File: Miscellaneous: (do nothing)
OK
Application Note
112
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Insert your application specific program:
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!
Application Note
113
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Double click: Main.c insert User Code (Global Variables):
const char menu[] =
"\n\n\n\n"
"TC1766, Program execution out of OnChipFlash:\n"
"=============================================\n"
"1 ... LED IO_Port_1_Pin_0 ON\n"
"2 ... LED IO_Port_1_Pin_0 OFF\n"
"3 ... LED IO_Port_1_Pin_0 blinking\n"
"
\n";
const char question[] =
"your choice: ";
const char message1[] =
"\n\r*** LED is ON ***\r\n";
const char message2[] =
"\n\r*** LED is OFF ***\r\n";
const char message3[] =
"\n\r*** LED is BLINKING ***\r\n";
volatile int RS232_wait=2;
volatile unsigned int blinking=ON;
char select=' ';
Application Note
114
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Application Note
115
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Double click: Main.c insert User Code (function: input()):
char input (void)
{
char in=' ';
do
{
myprintf(question);
// ASC0_RSRC_SRR ... ASC0_Receive Interrupt Service Request Control Register_Service Request Flag
// ASC0_RSRC_CLRR ... ASC0_Receive Interrupt Service Request Control Register_Request Clear Bit
while (!ASC0_RSRC_SRR) ;
// Clear SRR bit
ASC0_RSRC_CLRR=1;
in = (unsigned char)ASC0_RBUF;
}while (in!='1' && in!= '2' && in != '3');
return in;
}
Application Note
116
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Double click: Main.c insert User Code:
while(RS232_wait);
while (1)
{
myprintf(menu);
select=input();
switch (select)
{
case '1': blinking=OFF, IO_P1_0=LED_ON, myprintf(message1); break;
case '2': blinking=OFF, IO_P1_0=LED_OFF, myprintf(message2); break;
case '3': blinking=ON, myprintf(message3); break;
}
}
Application Note
117
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Double click: Main.h and insert the following Defines:
#define OFF 0
#define ON 1
#define LED_ON 0
#define LED_OFF 1
Application Note
118
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Double click: Main.h and insert Global Variables:
extern volatile unsigned int blinking;
extern volatile int RS232_wait;
Application Note
119
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Double click: STM.c insert User Code for interrupt service routine:
STM_CMP0=STM_CMP0+20000000; // 20.000.000 * 50 ns = 1 s
if(RS232_wait)
RS232_wait--;
if(blinking)
IO_vTogglePin(IO_P1_0);
Note:
20.000.000 * 50 ns = 1 s
To get an STM interrupt every 1 second you must change
the Compare Value to “STM_CMP0+=20000000;”!
Application Note
120
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
August 2003
Reason for “myprintf.c“
Unfortunately, a low-level I/O implementation similar to example project “IO” (which consists
of “serio.c” and “serio.h” files for generating an output stream for “printf” using ASC0) using
tool chain C166/ST10 is currently not available for Tasking TriCore tools.
For the moment, Tasking has only got the following “Change Request”:
-------------------------------------------------------------------CR32186 CR: Example for _write function implementation using serial interface.
DESCRIPTION
Change request for a low-level I/O (_write function implementation) example which does not
use simulated I/O but uses the real serial interface of the controller.
EXAMPLE
WORKAROUND
Application Note
121
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
File – New
Open a New File for Editing: Filename: insert myprintf.c
OK
Application Note
122
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Insert User Code for myprintf():
#include "main.h"
#include "ASC0.H"
void myprintf(const char *p)
{
while(*p)
{
if (ASC0_ubTxBufFree())
ASC0_vSendData(*p++);
}
}
/*
// Example 1 (use of myprintf):
void main(void)
{
myprintf("Hello World!\r\n");
}
// Example 2 (use of myprintf):
void main(void)
{
char mb[200]; // message buffer for sprintf()
int dummy;
sprintf(mb,"Variable wait = %d",dummy); // Write formatted data to string mb
myprintf(mb);
}
*/
Application Note
123
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Application Note
124
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
File - Save all
(Project Window File View) – TC1766 (Files) – right mouse button click – Add Existing Files –
Browse
Application Note
125
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Select myprintf.c
Open - OK
Application Note
126
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Application Note
127
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Double click: Main.h and insert Prototypes of Global Functions:
extern void myprintf(const char *p);
Application Note
128
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Double click: Main.h and insert required Header for sprintf:
#include <stdio.h>
Application Note
// for sprintf (for myprintf)
129
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Generate your application program:
Build - Rebuild
or
☺
Application Note
130
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Insert Map File:
(Project Window File View) – TC1766 (Files) – right mouse button click – Add Existing Files –
Browse
Select TC1766.map
Open - OK
Application Note
131
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Application Note
132
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
See Map File:
Interrupt Vector Table:
Note:
Click here to see Memory Map
Application Note
133
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Trap Vector Table:
Note:
Click here to see Memory Map
Application Note
134
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Memory Usage:
Application Note
135
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Now you can close your project and Tasking EDE:
File - Close Project Space
File - Exit
Application Note
136
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
5.) Programming is now complete. You can now load and run your program:
Start pls-Debugger
Application Note
137
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
File – New Workspace
Open
Application Note
138
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Click OK
Press Default
Application Note
139
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Create or use default:
Application Note
Use a default target configuration: expand Debugger
140
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Create or use default: Use a default target configuration:
select Triboard with TC1766 (JTAG/OCDS)
Click Finish
Application Note
141
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
New Target Configuration: Save in: select C:\TC1766 (1)
New Target Configuration: File name: change/insert TC1766 (2)
Save
Application Note
142
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
OK
Application Note
143
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Application Note
144
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Config – Add-In Components
Application Note
145
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
UDE Add-In Components Load State:
UDE Add-In Component Description check/tick
FLASH/OTP Memory Programming Tool
OK
Application Note
146
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Tools – FLASH Programming …
Application Note
147
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
FLASH/OTP – Memory Device: check/select 1,5 MByte OnChip Program FLASH
FLASH/OTP – Memory Device: check/tick Enable
Application Note
148
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Click Setup …
Application Note
149
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Program: tick
Automatic Verify after Program
OK
Exit
Application Note
150
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
File – Load Program
Application Note
151
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Open program file: Look in: select TC1766
Open program file: File name: select tc1766.elf
Open
Application Note
152
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Click Program All
Application Note
153
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Exit
Exit
Application Note
154
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
File – Close Workspace
Yes
File – Exit
Application Note
155
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Execute any terminal program
(9600 Baud, 8 bit Data, no Parity-Bit, 1 Stop-Bit, Xon/Xoff Protocol):
Power-On the Board and see the result:
Application Note
156
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
Conclusion:
In this step-by-step book you have learned how to use the TC1766 Starter Kit together with the
Tasking tool chain.
Now you can easily expand your “hello world” program to suit your needs!
You can connect either a part of - or your entire application to the TC1766 Starter Kit.
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.
Have fun and enjoy working with the TC1766 Starter Kit!
Note:
There are step-by-step books for 8 bit microcontrollers (e.g. XC866, XC88x, and XC878), 16 bit
microcontrollers (e.g. C16x, XC16x, and XE16x) 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.
Application Note
157
V2.0, 2008-10
AP32133
TC1766 "Cookery Book" for a hello world application
6.) Feedback (TC1766): Your opinions, suggestions and/or criticisms
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:
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________
Application Note
158
V2.0, 2008-10
http://www.infineon.com
Published by Infineon Technologies AG