Application Note, V2.0, July 2006 AP32110 TC1796 TC1796 "Cookery-Book" for a "Hello world" application Microcontrollers Edition 2008-07-16 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. AP32110 TC1796 "Cookery-Book" AP32110 Revision History: Previous Version: Page 2006-07 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, 2006-07 AP32110 TC1796 "Cookery-Book" Table of Contents Page Note: Table of Contents See page 7. Introduction: This “Appnote” is an Infineon Hands-On-Training. It will help inexperienced users to get an TC1796 Evaluation-Board / Starter-Kit-Board up and running. With this Hands-On-Training / Cookery-Book / 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 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. The main chapters are: Chapter 4: Program_Execution_From_Scratch-Pad-RAM_SPRAM Chapter 5: Program_Execution_From_OnChipProgramFlash Chapter 6: Program_Execution_From_OnBoardProgramFlash Chapter 7: Program_Execution_From_OnBoardProgramFlash_Burst-Mode 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, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 5 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" TC1796 Block Diagram Application Note 6 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" “Cookery-Book“ For your first programming example for the TC1796 Starter-Kit-Board: Your program: Chapter/ Step: 1.) *** Recipes *** TC1796 Board Power Supply, Jumper Setting, Serial cable to the notebook, pls-Debugger 2.) DAvE – program generator DAvE installation (mothersystem) + DAvE Update-installation for TC1796 (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 TASKING (Altium) tool chain (EDE) - v2.3r1 Locating programs in the 48 KByte code scratchpad RAM. (SPRAM), using OnChipSRAM) 5.) Using the TASKING Development Tools (C/C++/EC++ Compiler) Programming of your application with TASKING (Altium) tool chain (EDE) - v2.3r1 Locating programs in the 2 MByte OnChipProgramFlash (PFLASH), using OnChipSRAM) 6.) Using the TASKING Development Tools (C/C++/EC++ Compiler) Programming of your application with TASKING (Altium) tool chain (EDE) - v2.3r1 Locating programs in the 4 MByte OnBoardFlash, using OnChipSRAM + OnBoardSRAM) 7.) Using the TASKING Development Tools (C/C++/EC++ Compiler) Programming of your application with TASKING (Altium) tool chain (EDE) - v2.3r1 Locating programs in the 4 MByte OnBoardFlash (Burst!), using OnChipSRAM + OnBoardSRAM Application Note 7 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Additional exercises 8.) Time - Measurement Feedback 9.) Feedback Application Note 8 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 1.) TC1796 Starter Kit Board: Ordering information: Starter Kits Type SK-TC1796 Title Ordering No. TC1796 Starter Kit B158-H8537-G1-0-7600 Comment Distribution Worldwide: http://www.infineon.com/cgi-bin/ifx/portal/ep/channelView.do?channelId=66982&pageTypeId=17224 Application Note 9 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" You need a Power Supply: The TC1796 Board requires an external power supply. A (un)regulated DC power supply from 6 to 60 Volts can be connected to the power connector. 300mA are sufficient for the TC1796 Starterkit. You need a RS-232 Serial Cable (1:1; 9-pin Sub-D plug – 9-pin Sub-D connector; the “Hello World” example uses this interface): You need the pls-Debugger (Flash-Programming und Debugging): For further information, please refer to the TriBoard TC1796 V1.0, March 2003 Hardware Manual . For further information, please refer to the TriBoard TC1796 V2.0, June 2004 Hardware Manual . For further information, please refer to the TriBoard TC1796 V3.0, June 2004 Hardware Manual . For further information, please refer to the TriBoard TC1796 V3.1, Jan. 2005 Hardware Manual . For further information, please refer to the TriBoardManual-TC179X-V32.pdf (September 2006). Application Note 10 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Jumper Settings (Jumper JP501): Jumper JP501 1-2 … Enable On Board Wiggler (use parallel-on-board-interface) 2-3 … Disable On Board Wiggler (use pls-Debugger) use pls-Debugger Application Note 11 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" TC1796-Execution-Environment-SPRAM: Jumper Settings (HW-Configuration DIP-Switch): S301: 1, 2, 4, 5, 6 : ON 3, 7, 8 : OFF Application Note 12 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" TC1796-Execution-Environment-SPRAM: Jumper Settings ( >= B-Step, HW-Configuration DIP-Switch ): Application Note 13 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Accessories for the TC1796 Starter Kit – Extension Boards “TriBoard+XC16x-Adapter-Board” to have access to all microcontroller pins. Stencils are available with the Board Ordering information: TriBoard+XC16x-Adapter-Platine Price: approximately € 32,- (4 required) Extension Boards for easy measuring of the signals on the extension connectors. 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 14 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note stencil stencil stencil stencil 15 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 2.) DAvE – Installation for TC1796 microcontrollers: Install DAvE: Download @ http://www.infineon.com/DAvE the DAvE-mothersystem setup.exe and execute setup.exe to install DAvE . Application Note 16 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Install the TC1796 microcontroller Update: 1.) Download @ http://www.infineon.com/DAvE the DAvE-update-file (.DIP) for the required microcontroller Unzip the zip-file and save “ TC1796.DIP “ @ e.g. D:\DAvE\TC1796-2006-03-16\TC1796_v2.3 . Application Note 17 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 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\TC1796-2006-03-16\TC1796_v2.3 Forward> Select: Available Products click D TC1796 Forward> Install End 4.) DAvE is now ready to generate code for the TC1796 microcontroller. Application Note 18 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 3.) DAvE - Microcontroller Initialization after Power-On: Start the program generator DAvE and select the TC1796 microcontroller: File New 32-Bit Microcontrollers TC1796 Create Application Note 19 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Choose the Project Settings as you can see in the Screenshots: General: Compiler Settings: For the Tasking Compiler choose Tasking 2.0 in the Compiler Settings: Application Note 20 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" System Clock: CPU Clock will be 150 MHz: System Clock: External Clock Frequency: External clock frequency insert 20 [MHz] Note: We would be very grateful if you would check if your board is equipped with a 20 MHz Crystal (default). Yes Note: Validate each alpha numeric entry by pressing ENTER. Application Note 21 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 22 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" System Clock: External Clock Frequency: Input divider (PDIV) select fp=fosc/2=10,000 MHz Yes Application Note 23 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 24 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" System Clock: Voltage Controlled Oscillator: Feedback divider (NDIV) select fvco=fosc/P*60=600,000 MHz Yes Application Note 25 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 26 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" System Clock: Output Divider: Output divider (KDIV) select fcpu=fvco/4=150,000 MHz Yes Application Note 27 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Note: The final result should be 150 MHz CPU frequency and 75 MHz system frequency. Application Note 28 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Interrupt System: CPU Global Interrupt Enable: click 9Enable globally the interrupt system (IE) Application Note 29 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" PCP System: (do nothing) Application Note 30 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Pad Driver: (do nothing) Startup Configuration: Hardware Booting Scheme: (do not care !!!) Notes: If you wish, you can insert your comments here. Exit this dialog now by clicking Application Note the close button: 31 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Configuration of the ASC0: The configuration window can be opened by clicking the specific block/module. Application Note 32 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Module Clock: Module Disable Request: select/check Disable the ASC0 module Module Clock: Module Run Mode Clock Control: choose System clock/1 (=75,0000 MHz) Module Clock: Sleep Mode Enable Control: click 9 Disable the sleep mode Application Note 33 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Pin Selection: Alternate Pin Selection: click Configure pins RX and TX Application Note 34 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Pin Selection: Alternate Pin Selection: Configure pins RX and TX ASC0_RX: ASC0_RX Pin Selection: select Use pin P5.0 Pin Selection: Alternate Pin Selection: Configure pins RX and TX ASC0_RX: Pull Device: select Tristate Application Note 35 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Pin Selection: Alternate Pin Selection: Configure pins RX and TX ASC0_TX: ASC0_TX Pin Selection: select Use pin P5.1 Exit this dialog now by clicking X in the close button: Application Note 36 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Control: Receiver Enable: click 9 Enable receiver (REN) Application Note 37 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Baud Rate: Baud Rate: Required baud rate [kBaud] insert 9,600 Baud Rate: Baud Rate Selection Bit / Fractional Divider: click 9 Use fractional divider Interrupts: (do nothing) Application Note 38 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Functions: Initialization Function: click 9 ASC0_vInit Functions: Function Library (Part 1): click 9 ASC0_vSendData Functions: Function Library (Part 1): click 9 ASC0_usGetData Functions: Function Library (Part 1): click 9ASC0_ubTxBufFree Application Note 39 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Parameters: (do nothing) Notes: If you wish, you can insert your comments here. Exit this dialog now by clicking Application Note the close button: 40 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Configuration of the STM: The configuration window can be opened by clicking the specific block/module. Application Note 41 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Module Clock: Module Run Mode Clock Control: select System clock / 6 ( = 80 ns) Resolutions: (do nothing) Application Note 42 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" CMP0: Compare Register Size of CMP0: Number of bits for compare: insert 24 CMP0: Compare Register 0: Required compare value (CMP0): insert 12500000 Note: 12500000 * 80 ns = 1 s CMP1: (do nothing) Application Note 43 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Interrupt Control: Compare Register CMP0 Interrupt Control: click 9 Enable request on compare match with CMP0 Interrupt Control: Interrupt Control of STMIR0: click 9 Enable SRC0 interrupt Application Note 44 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Interrupts: drag and drop STM SRN 0 from Level 0 to Level 9 Application Note 45 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Functions: Initialization Function: click 9 STM_vInit Parameters: (do nothing) Notes: If you wish, you can insert your comments here. Exit this dialog now by clicking Application Note the close button. 46 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Port Configuration: The configuration window can be opened by clicking the specific block/module. Application Note 47 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Ports: click Configure Port 1 Application Note 48 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Ports: Configure Port 1 Port 1: Functionality: click 9 Use P1.15 as general IO, General Direction: click ~ Out Input Characteristic: (do nothing) Output Characteristic: (do nothing) Parameters: (do nothing) Notes: If you wish, you can insert your comments here. Exit this dialog now by clicking Application Note the close button. 49 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Functions: Initialization Function: click 9 IO_vInit Functions: Function Library (Part 1): click 9 IO_vSetPin Functions: Function Library (Part 1): click 9 IO_vResetPin Functions: Function Library (Part 1): click 9 IO_vTogglePin Parameters : (do nothing) Notes: If you wish, you can insert your comments here. Exit this dialog now by clicking Application Note the close button. 50 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Save the project: File Save Save project: Save in: C:\TC1796 (create directory) File name: TC1796 Save Application Note 51 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Generate Code: File Generate Code or click DAvE will show you all the files he has generated (File Viewer opens automatically). File Exit Save changes? click Yes Application Note 52 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 4.) Using of the TASKING - EDE Development Tools: Write programs for execution from Scratch-Pad RAM (SPRAM) Application Note 53 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 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 54 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File Change Directory Choose C:\TC1796 OK Application Note 55 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File New Project Space Insert TC1796 OK Application Note 56 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Click: “Add new project to project space” Application Note 57 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Insert TC1796 OK Application Note 58 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Click: “Add existing files to project” Application Note 59 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Select ASC0.c Select ASC0.h Select IO.c Select IO.h Select MAIN.c Select MAIN.h Select STM.c Select STM.h Open Application Note 60 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" OK Application Note 61 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 62 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Configure Compiler, Assembler, Linker, Locater and Build – Control: Project – Project Options Processor: Processor Definition: Target processor: select TC1796B Application Note 63 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Processor: Bypasses: CPU Functional Problem Bypasses: click 9 All bypasses TC179X Application Note 64 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" C Compiler: Preprocessing: deactivate Automatic inclusion of .sfr file Application Note 65 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" C Compiler: Optimization: Optimization level: select No optimization Application Note 66 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: Special Areas: RESET start address: insert 0xD4002100 (SPRAM) Linker: Script File: Special Areas: Libraries start address: insert 0xD4004000 (SPRAM) Linker: Script File: Special Areas: Interrupt table start address: insert 0xD4000000 (SPRAM) Linker: Script File: Special Areas: Trap table start address: insert 0xD4002000 (SPRAM) Linker: Script File: Special Areas: CSA start address: insert 0xD0000000 (LDRAM) Application Note 67 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 68 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 69 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: Internal Memory: change from brom to PMU_BROM Linker: Script File: Internal Memory: change from lmbram to DMU_SRAM Linker: Script File: Internal Memory: change from dsram to DMI_LDRAM Linker: Script File: Internal Memory: change from dpram to DMI_DPRAM Linker: Script File: Internal Memory: change from csram 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 70 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 71 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: Internal Memory: PMU_BROM: Alloc: select OFF Linker: Script File: Internal Memory: DMU_SRAM: Alloc: select ON!!! Linker: Script File: Internal Memory: DMI_LDRAM: Alloc: select OFF Linker: Script File: Internal Memory: DMI_DPRAM: Alloc: select OFF Linker: Script File: Internal Memory: PMI_SPRAM: Alloc: select ON!!! Linker: Script File: Internal Memory: PCP_PRAM: Alloc: select OFF Linker: Script File: Internal Memory: PCP_CMEM: Alloc: select OFF Application Note 72 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: Internal Memory: PMI_SPRAM: Type: select ROM Application Note 73 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: External Memory: ext_c: Alloc: select OFF Linker: Script File: External Memory: ext_d: Alloc: select OFF Linker: Script File: External Memory: vectable: Alloc: select OFF Application Note 74 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: Sections: linear: Alloc: select intmem Linker: Script File: Sections: linear: Location: insert PMI_SPRAM OK Application Note 75 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 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 76 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Double click: Main.c insert User Code (Global Variables): const char menu[] = "\r\n\n\n\n" "Program execution out of SPRAM\r\n" "==============================\r\n" "1 ... LED IO_P1_15 ON\r\n" "2 ... LED IO_P1_15 OFF\r\n" "3 ... LED IO_P1_15 blinking\r\n" " \r\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 77 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 78 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 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 79 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Double click: Main.c: insert User Code: while(RS232_wait); while (1) { myprintf(menu); select=input(); switch (select) { case '1': blinking=OFF, IO_P1_15=LED_ON, myprintf(message1); break; case '2': blinking=OFF, IO_P1_15=LED_OFF, myprintf(message2); break; case '3': blinking=ON, myprintf(message3); break; } } Application Note 80 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 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 81 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Double click: Main.h and insert Global Variables: extern volatile unsigned int blinking; extern volatile int RS232_wait; Application Note 82 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Double click: STM.c: insert User Code for interrupt service routine: STM_CMP0=STM_CMP0+12500000; // 12.500.000 * 80 ns = 1 s if(RS232_wait) RS232_wait--; if(blinking) IO_vTogglePin(IO_P1_15); Note: 12.500.000 * 80 ns = 1 s To get an STM-interrupt every 1 second you must change the Compare-Value to “STM_CMP0+=12500000;”, because there is no ”reload-functionality”! Application Note 83 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 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 not available for Tasking TriCore tools for the time being. For the moment, Tasking has only got 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 File – New Insert myprintf.c OK Application Note 84 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 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 85 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 86 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File Save all (Project Window File View) – TC1796 (Files) – right mouse button click – Add Existing Files – Browse Application Note 87 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Select myprintf.c Open - OK Application Note 88 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 89 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Double click: Main.h and insert Prototypes of Global Functions: extern void myprintf(const char *p); Application Note 90 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Double click: Main.h and insert required Header for sprintf: #include <stdio.h> Application Note // for sprintf (for myprintf) 91 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" (Project Window File View) – TC1796 (Files) – right mouse button click – Add Existing Files – Browse select TC1796Regs.h Open - OK Application Note 92 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Generate your application program: Build Rebuild or Now you can close your project and Tasking EDE: File - Close Project Space File – Exit Application Note 93 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Programming is now complete. You can now load and run your program: Start pls-Debugger Application Note 94 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – New Workspace Application Note 95 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Open Application Note 96 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Last used: Last used files: Triboard with TC1796 and PCP (JTAG/OCDS) Copy Application Note 97 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Save in: select C:\TC1796 File name: insert TC1796 Save Application Note 98 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" OK Application Note 99 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" OK Application Note 100 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 101 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – Load Program Application Note 102 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Select tc1796.elf Open Application Note 103 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 104 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 105 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Debug – Start Program Execution Application Note 106 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Execute any terminal-program (9600 Baud, 8 bit Data, no Parity-Bit, 1 Stop-Bit, Xon/Xoff Protocol): And see the result: Application Note 107 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – Close Workspace Yes File - Exit Application Note 108 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 5.) Using of the TASKING - EDE Development Tools: Write programs for execution from OnChipFlash (PFLASH) Application Note 109 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" TC1796-Execution-Environment: OnChipFlash (PFLASH): Jumper Settings (HW-Configuration DIP-Switch): Application Note 110 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" S301: 1, 3, 4, 5, 6 : ON 2, 7, 8 : OFF Application Note 111 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" TC1796-Execution-Environment: OnChipFlash (PFLASH): Jumper Settings (HW-Configuration DIP-Switch): Application Note 112 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Bottom side: all little DIPs: OFF Note: The little DIPs on the bottom side are for internal purpose. Please, guarantee that they are all set to “OFF”. Application Note 113 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Start DAvE and open the TC1796 project: File Open Look in: select C:\TC1796 File name: select TC1796.dav Open Application Note 114 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 115 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – Project Settings Startup Configuration: Boot type (CFG[3:0]) select 0010 Exit this dialog now by clicking Application Note the close button: 116 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Generate Code: File Generate Code or click DAvE will show you all the files he has generated (File Viewer opens automatically). File Exit Save changes? click Yes Application Note 117 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Start Tasking EDE and open the project: File – Open Project Space Look in: select C:\TC1796 File name: select TC1796.psp Open Application Note 118 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 119 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Configure Compiler, Assembler, Linker, Locater and Build – Control: Project – Project Options Linker: Script File: Special Areas: RESET start address: insert 0xA0000000 (PFLASH) Linker: Script File: Special Areas: Libraries start address: insert 0xA0104000 (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) Application Note 120 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 121 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: Internal Memory: PMI_SPRAM: Alloc: select OFF Application Note 122 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 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 2M Linker: Script File: Internal Memory: Address insert 0xA0000000 Application Note 123 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: Sections: linear: Location: insert PMU_PFLASH OK Application Note 124 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 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 125 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Double click: Main.c and change Global Variable menu from const char menu[] = "\r\n\n\n\n" "Program execution out of SPRAM\r\n" "==============================\r\n" "1 ... LED IO_P1_15 ON\r\n" "2 ... LED IO_P1_15 OFF\r\n" "3 ... LED IO_P1_15 blinking\r\n" " \r\n"; to const char menu[] = "\r\n\n\n\n" "Program execution out of OnChipFlash\r\n" "====================================\r\n" "1 ... LED IO_P1_15 ON\r\n" "2 ... LED IO_P1_15 OFF\r\n" "3 ... LED IO_P1_15 blinking\r\n" " \r\n"; Application Note 126 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Generate your application program: Build Rebuild or Now you can close your project and Tasking EDE: File - Close Project Space File – Exit Application Note 127 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Programming is now complete. You can now load and run your program: Start pls-Debugger Application Note 128 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – Open Workspace Look in: select C:\TC1796 File name: select tc1796.wsp Open Cancel Application Note 129 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Config – Add-In Components UDE Add-In Component Description click 9 UDE FLASH/OTP Memory Programming Tool OK Application Note 130 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Tools – FLASH Programming … FLASH/OTP – Memory Device: select 2 MByte OnChip Program FLASH FLASH/OTP – Memory Device: click 9 Enable Application Note 131 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Click Setup … Program: click 9 Automatic Verify after Program OK Exit Application Note 132 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – Load Program Look in: select TC1796 File name: select tc1796.elf Open Application Note 133 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Click Program All Application Note 134 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Exit Exit Application Note 135 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – Close Workspace Yes File – Exit Application Note 136 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 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 137 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 6.) Using of the TASKING - EDE Development Tools: Write programs for execution from OnBoardFlash Application Note 138 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" TC1796-Execution-Environment: OnBoardFlash : Jumper Settings (HW-Configuration DIP-Switch): Application Note 139 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" S301: 1, 2, 4, 5, 6 : ON 3, 7, 8 : OFF Application Note 140 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" TC1796-Execution-Environment: OnBoardFlash : Jumper Settings (HW-Configuration DIP-Switch): Application Note 141 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Bottom side: all little DIPs: OFF Note: The little DIPs on the bottom side are for internal purpose. Please, guarantee that they are all set to “OFF”. Application Note 142 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Start DAvE and open the TC1796 project: File Open Look in: select C:\TC1796 File name: select TC1796.dav Open Application Note 143 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 144 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – Project Settings Startup Configuration: Boot type (CFG[3:0]) select 0100 Exit this dialog now by clicking Application Note the close button: 145 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Generate Code: File Generate Code or click DAvE will show you all the files he has generated (File Viewer opens automatically). File Exit Save changes? click Yes Application Note 146 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Start Tasking EDE and open the project: File – Open Project Space Look in: select C:\TC1796 File name: select TC1796.psp Open Application Note 147 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 148 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Configure Compiler, Assembler, Linker, Locater and Build – Control: Project – Project Options Processor: Startup: Startup Code: BootMemory: Boot Memory: Value: insert 0x0000803C Application Note 149 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Processor: Bus Configuration: Address Select Registers: Addrsel0: insert 0xA1000051 Application Note 150 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Note: Memory Region Address Mask: Specifies the number of rightmost bits in the base address starting at bit 26, which should be included in the address comparison. Bits (31:27) will always be part of the comparison. 4 MBytes OnBoardFlash = 10000000000000000000000 b Base = A1000 Mask = 5 1 [31:27] [26] Application Note 2 3 4 5 [25] [24] [23] [22] [21:0] 1 0000000000000000000000 151 = Mask = 4 MBytes OnBoardFlash V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Processor: Bus Configuration: Address Select Registers: Addrsel1: insert 0xA2000071 Application Note 152 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Note: Memory Region Address Mask: Specifies the number of rightmost bits in the base address starting at bit 26, which should be included in the address comparison. Bits (31:27) will always be part of the comparison. 1 MBytes OnBoardFlash = 100000000000000000000 b Base = A2000 Mask = 7 1 [31:27] [26] 2 [25] 3 4 [24] [23] 5 [22] 6 7 [21] [20] 1 Application Note 153 = Mask [19:0] 00000000000000000000 = 1 MBytes OnBoardFlash V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Processor: Bus Configuration: Bus Access Parameters Registers: Busap0: insert 0x46940000 Application Note 154 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Processor: Bus Configuration: Bus Access Parameters Registers: Busap1: insert 0x40d80000 Application Note 155 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Processor: Bus Configuration: Bus Control Registers: Buscon0: insert 0x00922001 Application Note 156 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Processor: Bus Configuration: Bus Control Registers: Buscon1: insert 0x00920000 Application Note 157 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Processor: Bus Configuration: Other Registers: S_bcucon: (do nothing) Application Note 158 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Processor: Bus Configuration: Other Registers: Ebuclc: (do nothing) Application Note 159 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Processor: Bus Configuration: Other Registers: Ebucon: insert 0x00000068 Application Note 160 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Processor: Bus Configuration: Other Registers: Bfcon: insert 0x00100173 Application Note 161 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" C Compiler: Allocation: deactivate Default __near allocation for objects below threshold Application Note 162 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: Special Areas: RESET start address: insert 0xA1000000 (OnBoardFLASH) Linker: Script File: Special Areas: Libraries start address: insert 0xA1100000 (OnBoardFLASH) Linker: Script File: Special Areas: Interrupt table start address: insert 0xA1200000 (OnBoardFLASH) Linker: Script File: Special Areas: Trap table start address: insert 0xA1300000 (OnBoardFLASH) Application Note 163 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 164 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Memory-Map OnBoard-Flash: Application Note 165 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Interrupt–Vector–Table: DAvE: Application Note 166 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Interrupt–Vector–Table: Note: PN … Priority Number Click here to see the Map File Application Note 167 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" TRAP–Vector–Table: Note: 1 Word = 32 Bit 1 Word = 4 Bytes 8 Words= 32 Bytes Click here to see the Map File Application Note 168 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: Internal Memory: PMU_PFLASH: Alloc: select OFF Application Note 169 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: External Memory: Name: “vecttable” change to “TRAP_ vecttable” Application Note 170 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: External Memory: Name=ext_c: Alloc: select “ON” Linker: Script File: External Memory: Name=ext_d: Alloc: select “ON” Linker: Script File: External Memory: Name=TRAP_vecttable: Alloc: select “ON” Application Note 171 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: External Memory: Name=ext_c: Size: insert “3M” Linker: Script File: External Memory: Name=ext_d: Size: insert “1M” Application Note 172 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: External Memory: Name=ext_c: Address: insert 0xA1000000 Name=ext_d: Address: insert 0xA2000000 Name=TRAP_vecttable: Address: insert 0xA1300000 Application Note 173 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: Sections: Space=linear: Alloc: select “extmem” Application Note 174 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Linker: Script File: Sections: Space=linear: Location: insert “ext_c” OK Application Note 175 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 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 176 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Double click: Main.c and change Global Variable menu from const char menu[] = "\r\n\n\n\n" "Program execution out of OnChipFlash\r\n" "====================================\r\n" "1 ... LED IO_P1_15 ON\r\n" "2 ... LED IO_P1_15 OFF\r\n" "3 ... LED IO_P1_15 blinking\r\n" " \r\n"; to const char menu[] = "\r\n\n\n\n" "Program execution out of OnBoardFlash\r\n" "=====================================\r\n" "1 ... LED IO_P1_15 ON\r\n" "2 ... LED IO_P1_15 OFF\r\n" "3 ... LED IO_P1_15 blinking\r\n" " \r\n"; Application Note 177 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Insert Map File: (Project Window File View) – TC1796 (Files) – right mouse button click – Add Existing Files – Browse Select TC1796.map Open - OK Application Note 178 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 179 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Generate your application program: Build Rebuild or Application Note 180 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" See Map File: Interrupt Vector Table: Click here to see Memory Map Application Note 181 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Trap Vector Table: Click here to see Memory Map Now you can close your project and Tasking EDE: File - Close Project Space File – Exit Application Note 182 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Programming is now complete. You can now load and run your program: Start pls-Debugger Application Note 183 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – Open Workspace Look in: select C:\TC1796 File name: select tc1796.wsp Open Cancel Application Note 184 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Tools – FLASH Programming … FLASH/OTP – Memory Device: select 2 MByte OnChip Program FLASH: FLASH/OTP – Memory Device: unclick to deactivate Enable Application Note 185 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" FLASH/OTP – Memory Device: select 4 MB External FLASH FLASH/OTP – Memory Device: click 9 Enable Application Note 186 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" click Setup … Program: click 9 Automatic Verify after Program OK Exit Application Note 187 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – Load Program Look in: select TC1796 File name: select tc1796.elf Open Application Note 188 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Click Program All Application Note 189 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Exit Exit Application Note 190 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – Close Workspace Yes File – Exit Application Note 191 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 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 192 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" OnBoardSRAM Test: Start Tasking EDE and open the project: File – Open Project Space Look in: select C:\TC1796 File name: select TC1796.psp Insert your application specific program: Double click: Main.h and insert the following Defines: #define RAM_MAX 1000000 // 1MByte-On-Board-SRAM ( max. 1048576 Bytes) Application Note 193 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Double click: MAIN.C and insert Global Variables: char cArray[RAM_MAX]; // 1MByte-On-Board-SRAM ( max. 1048576 Bytes) Application Note 194 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Double click: MAIN.C and insert the following code in the main function: register unsigned int index=0; char mb1[200]; // message buffer1 for sprintf() Application Note 195 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Double click: MAIN.C and insert the following code in the main function: //****ramtest*********************************************************** sprintf(mb1,"testing 1 MByte-On-Board-SRAM at %9x, pattern = 1010 B ...\r\n",cArray); myprintf(mb1); for(index=0; index<RAM_MAX; index++) cArray[index]=10; // 1010 b = 0xA = 10 d for(index=0; index<RAM_MAX; index++) { if(cArray[index]==10); else { myprintf("OnBoardSRAM ERROR !!!\r\n"); while(1){} //Loop_For_Ever } } sprintf(mb1,"testing 1 MByte-On-Board-SRAM at %9x, pattern = 0101 B ...\r\n",cArray); myprintf(mb1); for(index=0; index<RAM_MAX; index++) cArray[index]=5; // 01010 b = 0x5 = 5 d for(index=0; index<RAM_MAX; index++) { if(cArray[index]==5); else { myprintf("OnBoardSRAM ERROR !!!\r\n"); while(1){} //Loop_For_Ever } } sprintf(mb1,"1 MByte-On-Board-SRAM at %9x: (%u Byte(s)) ... ok\r\n",cArray,RAM_MAX); // Write formatted data to string mb myprintf(mb1); //********************************************************************** Application Note 196 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 197 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Configure Linker – Control: Project – Project Options Linker: Map File: click 9 Memory usage info OK Application Note 198 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Generate your application program: Build Rebuild or Click Reload document Application Note 199 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" See the Memory Usage: Now you can close your project and Tasking EDE: File - Close Project Space File – Exit Application Note 200 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Programming is now complete. You can now load and run your program: Start pls-Debugger File – Open Workspace Look in: select C:\TC1796 File name: select tc1796.wsp Open Cancel File – Load Program Look in: select TC1796 File name: select tc1796.elf Open click Program All Exit Exit File – Close Workspace Yes File – Exit Application Note 201 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 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 202 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 7.) Using of the TASKING - EDE Development Tools: Write programs for execution from OnBoardFlash (BURST-Mode) Application Note 203 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Start Tasking EDE and open the project: File – Open Project Space Look in: select C:\TC1796 File name: select TC1796.psp Open Insert your application specific program: Double click: Main.c and change Global Variable menu from const char menu[] = "\r\n\n\n\n" "Program execution out of OnBoardFlash\r\n" "=====================================\r\n" "1 ... LED IO_P1_15 ON\r\n" "2 ... LED IO_P1_15 OFF\r\n" "3 ... LED IO_P1_15 blinking\r\n" " \r\n"; to const char menu[] = "\r\n\n\n\n" "Program execution out of OnBoardFlash (Burst Mode!!!)\r\n" "=====================================================\r\n" "1 ... LED IO_P1_15 ON\r\n" "2 ... LED IO_P1_15 OFF\r\n" "3 ... LED IO_P1_15 blinking\r\n" " \r\n"; Application Note 204 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 205 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Double click: Main.c: insert application-specific-program: // the CPU interrupt system is globally disabled: DISABLE(); // 4-MBytes-On-Board-Burst-Flash switch to Burst-Mode switch_to_burst(); // the CPU interrupt system is globally enabled ENABLE(); Application Note 206 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – New Insert switch_to_burst_mode.c OK Application Note 207 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Insert code: /***************************************************************************** ** * ** * ** COPYRIGHT: (c) 2003 Infineon Technologies * ** * ** AUTHOR: Holger Dienst (AI MC MA TM) * ** * ** changed/used by: Wilhelm Brezovits, June 2006 * ** * ** DESCRIPTION: activate Burst Mode * ** * ** * *****************************************************************************/ #include <stdio.h> #include <stdlib.h> #include "MAIN.h" #include "ebu.h" #include "types.h" #define SETUP_ADR #define UNLOCK_ADR #define AMDSET_UP #define AMDUNLOCK #define AMDRESET #define AMDBURST #define AMDBURST_ENABLE 0x0555 * 4 0x02AA * 4 0x00AA00AA 0x00550055 0x00F000F0 0x00C000C0 0x00010001 void external_switch_program(void); // // // // // // // // // // // Note: German: Das Problem ist, daß die Routine die das Flash umschaltet (external_switch_program) nicht aus dem Flash laufen kann, daher muß diese erst ins RAM kopiert (mittels switch_to_burst) und dort ausgeführt werden. English: The routine which switches the Flash (external_switch_program) cannot be executed from the Flash. Therefore, this must be copied into the RAM (by switch_to_burst) and executed there. unsigned char mb2[200]; // message buffer2 for sprintf() void external_switch_program(void) { EBU *psEBU; u_int32 *puiAdr; u_int32 uiCS0_Base; psEBU = (EBU *)(EBU_BASE); uiCS0_Base = psEBU->ADDSEL0; uiCS0_Base &= EBUBASE_MSK; // enable burst on the flash puiAdr = (u_int32 *)(uiCS0_Base + SETUP_ADR); *puiAdr = AMDSET_UP; puiAdr = (u_int32 *)(uiCS0_Base + UNLOCK_ADR); *puiAdr = AMDUNLOCK; puiAdr = (u_int32 *)(uiCS0_Base + SETUP_ADR); *puiAdr = AMDBURST; puiAdr = (u_int32 *)(uiCS0_Base); *puiAdr = AMDBURST_ENABLE; *puiAdr = AMDRESET; // setting BUSCON0 psEBU->BUSCON0 &= ~EBUAGEN_MSK; psEBU->BUSCON0 |= EBUAGEN_BURST0; // setting BFCON psEBU->BFCON = EBUFETBLEN0_8 | EBUFBBMSEL0 | EBUWAITFUNC0 | EBUEXTCLK_4 | EBUDBA0; // get BFCON back for synchronizing uiCS0_Base = psEBU->BFCON; __isync(); Application Note 208 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" __dsync(); } void switch_to_burst(void) { u_int32 *puiSource; u_int32 *puiDestination; u_int32 *puiDataHeap; unsigned int byte_count=(u_int32)&switch_to_burst-(u_int32)&external_switch_program; puiDataHeap = malloc((u_int32)&switch_to_burst-(u_int32)&external_switch_program); if( puiDataHeap == NULL ) { myprintf("ERROR: Insufficient memory (heap) available !!!\r\n"); while(1){} //Loop_For_Ever } else { puiDestination = puiDataHeap; sprintf(mb2,"%u Byte(s) at %9x (heap) allocated\r\n",byte_count,puiDataHeap); //Write formatted data to string mb2 myprintf(mb2); byte_count=0; // first copy all codes to external sram myprintf("Copy Program into heap\r\n"); for(puiSource = (u_int32 *)&external_switch_program; puiSource < (u_int32 *)(&switch_to_burst); puiSource++) { *puiDestination = *puiSource; puiDestination++; byte_count++; } sprintf(mb2,"%u*4=%u Byte(s) copied into heap\r\n",byte_count,byte_count*4); myprintf(mb2); puiDestination = puiDataHeap; myprintf("JUMP to heap\r\n"); // jump to external ram // // // // // // // // // __asm("calli\t%0"::"a"(puiDestination)); // (possibility 1/3) WRONG !!! FAULTY !!! a2 is passed to the instruction template. a2 is part of the lower context and therefore not saved/restored. The compiler assumes that a2 remains constant as it is an input parameter. The technical reasoning for this is that otherwise all input parameters require a backup prior to passing them to the instruction template. The trick now is to tell the compiler that there is a possibility that the input parameter might change because you after all know what the instruction template is doing. One way would be the following: // __asm("calli\t%0":"=a"(puiDestination):"0"(puiDestination)); // (possibility 2/3) OK !!! // But another would be to just do the whole thing in C: ((void(*)(void))puiDestination)(); // (possibility 3/3) OK !!! free(puiDataHeap); myprintf("BACK from heap, Burst-Mode activated\r\n"); } } Note: // jump to external ram __asm("calli\t%0"::"a"(puiDestination)); Syntax see: TriCore User’s Manual, CHAPTER 3, TriCore C Language (next page): Application Note 209 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 210 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – Save (Project Window File View) – TC1796 (Files) – right mouse button click – Add Existing Files – Browse Select switch_to_burst_mode.c Open OK Application Note 211 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Application Note 212 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Double click: Main.h and insert Prototype of Global Function: extern void switch_to_burst(void); Application Note 213 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – New Insert types.h OK Insert code: /************************************************************************ * * * FILE : TYPES.H * * * * DESCRIPTION : Setting names for types * * * * COPYRIGHT : (c) 1999 Infineon Technologies * * * * AUTHOR : Holger Dienst (AI MC AE) * * * ************************************************************************/ #ifndef _TYPES_H #define _TYPES_H typedef typedef typedef typedef typedef typedef unsigned int u_int32; int int32; unsigned short u_int16; short int16; unsigned char u_int8; char int8; #endif /* _TYPES_H */ File – Save Application Note 214 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" File – New Insert EBU.h OK Insert code: /************************************************************************ * * * FILE : EBU.H * * * * DESCRIPTION : Structur and Bitsettings for EBU TC1796 * * * * COPYRIGHT : (c) 2003 Infineon Technologies AG * * * * AUTHOR : Holger Dienst (AI MC MA TM) * * * VERSION : 1.00 * * * * CHANGES : * * * ************************************************************************/ * #ifndef _EBU_H #define _EBU_H #define EBU_BASE (0xF8000000) /* Access Mode: R - Read-only register. 32 - Only 32-bit word accesses are permitted to that register/address range. E - Endinit protected register/address. PW - Password protected register/address. For more details refer to specification. */ typedef struct ebu { volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned Application Note int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int CLC; /* RESERVED0[1]; /* ID; /* RESERVED1[1]; /* CON; /* RESERVED2[3]; /* BFCON; /* RESERVED3[23]; /* ADDSEL0; /* RESERVED4[1]; /* ADDSEL1; /* RESERVED5[1]; /* ADDSEL2; /* RESERVED6[1]; /* ADDSEL3; /* RESERVED7[9]; /* BUSCON0; /* RESERVED8[1]; /* BUSCON1; /* RESERVED9[1]; /* BUSCON2; /* RESERVED10[1]; /* BUSCON3; /* RESERVED11[9]; /* BUSAP0; /* RESERVED12[1]; /* BUSAP1; /* RESERVED13[1]; /* BUSAP2; /* RESERVED14[1]; /* BUSAP3; /* RESERVED15[17];/* EMUAS; /* RESERVED16[1]; /* EMUBC; /* RESERVED17[1]; /* EMUBAP; /* RESERVED18[1]; /* EMUOVL; /* RESERVED19[5]; /* Clock Control Register (E) (32) */ Reserved */ Identification Register (32) */ Reserved */ Global Control Register (32) */ Reserved */ Burst Flash Control Register (32) */ Reserved */ Address Select Register 0 (32) */ Reserved */ Address Select Register 1 (32) */ Reserved */ Address Select Register 2 (32) */ Reserved */ Address Select Register 3 (32) */ Reserved */ Bus Configuration Register 0 (32) */ Reserved */ Bus Configuration Register 1 (32) */ Reserved */ Bus Configuration Register 2 (32) */ Reserved */ Bus Configuration Register 3 (32) */ Reserved */ Bus access parameter Register 0 (32) */ Reserved */ Bus access parameter Register 1 (32) */ Reserved */ Bus access parameter Register 2 (32) */ Reserved */ Bus access parameter Register 3 (32) */ Reserved */ Emulator Memory Address Select Register (32) */ Reserved */ Emulator Memory Bus Configuration Register (32) */ Reserved */ Emulator Memory access parameter (32) */ Reserved */ Overlay memory chip-select generation (32) */ Reserved */ 215 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" volatile unsigned int USERCON; /* Test/Control Configuration Register (32) */ } EBU; /* Global Control Register #define EBUEXTRECON */ #define EBUEXTSVM #define EBUEXTACC #define EBUEXTLOCK #define EBUARBSYNC #define EBUARBMODE_MSK #define EBUARBMODE_EBUDIS #define EBUARBMODE_EXTM #define EBUARBMODE_EXTS #define EBUARBMODE_NOARB #define EBUTIMOUTC_MSK #define EBUGLOBAL_CS_MSK #define EBUGLOBAL_CS0 #define EBUGLOBAL_CS1 #define EBUGLOBAL_CS2 #define EBUGLOBAL_CS3 #define EBUCS0FAM #define EBUEMUFAM */ 0x00000002 /* EBU External Address Extension Reconfiguration Control 0x00000004 0x00000008 0x00000010 0x00000020 0x000000C0 0x00000000 0x00000040 0x00000080 0x000000C0 0x0000FF00 0x00FF0000 0x00010000 0x00020000 0x00040000 0x00080000 0x08000000 0x10000000 /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* Burst Flash Control Register */ #define EBUFETBLEN0_MSK 0x0000000F #define EBUFETBLEN0_1 0x00000000 #define EBUFETBLEN0_2 0x00000001 #define EBUFETBLEN0_4 0x00000002 #define EBUFETBLEN0_8 0x00000003 #define EBUFBBMSEL0 0x00000010 #define EBUWAITFUNC0 0x00000020 #define EBUEXTCLK_MSK 0x000000C0 #define EBUEXTCLK_1 0x00000000 #define EBUEXTCLK_2 0x00000040 #define EBUEXTCLK_3 0x00000080 #define EBUEXTCLK_4 0x000000C0 #define EBUBFCMSEL 0x00000100 #define EBUEBSE0 0x00000200 #define EBUDBA0 0x00000400 #define EBUFDBKEN 0x00000800 #define EBUDTALTNCY 0x0000F000 #define EBUFETBLEN1_MSK 0x000F0000 #define EBUFETBLEN1_1 0x00000000 #define EBUFETBLEN1_2 0x00010000 #define EBUFETBLEN1_4 0x00020000 #define EBUFETBLEN1_8 0x00030000 #define EBUFBBMSEL1 0x00100000 #define EBUWAITFUNC1 0x00200000 #define EBUEBSE1 0x02000000 #define EBUDBA1 0x04000000 /* Address Select Register #define EBUREGENAB #define EBUALTENAB #define EBUMASK_MSK #define EBUALTSEG_MSK #define EBUBASE_MSK /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* */ 0x00000001 0x00000002 0x000000F0 0x00000F00 0xFFFFF000 /* Bus Configuration Register */ #define EBUCMULTMAP 0x0000007F #define EBUCMULTMAP_ADDRC 0x00000001 #define EBUCMULTMAP_AHOLDC 0x00000002 #define EBUCMULTMAP_CMDDELAY 0x00000004 #define EBUCMULTMAP_BURSTC 0x00000008 #define EBUCMULTMAP_DATAC 0x00000010 #define EBUCMULTMAP_RDRECOVC 0x00000020 #define EBUCMULTMAP_WRRECOVC 0x00000040 #define EBUWEAK_PREFETCH 0x00000100 #define EBUAALIGN 0x00000200 #define EBUCTYPE_MSK 0x00000C00 #define EBUCTYPE_NOMUX 0x00000000 #define EBUCMULT_MSK 0x0000E000 #define EBUCMULT_CM1 0x00000000 #define EBUCMULT_CM4 0x00002000 #define EBUCMULT_CM8 0x00004000 #define EBUCMULT_CM16 0x00006000 #define EBUCMULT_CM32 0x00008000 #define EBUENDIAN 0x00010000 #define EBUDLOAD 0x00020000 #define EBUPREFETCH 0x00040000 #define EBUWAITINV 0x00080000 #define EBUBCGEN_MSK 0x00300000 #define EBUBCGEN_CSM 0x00000000 #define EBUBCGEN_CM 0x00100000 Application Note EBU EBU EBU EBU EBU EBU EBU EBU EBU EBU EBU EBU EBU EBU EBU EBU EBU External Supervisor Mode Access Control */ External Access to FPI Control */ External Bus Lock Control */ Arbitration Inputs Evaluation Control */ Arbitration Strategy */ is Disabled */ is External Master */ is External Slave */ Arbitration is Disabled */ Time Out Control */ chip select global mask */ chip select global 0 */ chip select global 1 */ chip select global 2 */ chip select global 3 */ CS0 Fills Address Map */ CSemu Fills Address Map */ Fetch burst length Type 0 */ Fetch burst length 1 data access Type 0 */ Fetch burst length 2 data access Type 0 */ Fetch burst length 4 data access Type 0 */ Fetch burst length 8 data access Type 0 */ Flash burst buffer mode select Type 0 */ Operation of /WAIT input Type 0 */ BFCLK external clock */ BFCLK = LMBCLK */ BFCLK = LMBCLK/2 */ BFCLK = LMBCLK/3 */ BFCLK = LMBCLK/4 */ BFCLK only present during burst access */ ADV and BAA not 1/2LMBCLK delayed Type 0 */ Disable Burst Address Wrapping Type 0 */ Burst Clock Feedback Enable */ Latency Cycle Control */ Fetch burst length Type 1 */ Fetch burst length 1 data access Type 1 */ Fetch burst length 2 data access Type 1 */ Fetch burst length 4 data access Type 1 */ Fetch burst length 8 data access Type 1 */ Flash burst buffer mode select Type 1 */ Operation of /WAIT input Type 1 */ ADV and BAA not 1/2LMBCLK delayed Type 1 */ Disable Burst Address Wrapping Type 1 */ /* /* /* /* /* Memory Altseg Memory Memory Memory /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* Multiplier Map */ Multiplier Map addrc */ Multiplier Map aholdc */ Multiplier Map cmddelay */ Multiplier Map burstc */ Multiplier Map datac */ Multiplier Map rdrecovc */ Multiplier Map wrrecovc */ Code prefetch can be aborted by data access */ Address Alignment */ Cycle Typ */ Cycle Typ is non-multiplexed */ Cycle Multiplier Control */ Cycle Multiplier 1 */ Cycle Multiplier 4 */ Cycle Multiplier 8 */ Cycle Multiplier 16 */ Cycle Multiplier 32 */ Big Endian mode */ Data access always fed from external bus */ Code access always uses prefetch buffer */ #WAIT Input is active High */ Byte Control Signal Timing Mode */ Chipselect Mode */ Control Mode */ 216 Region Enable Control */ is always compared with LMB address */ Region Address Mask */ Region Alternate Segment */ Region Base Address */ V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" #define EBUBCGEN_WEM #define EBUPORTW_MSK #define EBUPORTW_16 #define EBUPORTW_32 #define EBUWAIT_MSK #define EBUWAIT_DIS #define EBUWAIT_ASYN #define EBUWAIT_SYN #WAIT */ #define EBUWAIT_NAND #define EBUXCMDDELAY_OFF #define EBUAGEN_MSK #define EBUAGEN_DEMUX #define EBUAGEN_BURST0 #define EBUAGEN_BURST1 #define EBUWRITE 0x00200000 0x00C00000 0x00400000 0x00800000 0x03000000 0x00000000 0x01000000 0x02000000 /* /* /* /* /* /* /* /* Write Enable Mode */ External Device Data Width Control */ 16 Bit */ 32 Bit */ External Waitstate Control */ External Waitstate Control OFF */ Asynchronous Input at #WAIT */ (Early for Burst Flash Devices) Synchronous Input at 0x03000000 0x0000000 0x70000000 0x00000000 0x20000000 0x50000000 0x80000000 /* /* /* /* /* /* /* NAND Flash Mode (not valid for Burst Flash Devices) */ External Command Delay Control OFF */ Address Generation Control */ Demultiplex address */ Burst Flash Type 0 access */ Burst Flash Type 1 access */ Write Protection */ /* Bus Access Parameter Register */ #define EBUDTACS_MSK 0x0000000F #define EBUDTARDWR_MSK 0x000000F0 #define EBUWRRECOVC_MSK 0x00000700 #define EBURDRECOVC_MSK 0x00003800 #define EBUDATAC_MSK 0x0000C000 #define EBUBURSTC_MSK 0x00070000 #define EBUWAITWRC_MSK 0x00380000 #define EBUWAITRDC_MSK 0x01C00000 #define EBUCMDDELAY_MSK 0x0E000000 #define EBUHOLDC_MSK 0x30000000 #define EBUADDRC_MSK 0xC0000000 /* /* /* /* /* /* /* /* /* /* /* Recovery cycles between different regions */ Recovery cycles between read and write accesses */ Recovery Cycles after write accesses */ Recovery Cycles after read accesses */ Data hold Cycles for write accesses */ Data Cycles during burst accesses */ Programmed Waitstates for Write Access */ Programmed Waitstates for Read Access */ Programmed command delay cycles */ Address Hold Cycles for multiplexes accesses */ Address Cycles */ /* Emulator Memory Control Register */ #define EBUOVL0 0x00000001 #define EBUOVL1 0x00000002 #define EBUOVL2 0x00000004 #define EBUOVL3 0x00000008 /* /* /* /* Overlay Overlay Overlay Overlay /* Test/Control Configuration Register */ #define EBUDIP 0x00000001 /* Disable Internal Pipelining */ /* External Access Configuration Register */ #define EBUAEXT0_MSK 0x000003FF /* with A[23..22] = 00 */ #define EBUAEXT2_MSK 0x000FFC00 /* with A[23..22] = 10 */ #define EBUAEXT3_MSK 0x3FF00000 /* with A[23..22] = 11 */ #define EBUFPILOCK 0x80000000 /* #endif Memory Memory Memory Memory Control Control Control Control for for for for Region Region Region Region 0 1 2 3 */ */ */ */ Address Extension Bits A[31..22] for External Access Address Extension Bits A[31..22] for External Access Address Extension Bits A[31..22] for External Access Gain Ownership of FPI Bus and Lock It */ /* _EBU_H */ File – Save Application Note 217 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" (Project Window File View) – TC1796 (Files) – right mouse button click – Add Existing Files – Browse Select EBU.h Select types.h Application Note 218 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Open OK EBU.h types.h Application Note 219 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Generate your application program: Build Rebuild or Now you can close your project and Tasking EDE: File - Close Project Space File – Exit Application Note 220 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Programming is now complete. You can now load and run your program: Start pls-Debugger File – Open Workspace Look in: select C:\TC1796 File name: select tc1796.wsp Open Cancel File – Load Program Look in: select TC1796 File name: select tc1796.elf Open Click Program All Exit Exit File – Close Workspace Yes File – Exit Application Note 221 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 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 222 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 8.) Time – Measurement: Insert application specific program (time measurement): For programming example Chapter 4: Program_Execution_From_Scratch-Pad-RAM_SPRAM Chapter 5: Program_Execution_From_OnChipProgramFlash Chapter 6: Program_Execution_From_OnBoardProgramFlash Chapter 7: Program_Execution_From_OnBoardProgramFlash_Burst-Mode Double click: Main.c and change Global Variable menu from volatile unsigned int blinking=ON; to volatile unsigned int blinking=OFF; Double click: Main.c and insert Global Variables volatile unsigned int i = 0; volatile unsigned int j = 0; Double click: Main.c and insert the following endless loop (before “while (1)”): // - the CPU interrupt system is globally disabled DISABLE(); while(1) // endless loop { IO_vTogglePin(IO_P1_15); // time-consuming, dummy operations for (i=0;i<=100000;i++) { __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); j=i; __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); } __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); } Application Note 223 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" Result: The frequency/time of the toggling pin IO_P1_15 is a measurement for the speed of the application: Program execution sorted by speed: Program execution out of SPRAM OnChipFlash OnBoardFlash (Burst Mode) OnBoardFlash Time [s] 0,0787 0,0907 0,3734 0,7854 Frequency [Hz] *1 12,7 11,0 2,7 1,3 Speed *1 … higher is better Application Note 224 V2.0, 2006-07 AP32110 TC1796 "Cookery-Book" 9.) Feedback (TC1796): Your opinion, suggestions and/or criticisms Contact Details (this section may remain empty 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 225 V2.0, 2006-07 http://www.infineon.com Published by Infineon Technologies AG