XC2287M HOT

XC2287M HOT
Getting Started Exercise 1
Get familiar with the tool chain and
uses a timer triggered LED toggle
Device: XC2287M-104F80
Compiler: Tasking Viper 2.4r1
Code Generator: DAvE 2.1
Getting Started 1
Pin/LED toggle using a simple timer
Let’s
Let’s get
get started
started now!
now!
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 2
Getting Started 1
Objective
„ Very simple example
†
See interaction with different tools
†
Check tool setup/installation
„ Setup Prescaler and Timer T3 of GPT12
„ Using timer interrupt to toggle port pin
fclk
14.07.2010
Prescaler
Timer T3
INT
Copyright © Infineon Technologies 2008. All rights reserved.
Toggle
P10.0
Page 3
Getting Started 1
Interaction of Development Tools
IDE
Compiler
Compiler
Assembler
Assembler
Linker
Linker
Locator
Locator
DAvE
Programming
Tool
Debugger
int main(){
char a;
long b;
…
Target
Debugger/Emulator
SW
SW
14.07.2010
HW
HW
Copyright © Infineon Technologies 2008. All rights reserved.
Page 4
Getting Started 1
Overview
„ DAvE
†
General Project Settings
†
Setup Timer T3
†
Port Settings
†
Generate Code (Peripheral Initialization; C Code)
„ Compiler
†
Import your DAvE Project
†
Include Peripheral Initialization
†
Add Application C Code (Interrupt routine)
†
Compile Code
„ Debugger
†
Download/Flash Compiled Code
†
Execute/Debug Code
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 5
Getting Started 1 - DAvE Configurations
Start DAvE
„ Start DAvE
†
Click on the
„ Create a new project (Startup Dialog pop up automatically)
†
Click on ‘Create a new project’ or select File -> New
†
Select microcontroller: ‘XC2287M’
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 6
Getting Started 1 - DAvE Configurations
Select Device
1
2
3
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 7
Getting Started 1 - DAvE Configurations
Project Settings
„ Project Settings
„ Close the window
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 8
Getting Started 1 - DAvE Configurations
Save DAvE Project
„ Save your DAvE project
†
Path:
C:\IFX_HOT\XC2287M\Examples\Dave\GET_START_1
†
Project name:
GET_START_1\GET_START_1.dav
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 9
Getting Started 1 - DAvE Configurations
Save DAvE Project
„ Save your DAvE Project File
1
1
2
3
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
4
Page 10
Getting Started 1 - DAvE Configurations
GPT1 settings
„ Timer Settings
†
Enable the module (enable clock path)
†
Set Prescaler to get ~ 1 second timer overflow
†
Generate interrupt on overflow
†
Configure interrupt routine
†
Include timer setup function
†
Close GPT1 setup window
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 11
Getting Started 1 - DAvE Configurations
GPT1 settings
„ Timer Settings
†
GPT1 :
¬ Click on
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 12
Getting Started 1 - DAvE Configurations
GPT1 settings
„ Module Clock settings
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 13
Getting Started 1 - DAvE Configurations
GPT1 settings
„ T3 settings
1
2
3
5
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
4
Page 14
Getting Started 1 - DAvE Configurations
GPT1 settings
„ Interrupts settings
1
2
3
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 15
Getting Started 1 - DAvE Configurations
GPT1 settings
„ Functions settings and close GPT1 window
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 16
Getting Started 1 - DAvE Configurations
Port settings
„ Port Settings
†
LED connected to P10.0
†
Use P10.0 as general output
†
Include port setup function
†
Include port toggle function
†
Close port setup window
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 17
Getting Started 1 - DAvE Configurations
Port settings
„ Port Settings
†
Port:
¬ Click on
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 18
Getting Started 1 - DAvE Configurations
Port settings
„ Port Settings
†
Ports:
¬ Configure Port 10
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 19
Getting Started 1 - DAvE Configurations
Port settings
„ Configure Port 10
†
Port 10:
¬ Use P10.0 as general IO
¬ Set Direction to Out
¬ Close the window
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 20
Getting Started 1 - DAvE Configurations
Port settings
„ Parallel Ports
†
Functions:
¬ Include ‘IO_vInit’
¬ Include ‘IO_vTogglePin’
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 21
Getting Started 1 - DAvE Configurations
Save DAvE Project and Generate Code
„ Save your DAvE Project File
„ Generated Code
1
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 22
Getting Started 1 - DAvE Configurations
Generated Code
„ DAvE generated code files are
†
†
‘MAIN.c’, ‘MAIN.h’
‘SCS.c’, ‘SCS.h’
‘IO.c’, ‘IO.h’
‘GPT1.c’, ‘GPT1.h’
‘XC22xxREGS.h’
†
In general:
†
†
†
¬ if the included function is a macro it is included in the ‘.h’ file
¬ if the included function is a function it is included in the ‘.c’ file
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 23
Getting Started 1– Tasking VX Toolset
„ Start Tasking Viper Tool Set
„ Open Project Work Space
†
Browse to “c:\IFX_HOT\XC2287M\Examples”
†
Click ‘OK’
1
2
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 24
Getting Started 1– Tasking VX Toolset
„ Create New Project
†
14.07.2010
Click on Workbench (if not already there…)
Copyright © Infineon Technologies 2008. All rights reserved.
Page 25
Getting Started 1– Tasking VX Toolset
„ Import DAVE Project
1
†
Click on File -> Import
†
Select Tasking VX-toolset for C166…
†
Click ‘OK’
2
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 26
Getting Started 1– Tasking VX Toolset
„ Import DAVE Project
†
Click `Infineon DAvE C166 Project´
†
Click ‘Next’
CAN_1
1
2
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 27
Getting Started 1– Tasking VX Toolset
„ Import DAvE Project
†
Add Dave Project `Get_Start_1´
†
Click `Finish´
2
1
3
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 28
Getting Started 1– Tasking VX Toolset
„ Configure Target Board
1
† Select the project in the navigator
† Select ‘Project/Target Board
Configuration’
2
† Select ‘Infineon XC2000/XE166
Easykit Board’
† Choose `XC2287M-104F´
† Click `Finish´
3
4
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 29
Getting Started 1– Tasking VX Toolset
„ Software Hint
†
DAvE doesn’t change code that is inserted in the ‘USER
CODE’ sections if you let DAvE regenerate the code.
Therefore, whenever adding code to the generated code,
write it into a ‘USER CODE’ section.
The code you really have to add looks like this:
while(1)
{
// USER CODE BEGIN (Main,4)
BlinkLED();
// USER CODE END
}
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 30
Getting Started 1 - Complete code
Edit File ‘GPT1.C’
„ In the ISR function 'void GPT1_viTmr3(void)'
(almost at the end)
_interrupt(T3INT)
void GPT1_viTmr3(void)
{
// USER CODE BEGIN (Tmr3,2)
IO_vTogglePin(IO_P10_0);
// USER CODE END
// USER CODE BEGIN (Tmr3,5)
// USER CODE END
} //
14.07.2010
End of function GPT1_viTmr3
Copyright © Infineon Technologies 2008. All rights reserved.
Page 31
Getting Started 1– Tasking VX Toolset
Build Project
1
„ Click on ‘Build Project GET_START_1’
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 32
Getting Started 1 - Device Access Server
Check for the latest DAS version
Note: It is recommended to use the latest DAS version.
Download the latest version at www.infineon.com\DAS
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 33
Getting Started 1 - Device Access Server
1.) Checking USB connections
This gets identified only
when COM port is used
•Via the USB interface
on the Easykit with FTDI
chip
The DAS JTAG
composite device gets
identified
•When miniWiggler is
connected
•When USB Wiggler Box
is connected
•Via the USB interface
on the Easykits with
FTDI chip
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 34
Getting Started 1 - Device Access Server
2.) Check DAS status
1. Start DAS device scanner
2. Start DAS Server Control panel
3. If DAS device scanner does not show any device, start the
appropriate DAS server
Incase you are connected via the USB Wiggler box,
then start „JTAG over USB Box“
Incase you are connected via the FTDI chip or mini wiggler,
then start „UDAS“
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 35
Getting Started 1 - Device Access Server
3.) Starting the servers manually
4. Incase „UDAS“ server is started and XC2000 easykit is
connected via on-chip FTDI or via separate miniWiggler,
following status changes could be noted
5. Incase „JTAG over USB Box“ server is started and XC2000
starter kit is connected via Wiggler box, following status
changes could be noted
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 36
Getting Started 1
Connect XC2287M Board
„ Internal start from Flash
†
Connect XC2287M Board to PC
†
Check the DIP switch settings, S102: OFF-OFF-OFF-OFF-OFF
†
Reset the board (press the reset button)
S102
Standard Internal
Start configuration
ON
1 2 3 4
DIP
5
USB
Reset button
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 37
Getting Started 1– Tasking VX Toolset
Run Debugger
1
„ Click on
2
„ Click on ‘Resume’ and start program
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 38
Getting Started 1
See Result
„ The yellow LED will toggle
LED blinking
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 39
Getting Started 1
Verification
„ Verification: (stop the program)
†
Go to Tasking debugger
†
Click on ‘RESET’
†
⇒ LED is no more toggling; stays constant off
14.07.2010
Copyright © Infineon Technologies 2008. All rights reserved.
Page 40