XC2287M HOT Solution ASC Uses a timer triggered LED to toggle with ASC Interrupt Device: XC2287M-104F80 Compiler: Tasking Viper 2.4r1 Code Generator: DAvE 2.1 XC2287M HOT Exercise ASC Hello World with ASC Let’s Let’s get get started started now! now! May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 2 XC2287M HOT Exercise ASC 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 May 2008 HW HW Copyright © Infineon Technologies 2007. All rights reserved. Page 3 HOT Exercise ASC Hello World with ASC In this exercise you will: Configure the XC2287M with DAvE Configure USIC 0 Channel 0 as a UART Receive a character from a PC and generate a receive interrupt Transmit the received data back to the PC Toggle one of the LED’s on the board on receipt of every character May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 4 HOT Exercise ASC Block Diagram RXD: P7.4 TXD: P7.3 USIC 0 – ASC 0 RxD TxD Receive ReceiveBuffer Buffer PC PC RxD TxD Transmit TransmitBuffer Buffer U0C0 U0C0Receive ReceiveIRQ IRQ Priority Priority33 RS 232 via USB • 19200 Baud •8n1 • RX interrupt a = Transfer by Interrupt handler ASC RX Interrupt • Received Character -> U0C0 ASC TX (Sends Received character) • Clear ASC status register Exit May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 5 HOT Exercise ASC 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’ May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 6 HOT Exercise ASC Select Device 1 2 3 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 7 HOT Exercise ASC - DAvE Configurations Project Settings Project Settings Close the window May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 8 HOT Exercise ASC - DAvE Configurations Save DAvE Project Save your DAvE project Path: C:\IFX_HOT\XC2287M\Examples\ASC Project name: ASC\ASC.dav May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 9 HOT Exercise ASC - DAvE Configurations Save DAvE Project Save your DAvE Project File 1 2 3 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. 4 Page 10 HOT Exercise ASC - DAvE Configurations ASC settings XC2287M USIC0 : ¬ Click on the May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 11 HOT Exercise ASC - DAvE Configurations ASC Settings (cont.) Configure ‘Protocol’ Select ASC for USIC0 (U0C0) Close the windows by pressing May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 12 HOT Exercise ASC - DAvE Configurations ASC settings (cont.) XC2287M USIC0, CH0 : ¬ Click on the May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 13 HOT Exercise ASC - DAvE Configurations ASC Settings (cont.) Configure ASC – General Enable module Pin selection – Transmit (TxD) P7.3, Receive (RxD) P7.4 Others- default 1 2 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 14 HOT Exercise ASC - DAvE Configurations ASC Settings (cont.) Configure ASC – Control Click on ‘Receive Interrupt’ 1 2 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 15 HOT Exercise ASC - DAvE Configurations ASC Settings (cont.) Configure ASC – Interrupts Drag ‘U0C0 OIC INT’ from Level 0 to Level 3, Group 0 1 2 3 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 16 HOT Exercise ASC - DAvE Configurations ASC Settings (cont.) Configure ASC – Functions Click on ‘U0C0_ASC_vInit’ Click on ‘U0C0_ASC_vSendData’ Click on 4 1 3 2 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 17 HOT Exercise ASC - DAvE Configurations Port settings XC2287M Port: ¬ Click on the May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 18 HOT Exercise ASC - DAvE Configurations Port settings Parallel Ports Ports: ¬ Configure Port 10 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 19 HOT Exercise ASC - DAvE Configurations Port settings Configure Port 10 Port 10: ¬ Use P10.0 as general IO ¬ Set Direction to Out ¬ Close the window May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 20 HOT Exercise ASC - DAvE Configurations Port settings Parallel Ports Functions: ¬ Include ‘IO_vInit’ ¬ Include ‘IO_vTogglePin’ May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 21 HOT Exercise ASC - DAvE Configurations Save DAvE Project Save your DAvE Project File Go to File Æ Save (or Save As) or click on Filename entered previously: “c:\IFX_HOT\XC2287M\Examples\ASC\ASC.dav” May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 22 HOT Exercise ASC - DAvE Configurations Code Generation Let DAvE Generate Code for You Go to File Æ generate Code or click on DAvE generated code files are ¬ MAIN.C, MAIN.H ¬ U0C0.C, U0C0.H ¬ USIC0.C, USIC0.H ¬ IO.C, IO.H ¬ SCS.C, SCS.H ¬ XC22XXREGS.H May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 23 HOT Exercise ASC – Tasking VX Toolset Create New Work Space Click on Filename: “c:\IFX_HOT\XC2287M\Examples” Click ‘OK’ 1 2 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 24 HOT Exercise ASC – Tasking VX Toolset Create New Project Click on Workbench May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 25 HOT Exercise ASC – Tasking VX Toolset Import DAVE Project 1 Click on File -> Import Select Tasking VX-toolset for C166… Click ‘OK’ 2 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 26 HOT Exercise ASC – Tasking VX Toolset Import DAVE Project Click `Infineon DAvE C166 Project´ Click ‘Next’ CAN_1 1 2 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 27 HOT Exercise ASC – Tasking VX Toolset Import DAvE Project Add Dave Project ‘ASC´ Click `Finish´ 2 1 3 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 28 HOT Exercise ASC – 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 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 29 HOT Exercise ASC – 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 } May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 30 HOT Exercise ASC – Tasking VX Toolset Add User Code – U0C0.C (ISR) _interrupt(U0C0_0INT) void U0C0_ASC_vi0IC(void) { // USER CODE BEGIN (ASC0IC,2) // USER CODE END if (U0C0_PSR & 0x4000) { // USER CODE BEGIN (ASC0IC,4) IO_vTogglePin(IO_P10_0); U0C0_ASC_vSendData (U0C0_RBUF); // USER CODE END U0C0_PSCR |= 0x4000; // clear PSR_RIF } // USER CODE BEGIN (ASC0IC,15) // USER CODE END 1 } // End of function U0C0_ASC_vi0IC May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 31 HOT Exercise ASC – Tasking VX Toolset Build Project 1 Click on ‘Build Project ASC’ May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 32 HOT Exercise ASC - 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 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 33 HOT Exercise ASC - 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 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 34 HOT Exercise ASC - 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“ May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 35 HOT Exercise ASC - 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 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 36 HOT Exercise ASC – Tasking VX Toolset Connect XC2287M Easy Kit Connect XC2287M Board to PC Modify The DIP Switch Settings, S102: OFF-OFF-OFF-OFF-OFF (Start from Internal Flash) Reset The Board (Press The Reset Button) S102 Standard Internal Start configuration ON 1 2 3 4 DIP 5 USB Reset button May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 37 HOT Exercise ASC – Tasking VX Toolset Run Debugger 1 Click on 2 Click on ‘Resume’ and start program May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 38 HOT Exercise ASC Start HyperTerminal With the FTDI chip an on board, USB interface can be used for UART. FTDI device will converts the USB protocol the ASC protocol. Both USB and UART can be used at the same time. Open Device Manger and check which COM port is activated for the FTDI chip May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 39 HOT Exercise ASC Start HyperTerminal 1. 2. 3. 4. 5. 6. May 2008 Start->Programs->Accessories->Communications->HyperTerminal Enter any name and click ‘OK’ Connect using: COMx (COM port activated for the FTDI chip) Click ‘Configure’ to enter Port settings Select 19200 baud, no Parity, 8 Data Bits and 1 Stop Bit Click ‘OK’ Copyright © Infineon Technologies 2007. All rights reserved. Page 40 HOT Exercise ASC Running the program Start typing Enter ASCII characters in the HyperTerminal The characters you enter are sent to the XC2287M and back to the Terminal Program so that you can read them on the screen The characters are not sent directly from the keyboard to the screen! ¬ Hold the reset button down to verify that the screen no longer displays the typed characters May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 41 HOT Exercise ASC See Result The yellow LED will toggle when the ASC sending the data back LED blinking May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 42 HOT Exercise ASC – Tasking VX Toolset Run Debugger Verifications Click on ‘Suspend’ Click on ‘Restart’ The LED no longer toggles when a key is pressed Click on ‘Resume’ LED toggles again when a key is pressed May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 43 May 2008 Copyright © Infineon Technologies 2007. All rights reserved. Page 44