AN205435 Use Eclipse with F²MC-16LX/16FX Family MCUS This application note describes how to set up Eclipse so you can use it to develop your Cypress microcontroller applications. It will also highlight the important differences between Softune Workbench and Eclipse and give a short introduction in Eclipse in general. Contents 1 2 3 1 Introduction .................................................................. 1 1.1 Overview ............................................................. 2 1.2 Differences between Eclipse and Softune .......... 2 Installation ................................................................... 3 2.1 Java Runtime Environment (JRE) ....................... 3 2.2 Eclipse ................................................................ 3 2.3 Cypress Plug-in for Eclipse ................................. 3 2.4 Softune ............................................................... 5 2.5 MSYS .................................................................. 5 2.6 FLASHly .............................................................. 5 2.7 Set up the environment variable ......................... 6 First steps in Eclipse .................................................... 7 3.1 Create a project .................................................. 7 3.2 Configure flash programming .............................. 8 3.3 Add the Cypress controller files ........................ 11 3.4 3.5 Create a new main.c source file ........................ 11 Compile, link and if enabled flash the application .......................................... 13 4 Eclipse features ......................................................... 14 4.1 Special terms used by Eclipse .......................... 14 4.2 Views ................................................................ 15 4.3 Panes................................................................ 16 4.4 Code editor ....................................................... 16 4.5 Menu bar / Toolbar ........................................... 19 4.6 Project settings ................................................. 19 A Appendix ................................................................... 20 A.1 Links to Cypress ............................................... 20 A.2 Links to third party sites .................................... 20 Document History............................................................ 21 Introduction Eclipse is a well known development environment developed by a large open source community including companies like IBM. Since its architecture is based on plug-ins it allows a wide variety of features to be added as in this case support for the Softune compiler tool chain for Cypress microcontrollers. This application note describes how to set up Eclipse so you can use it to develop your Cypress microcontroller applications. It will also highlight the important differences between Softune Workbench and Eclipse and give a short introduction in Eclipse in general. This application note is referring to version 1.1.3 of the Cypress Eclipse plug-in with Eclipse Galileo (v3.5). Please note that most software presented in this application note is not developed or owned by Cypress. Therefore Cypress can not take any responsibilities or provide support for any problems you encounter by using it. www.cypress.com Document No. 002-05435 Rev. *A 1 ² Use Eclipse with F MC-16LX/16FX Family MCUS 1.1 Overview In order to be able to use Eclipse to build Cypress MCU targeted applications the following software components are required: Eclipse for C/C++ (i.e. Eclipse with the C Development Tools plug-in) Cypress plug-in for Eclipse Provides project dialogs specific for Cypress microcontrollers and the interface to the Softune tool chain Softune compiler tool chain (Softune C Compiler, Softune Assembler Pack) Primary component to build applications for Cypress microcontrollers MSYS Optional; allows to use the external builder to build the projects as it provides the commands used in the process of compiling applications, i.e. make (handles the build process itself), echo (prints messages on the console) and rm (deletes files); alternatively the internal builder can be used which sometimes requires to recompile the whole project and not only the changed and/or new files Java Runtime Environment 6 Required to run Eclipse FLASHly Optional; allows flashing of the target MCU directly controlled by Eclipse Eclipse does provide a lot of other plug-ins which can improve workflows, e.g. integration with Subversion and CVS or modelling tools. 1.2 Differences between Eclipse and Softune Feature Softune Eclipse Tool chain help file integration Yes No Simulator Yes No Debugger Yes No 1 Dedicated Error/Warning list No No 1,2 Project management + ++ 3 Yes Integration with code documentation (Doxygen) No Yes Syntax highlighting Yes (basic) Yes (advanced) Code completion No Yes Code formatter No Yes Refactoring No Yes Outline view No Yes Code folding No Yes 1 : Planned for future revisions 2 : Not fully functional 3 : External tool can be controlled by the development environment www.cypress.com Document No. 002-05435 Rev.*A Yes 3 Integrated flash programming 2 ² Use Eclipse with F MC-16LX/16FX Family MCUS 2 Installation Installation of the different software components required to work with Eclipse. In order to use Eclipse properly some additional software packages are required. This chapter will guide you through the installation steps. The following software besides Softune is neither developed nor owned by Cypress. Thus Cypress can not guarantee that the given addresses will remain correct. If you encounter an invalid address please report it to Cypress (www.cypress.com/spansionsupport). The installation steps for a full set up including all optional components are: 2.1 1. Java Runtime Environment 2. Eclipse 3. Eclipse Plug-in 4. Softune 5. MSYS 6. FLASHly 7. Set up the PATH environment variable Java Runtime Environment (JRE) Install the current JRE from java.sun.com/javase/downloads/index.jsp. 2.2 Eclipse Open www.eclipse.org/downloads/, download the “Eclipse IDE for C/C++ Developers” and unpack it. 2.3 Cypress Plug-in for Eclipse There are two ways to get the plug-in in your local copy of Eclipse: Online installation through Eclipse’s software updater Manual installation Depending on your environment you can go either way. Online installation has the advantage that the plug-in can automatically be updated when there is a new version whereas manual installation does not require an internet connection on the target machine when installing. The whole Eclipse folder including the installed plug-in can also be copied to other machines without any problems so you can integrate the plug-in in Eclipse once and then copy Eclipse to other machines. 2.3.1 Online installation Run Eclipse. When asked to select a workspace select the path where the projects should be stored later on. www.cypress.com Document No. 002-05435 Rev.*A 3 ² Use Eclipse with F MC-16LX/16FX Family MCUS Go to the Eclipse Workbench: Note: If your workstation is connected to the internet through a proxy you have to set it up first (menu entry Window – Preferences, tree location General – Network Connections. Active Provider has to be set to Manual in this case). Select Help – Install New Software... from the menu: www.cypress.com Document No. 002-05435 Rev.*A 4 ² Use Eclipse with F MC-16LX/16FX Family MCUS Click on Add... and enter a name for the new update site (e.g. “Cypress Plug-in”) and the location of the update site “www.cypress.com/softune_eclipse”. Close the dialog by clicking OK. Select the newly entered update site from the dropdown box: Expand the item “Uncategorized” and check the box in front of the “Cypress MCU Integration” then click next and follow the dialogs. Ignore the warning about the plug-in being unsigned content and when asked to restart Eclipse confirm it. 2.3.2 Manual installation Open the website (www.cypress.com/softune_eclipse) in a browser and download the latest version of the plug-in. Copy the plug-in archive into the plugins subfolder of your Eclipse installation. 2.4 Softune In the package selection menu of the Softune installer only “SOFTUNE C Compiler” and “SOFTUNE Assembler Pack” have to be selected for use with Eclipse. For information regarding the installation of Softune refer to its website (www.cypress.com/products/swb_(f2mc-16)_v3). Note: Softune is not provided via Internet but only available on CD/DVD available from your distributor. 2.5 MSYS Go to the download page of MinGW (www.mingw.org). Open the “MSYS Base System” – “Current Release” (as of writing this document the current release is 1.0.11). Download msysCORE-*-bin.tar.gz and unpack it (e.g. to C:\MSYS). 2.6 FLASHly Get FLASHly from www.holgerium.de/elektronik/index.htm and unpack it (e.g. to C:\Program Files\FLASHly). www.cypress.com Document No. 002-05435 Rev.*A 5 ² Use Eclipse with F MC-16LX/16FX Family MCUS 2.7 Set up the environment variable In order for Eclipse to be able to find the binaries from Softune, MSYS and FLASHly each of them have to be added to the environment variable PATH in Windows. 1. Open the System dialog (either through the Control Panel or right click on the My Computer icon – Properties). 2. Select the Advanced tab. 3. Click on Environment Variables. 4. Check whether there already is a “PATH” entry in the upper list. If so select it and click on Edit otherwise click on New. 5. Enter “PATH” as Variable name. As Variable value enter the path names to the binaries of Softune (C:\Softune\bin), MSYS (C:\MSYS\bin) and FLASHly (C:\Program Files\FLASHly), each entry separated by a semicolon. If there was a value before just add the new paths to the end of the old values. 6. Close all dialogs with OK. www.cypress.com Document No. 002-05435 Rev.*A 6 ² Use Eclipse with F MC-16LX/16FX Family MCUS 3 First steps in Eclipse Basic steps to the first project. In the following a standard development process is described: 3.1 Create a project Configure flash programming Add Cypress controller files Create source files Compile, link and program the flash Create a project Do a right click in the Project Explorer on the left of the main Eclipse window and select New – C Project. Enter a name for the project and select “Cypress 16bit Executable” as Project type and the appropriate microcontroller name as Toolchain. Note: If your microcontroller is not available from the list refer to the documentation of the plug-in on its web site on how to add new devices or contact the developer of the plug-in. Click Next > to add a second compiler configuration besides Release (e.g. Debug) or just Finish to create the project with a Release configuration only. www.cypress.com Document No. 002-05435 Rev.*A 7 ² Use Eclipse with F MC-16LX/16FX Family MCUS 3.2 Configure flash programming Open the project properties through the menu (Project – Properties) or through the context menu of the project in the Project Explorer – Properties: www.cypress.com Document No. 002-05435 Rev.*A 8 ² Use Eclipse with F MC-16LX/16FX Family MCUS On the left side go to C/C++ Build – Settings. If you have a microcontroller which is supported by FLASHly navigate to FLASHly – General and enter the COM port the board is connected to in the appropriate field (also update the other fields if needed by your hardware, e.g. the crystal frequency): www.cypress.com Document No. 002-05435 Rev.*A 9 ² Use Eclipse with F MC-16LX/16FX Family MCUS If FLASHly does not support your microcontroller uncheck the box FLASHly on the page Additional Tools in Toolchain: Close the dialog by clicking on OK. www.cypress.com Document No. 002-05435 Rev.*A 10 ² Use Eclipse with F MC-16LX/16FX Family MCUS 3.3 Add the Cypress controller files As with Softune it is recommended to use the template files for the used microcontroller series from Cypress, including the microcontroller resource definitions (e.g. mb96f348hs.h, mb96f348hs.asm), the start-up assembler code (start.asm) and the vector table (vectors.c). The Project Explorer supports drag and drop so files can directly be dragged in the project from the system’s file navigator. Alternatively they can be copied to the clipboard and pasted in the project. 3.4 Create a new main.c source file Note: Normally you would copy the main.c from the template just like the other files. This is just an example on how to create new source files. Click on New C/C++ Source File in the toolbar: Enter “main.c” as name for the source file and click on Finish: Open the new file and enter some code to test the setup (example code is for the SK-16FX-EUROSCOPE starter kit): www.cypress.com Document No. 002-05435 Rev.*A 11 ² Use Eclipse with F MC-16LX/16FX Family MCUS Save the file. www.cypress.com Document No. 002-05435 Rev.*A 12 ² Use Eclipse with F MC-16LX/16FX Family MCUS 3.5 Compile, link and if enabled flash the application Click on Build project. If everything was setup correctly the tool invocations should scroll through the console window on the bottom pane of Eclipse. If the code compiled fine and programming with FLASHly is enabled the programmer should automatically start. Depending on flash size it will take some time to erase the chip and flash the new application: If everything went fine FLASHly will automatically close itself. www.cypress.com Document No. 002-05435 Rev.*A 13 ² Use Eclipse with F MC-16LX/16FX Family MCUS 4 Eclipse features This chapter will give you a short introduction on the features Eclipse offers you while developing applications. Menubar and Toolbar Left pane 4.1 Code editor pane Status bar Perspective selector Bottom pane Right pane Special terms used by Eclipse Perspective Describes a set of views, their sizes and positions selected by the user to be shown in an environment for a development purpose. The current perspective can be switched in the perspective selector. Examples: C/C++-Perspective shows views for code, structural overview, compilation SVN Repository Exploring shows views for Subversion repositories, version history, Subversion file properties View A functional entity which can be docked to a pane. Will be explained in chapter 4.2. Examples: Project Explorer, Outline, Console Pane Sub window in eclipse providing a tabbed environment to dock views to. www.cypress.com Document No. 002-05435 Rev.*A 14 ² Use Eclipse with F MC-16LX/16FX Family MCUS 4.2 Views New views can be opened through the menu point Window – Show View. Views can be moved to other locations inside a pane, different panes and to new panes by dragging the tab header of the view with the mouse. Many views provide settings through a menu which can be opened by clicking on the white triangle: The important views for application development in C are already opened by default in new installations. 4.2.1 Project Explorer Shows the projects and their files in the currently opened workspace. The context menu of elements provides lots of functions for files and projects. 4.2.2 Problems Shows the warnings and errors output by the compiler, assembler, linker. If there was a reference to a source file and line number you can directly jump to the problem by double clicking on an entry. www.cypress.com Document No. 002-05435 Rev.*A 15 ² Use Eclipse with F MC-16LX/16FX Family MCUS 4.2.3 Outline Provides a structural overview on the source file currently visible in the editor. By default it shows all declarations of includes, defines, variables and methods. 4.2.4 Console The Console view shows the output of the tools which are run by the plug-in when building the application. Here can be seen what arguments were passed to the tools or what errors the tools may have thrown. 4.3 Panes Each of the panes in Eclipse is a tabbed area where views can be docked. The code editor pane is a special pane in that it does not allow docking any view but only shows the primary elements of the currently opened perspective. A pane can be maximized to the whole Eclipse window by double clicking on its tab section. 4.4 Code editor The code editor is the main part of the development environment. It includes a lot of features which can reduce the time spent on non-programming stuff like formatting. 4.4.1 Code folding and line numbers Neither code folding nor display of line numbers are enabled by default. To enable them open the preferences (Menu – Window – Preferences) and go to General – Editors – Text Editors. On the right check the box Show line numbers. Then go to the section C/C++ – Editor – Folding and check the box Enable folding when opening a new editor and any other option you might want. Apply the changes and close the preferences dialog. www.cypress.com Document No. 002-05435 Rev.*A 16 ² Use Eclipse with F MC-16LX/16FX Family MCUS Next time a new editor tab is opened there will be small plus and minus signs in front of methods and, if selected, in front of conditional statements. By clicking on a minus sign the code section inside the block will be folded and by clicking on a plus it will be unfolded. 4.4.2 Mark occurrences If the cursor is in an identifier the editor automatically highlights occurrences of the same identifier in the file. It also shows the occurrences by putting small white dashes on the right bar of the editor to easily jump to them in the whole file. 4.4.3 Code completion When typing an identifier press Ctrl + Space to get a box showing all identifiers which begin with the already typed characters. You can select one with the cursor keys and enter or the mouse to complete the identifier. 4.4.4 Code formatting If the currently opened source file should be completely formatted press Ctrl + Shift + F. Note: The rules for the formatter can be configured in the preferences (Menu – Window – Preferences) under C/C++ – Code Style. On the right select Edit to get to the formatting preferences editor. The name of the profile has to be changed to save the changes. 4.4.5 Refactoring Refactoring allows for renaming identifiers in the whole project without breaking references to them. Right click on the identifier you want to rename, go to Refactor – Rename. www.cypress.com Document No. 002-05435 Rev.*A 17 ² Use Eclipse with F MC-16LX/16FX Family MCUS Enter a new name for the identifier and click on Preview. Now the changes that would be made to the source code will be shown. If you are ok with them press OK. www.cypress.com Document No. 002-05435 Rev.*A 18 ² Use Eclipse with F MC-16LX/16FX Family MCUS 4.5 Menu bar / Toolbar The toolbar consists of multiple sections. They are from left to right: File operations (New, Save, Print, Build all) FLASHly invocation File creation (New Project, New Folder, New File, New Class) Build options (Build project, Manage Configurations) Run commands (Debug, Run, Run tool) Search functions (Open Element, Open Task, Search) Editor options (Mark Occurrences, Block selection, Show special characters) Navigation (Go to annotations, last edited locations, backward/forward) Many functions in Eclipse can also be reached with hotkeys which can also be defined by the user in the preferences under General – Keys. 4.6 Project settings The project properties dialog can be opened by a right click on a project in the Project Explorer and a click on Properties (or the menu Project – Properties). The project properties dialog controls many project related options. The most important ones are for the build process. The settings for the different tools can be found under C/C++ Build – Settings. The tree to the right resembles the project settings of Softune where the top-level elements of the tree correspond to the tabs in Softune and the second-level elements correspond to the categories of the drop-down boxes in Softune. The options themselves are basically the same. www.cypress.com Document No. 002-05435 Rev.*A 19 ² Use Eclipse with F MC-16LX/16FX Family MCUS A Appendix A.1 Links to Cypress A.2 Softune Workbench: www.cypress.com/products/swb_(f2mc-16)_v3 Links to third party sites MinGW / MSYS: http://www.mingw.org FLASHly: http://www.holgerium.de/elektronik/index.htm Java Runtime Environment: http://java.sun.com/javase/downloads/index.jsp Eclipse: http://www.eclipse.org/downloads/ Cypress plug-in update site: www.cypress.com/softune_eclipse www.cypress.com Document No. 002-05435 Rev.*A 20 ² Use Eclipse with F MC-16LX/16FX Family MCUS Document History Document Title: AN205435 - Use Eclipse with F²MC-16LX/16FX Family MCUS Document Number: 002-05435 Revision ECN Orig. of Change Submission Date ** — NOFL 11/10/2009 Initial release. *A 5232475 NOFL 04/21/2016 Migrated Spansion Application Note from MCU-AN-300113-E-V10 to Cypress format. www.cypress.com Description of Change Document No. 002-05435 Rev.*A 21 ² Use Eclipse with F MC-16LX/16FX Family MCUS Worldwide Sales and Design Support Cypress maintains a worldwide network of offices, solution centers, manufacturer’s representatives, and distributors. To find the office closest to you, visit us at Cypress Locations. PSoC® Solutions Products ARM® Cortex® Microcontrollers cypress.com/arm PSoC 1 | PSoC 3 | PSoC 4 | PSoC 5LP Automotive cypress.com/automotive Cypress Developer Community Clocks & Buffers cypress.com/clocks Interface cypress.com/interface Lighting & Power Control cypress.com/powerpsoc Memory cypress.com/memory PSoC cypress.com/psoc Touch Sensing cypress.com/touch USB Controllers cypress.com/usb Wireless/RF cypress.com/wireless Forums | Projects | Videos | Blogs | Training | Components Technical Support cypress.com/support PSoC is a registered trademark and PSoC Creator is a trademark of Cypress Semiconductor Corporation. All other trademarks or registered trademarks referenced herein are the property of their respective owners. Cypress Semiconductor 198 Champion Court San Jose, CA 95134-1709 Phone Fax Website : 408-943-2600 : 408-943-4730 : www.cypress.com © Cypress Semiconductor Corporation, 2009-2016. This document is the property of Cypress Semiconductor Corporation and its subsidiaries, including Spansion LLC (“Cypress”). This document, including any software or firmware included or referenced in this document (“Software”), is owned by Cypress under the intellectual property laws and treaties of the United States and other countries worldwide. Cypress reserves all rights under such laws and treaties and does not, except as specifically stated in this paragraph, grant any license under its patents, copyrights, trademarks, or other intellectual property rights. If the Software is not accompanied by a license agreement and you do not otherwise have a written agreement with Cypress governing the use of the Software, then Cypress hereby grants you a personal, non-exclusive, nontransferable license (without the right to sublicense) (1) under its copyright rights in the Software (a) for Software provided in source code form, to modify and reproduce the Software solely for use with Cypress hardware products, only internally within your organization, and (b) to distribute the Software in binary code form externally to end users (either directly or indirectly through resellers and distributors), solely for use on Cypress hardware product units, and (2) under those claims of Cypress’s patents that are infringed by the Software (as provided by Cypress, unmodified) to make, use, distribute, and import the Software solely for use with Cypress hardware products. Any other use, reproduction, modification, translation, or compilation of the Software is prohibited. TO THE EXTENT PERMITTED BY APPLICABLE LAW, CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS DOCUMENT OR ANY SOFTWARE OR ACCOMPANYING HARDWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. To the extent permitted by applicable law, Cypress reserves the right to make changes to this document without further notice. Cypress does not assume any liability arising out of the application or use of any product or circuit described in this document. Any information provided in this document, including any sample design information or programming code, is provided only for reference purposes. It is the responsibility of the user of this document to properly design, program, and test the functionality and safety of any application made of this information and any resulting product. Cypress products are not designed, intended, or authorized for use as critical components in systems designed or intended for the operation of weapons, weapons systems, nuclear installations, life-support devices or systems, other medical devices or systems (including resuscitation equipment and surgical implants), pollution control or hazardous substances management, or other uses where the failure of the device or system could cause personal injury, death, or property damage (“Unintended Uses”). A critical component is any component of a device or system whose failure to perform can be reasonably expected to cause the failure of the device or system, or to affect its safety or effectiveness. Cypress is not liable, in whole or in part, and you shall and hereby do release Cypress from any claim, damage, or other liability arising from or related to all Unintended Uses of Cypress products. You shall indemnify and hold Cypress harmless from and against all claims, costs, damages, and other liabilities, including claims for personal injury or death, arising from or related to any Unintended Uses of Cypress products. Cypress, the Cypress logo, Spansion, the Spansion logo, and combinations thereof, PSoC, CapSense, EZ-USB, F-RAM, and Traveo are trademarks or registered trademarks of Cypress in the United States and other countries. For a more complete list of Cypress trademarks, visit cypress.com. Other names and brands may be claimed as property of their respective owners. www.cypress.com Document No. 002-05435 Rev.*A 22