Home

Developing and debugging your STM8S

image

Contents

1.
2. kyy UM0834 User manual Developing and debugging your STM8S DISCOVERY application code January 2011 Introduction This document complements the information in the STM8S datasheets by describing the software environment and development recommendations required to build an application around the STM8S DISCOVERY It also explains how to use the STM8S firmware and STMBS touch sensing libraries provided by STMicroelectronics in order to develop cost effective applications In addition ST provides a development package which can be used to build an application running on the STM8S DISCOVERY This package includes application code examples and a project template Reference documents STM8S DISCOVERY user manual UM0817 ST Visual Develop STVD user manual UM0036 Adjustable LED blinking speed using STM8S DISCOVERY touch sensing key UM0833 Displaying variable voltage on a LED bar using STM8S DISCOVERY UM0848 Generating PWM signals using STM8S DISCOVERY UM0856 STM8S reference manual RM0016 STM8S105xx datasheet Doc ID 16499 Rev 3 1 42 www st com Contents UM0834 Contents 1 Overview of STM8 software development toolchain 6 1 1 ST Visual Develop STVD 22225 ius kr Ram RE ERR 6 1 2 ST Visual Programmer STVP 0 00 cee eee eee 7 13 C and assembly compilers nannu annae 7 1 4 Firmware lIBIatl6S maser rores purion Bee se Pee ese EAE Bae bs 7 2 Installing the development too
3. My own project 5 stmBs i2c h a stm8s uart2 h Project template stm s_ite h stmBs uart3 h 2 C PWM g stm8s iwdg h E stm8s_wwdg h Linking the libraries to your STVD project No library linked to your STVD project If your application does not require any library follow the instructions below 1 Edit stm8s h and comment define USE STDPERIPH DRIVER to be able to use the register structures memory mapping and constant definitions for each peripheral For an example of application code that does not use any library refer to the ADC project of the STM8S DISCOVERY development package Doc ID 16499 Rev 3 31 42 Building and running your STVD project UM0834 32 42 Figure 29 No libraries linked Workspace x Hes STYD_workspace stw 52 I r E 53 O if defined USE STDPERIPH DRIVER stvd project E Es m y 54 E Comment the line below if you will 43 Source Files 3 main c not use the perip als drivers T F 55 In this c tk drivers will a 2 stm8 interrupt vector c i x not be included and the applic n a 2 stmes itc m iacl led and t licatio e C FWLb code wi e Tslib 56 oased on direct access to a Sq Include Files AP j de te 8 stmBs_it h 2 define Us FWLib Pe 8 stm8s h T E rsLib 60 O For FLASH routines select whether a pointer will be declared as near 2 a External Dependencies bytes handle v RS Workspace main c s
4. STM8S DISCOVERY_dev Project My_own_project STVD Cosmic STVD_workspace s tw for Raisonance select STM8S DISCOVERY_dev Project My_own_project STVD Raisonance STVD_workspa ce stw stvd project appears in the STVD workspace window as shown in Figure 25 Its structure is slightly different from the structure of My own project directory in STM8S Discovery dev package Source Files has the same content as STM8S DISCOVERY_dev Project My_own_project STVD src Source Files FWLib contains the STM8S standard library source files A Source Files TSLib contains the STM8S touch sensing library source files Include Files contains My own project include files Include Files FWLib contains the STM8S standard library include files Include Files TSLib contains the STM8S touch sensing library include files Figure 25 Creating the STVD workspace for your project amp ST Visual Develop STVD_workspace stw main c sa File Edit View Project Build Debug Debuginstrument Tools Window Help asdal WO d stvd_project l Debug Workspace STYD_workspace stw 48 stvd project 43 Source Files i main c f B stm8 interrupt vector c Int inite loop stmas it c while 1 E FwLib TSLib Include Files 8 stmas_it h E FwLib TSLib External Dependencies void main void At Workspace x I I I T Build Tools A Find in Files 1 A Find in Files 2 A Debug A
5. Step 1 Connect to http www cosmicsoftware com download_stm8_16k php and fill in the information form see Figure 2 Click Submit to access the download page Figure 2 Cosmic compiler form 3 Cosmic Software Download Microsoft Internet Explorer provided by Corporate Package Fabricost De CA Wew Favertes Tods teb MES O O DBO Paw tm OSS 5 L8 3 i B Adress B hcl vem conmcsoftmare comldonnioad sni 16 500 Embedded Innovation ABOUTUS NEWSAEVENTS CONTACT US Home Dovnload stm FREE 16k Download of the FREE stmB 16k version Fill and rubenit the form Below to download the free rte compiler 16K version To use this product you must register with Cosmic Software The installation procedure vill instruct you to send a message to Cosmic Software at rto 16kftosmicfr to perform this regirtration As rero you vill receive the appropriate free license for this product Name Company Address ZIP Code City L Country Seled Phone Fax Emaii Seem Geer Gevowncoan MBrsuvporr Copyright 2008 COSMIC Software Doc ID 16499 Rev 3 9 42 Installing the development toolchain UM0834 2 Step2 Download and run the installation software wizard see Figure 3 Figure 3 Downloading Cosmic compiler software wizard Fie fd Yew lute do tht O O Hiat O S DMa Addes AB het ffwrn cosmcsoftmare comdekdstr 16 ocho Embedde
6. The Discover application project is proposed only with the Cosmic compiler because the STMB8 touch sensing library V1 3 0 included in the STM8S Discovery dev package is not yet compatible with the Raisonance compiler PWM The PWM application code example is only based on the STM8S standard library It explains how to use a timer to generate PWM signals Refer to user manual Generating PWM signals using STM8S DISCOVERY UM0856 for details on the PWM application software code implementation and library configuration The PWM project is compatible both with Cosmic and Raisonance compilers ADC The ADC application code example explains how to use the ADC to convert the analog voltage delivered by a variable resistor It does not use any library Refer to user manual Read UM0848 Displaying variable voltage on a LED bar UM0848 for details on the ADC application software code implementation and project configuration This example requires additional components to be mounted on the board The ADC project is compatible both with Cosmic and Raisonance compiler Project template This directory contains a standard project template that should be used to start any application software development Project structure Each project is structured as follows inc This directory contains all the header files for your application including the configuration files for the touch sensing library STM8 TSL RC Configuration h and for the standa
7. 5 Timer Driver Description Li bra ry Fi rmware B 6 1 0 Driver Description V1 3 0 4 Doc ID 16499 Rev 3 21 42 Configuring the option bytes for your application UM0834 4 22 42 Configuring the option bytes for your application The option bytes allow to configure the device hardware features and memory protection They are stored in a dedicated memory block Refer to the option bytes section of the STM8S105xx datasheet for a detailed description STVP can be used to program the STMB8S option bytes It is part of the free software package provided by STMicroelectronics This easy to use tool has a graphical interface allowing to read write and verify the STM8 Flash programming memory data EEPROM and option bytes The STVP executable is available from the Windows start menu Open the STVP GUI and select Configure gt Configure ST Visual Programmer from the main menu toolbar The configuration dialog box opens In the hardware list select ST LINK as programming board In the port list select USB as the host PC port to which the ST LINK is connected Only the ports that are compatible with the selected hardware are displayed in the programming mode list select SWIM The programming modes displayed 1 depend on your programming equipment In the device list select STM8S105x6 as the ST microcontroller you are going to program see Figure 18 Figure 18 Select your MCU 6 Confi
8. As an example download the Discover application demonstration available at http www st com stm8s discovery To read the data set by the library for example to check flags ensure that the touch sensing main state machine is in idle state to avoid spurious values to be retrieved Doc ID 16499 Rev 3 ky UM0834 Description of firmware libraries Figure 16 User application flowchart TSL dni bee Initializes memory API and structures in the touch sensing library User function performing the initialization of ERIC Oe AW Paneer TS1 key state machine SAARE User application code linked to TS1 detected state Main touch sensing state machine TSL_Action performing the sequencing of all the actions _ concerning the touch keys ExtraCode_StateMachine ai17222 3 2 4 STM8S touch sensing library online help An online help stm8 ts um chm is located in the STM8S touch sensing library installation directory to help you with the structure of the library see Figure 17 Figure 17 STM8S touch sensing library online help home page E STM8 TSL On line Help Manual ef OG amp te Hide Locate Stop Refresh Home Prnt Options Contents Index Search Favorites Main Page Modules Main Page Release Notes Data Structures Files io oiii Related Pages B 1 Introduction B 2 Library Architecture 3 API Description STM8 Touch Sensing B 4 Core Description H B
9. STM8S touch sensing library are part of the STM8S DISCOVERY development package that is available from the STM8S DISCOVERY web page at http www st com stm8s discovery Warning The STMB8S touch sensing library includes the STM8S standard firmware library Make sure you have the latest version of each library see http www st com mcu STM8S standard firmware library The STMBS standard firmware library contains a collection of routines data structures and macros covering the features of the STM8S peripherals as well as a description of the device drivers see Figure 1 1 The STM8S standard firmware library allows to develop an application on any STM8S device without the need for in depth study of each peripheral specifications It saves significant time that would otherwise be spent in coding while simultaneously reducing application development and integration cost It contains a set of example for each peripheral All these examples are provided with workspace and project definition files for STVD and Cosmic C compiler to allow loading and compiling them easily into you development environment These examples are developed to run on an STM8S208xx device with STMicroelectronics STM8 128 EVAL evaluation board They have to be considered as example codes to develop your own application Some examples have already been tailored to run on the STM8S DISCOVERY They are available from the STM8S DISCOVERY web pages at http www st com stm8
10. UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE ST PRODUCTS ARE NOT RECOMMENDED AUTHORIZED OR WARRANTED FOR USE IN MILITARY AIR CRAFT SPACE LIFE SAVING OR LIFE SUSTAINING APPLICATIONS NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY DEATH OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE ST PRODUCTS WHICH ARE NOT SPECIFIED AS AUTOMOTIVE GRADE MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK Resale of ST products with provisions different from the statements and or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever any liability of ST ST and the ST logo are trademarks or registered trademarks of ST in various countries Information in this document supersedes and replaces all information previously supplied The ST logo is a registered trademark of STMicroelectronics All other names are the property of their respective owners 2011 STMicroelectronics All rights reserved STMicroelectronics group of companies Australia Belgium Brazil Canada China Czech Republic Finland France Germany Hong Kong India Israel Italy Japan Malaysia Malta Morocco Philippines Singapore Spain Sweden Switzerland United Kingdom United States of America www st com 42 42 Doc ID 16499 Rev 3 ky
11. at start of debugging session Cancel Creating your STVD project This section explains step by step how to create your own application project The touch sensing and the firmware libraries can be used or not according to the kind of application code to develop All projects must be created starting from STM8S Discovery_dev development package see Section 5 1 Description of the STM8S DISCOVERY development package Creating your project structure The best way to proceed is to start from the Project_template directory 1 Extract the content of STM8S Discovery_dev zip file on your PC 2 Copy the Project template directory and rename it My own project see Figure 24 Your STVD project comes already structured thus simplifying the project creation Figure 24 Creating your project structure C3 STM85 Discovery dev S O Libraries 4 C3 STM8 TouchSensing Driver 20 My own project O STM8S StdPeriph Driver o me C3 Project o src 58 3 ape amp G3 sTVD i 3 Discover O Cosmic O My own project bs Raisonance 73 Project template 8 G PWM Doc ID 16499 Rev 3 ky UM0834 Building and running your STVD project 5 3 2 Creating your STVD project 1 Open STVD and click File gt Open Workspace 2 Browse for the Workspace location and select STVD_workspace stw in the Cosmic or Raisonance directory depending on the compiler you intend to use For Cosmic select
12. peripherals used by your application stm8s type h plus the c and h files corresponding to the peripherals which define statement are uncommented must be copied from STM8S DISCOVERY_dev Libraries STM8S_StdPeriph_Driver inc and STM8S q Doc ID 16499 Rev 3 UM0834 Building and running your STVD project 4 DISCOVERY_dev Libraries STM8S_StdPeriph_Driver src into Include Files FWLib and Source Files FWLib of STVD project respectively You can also decide to copy the whole drivers c and h files from the library to your STVD project Figure 31 Workspace X Hg STVD workspace stw styd_project QQ Source Files main c Y stm8 interrupt vector c FWub 53 T3Lib Sq Include Files stm8s it h cg FWLib 8 stm s h 3 T3Lib External Dependencies f amp Workspace Linking the STM8S standard firmware library step 2 THKKTAKAKAKKHRHAARARAR ELEELE 77 define OPT 1 78 79 GPIO a ftttttttttittttt 80 define PIO 1 E 81 82 JR EG GR d d d GA Rd d RE RR I RE E E E E AS EATS a I2C d WODCROOR A OA S S OR A A B S A S S EEEE EEEE EEEE 83 define I2C 1 84 85 fERRARAREERAAAARAAAEAREARERE RAR AREREARE ITC d REAAKAAAAKAATARAT AS eee ee ee ee main c stm8s_conf h Workspace x Folies E stm s_rst c Hes STVD workspace stw STM8S Discovery dev Ej eH stvd project Librarie
13. timer c 69 A HODIAED READ CAP NUM BCAL OVA 4 6 42 Doc ID 16499 Rev 3 UM0834 Overview of STM8 software development toolchain 1 2 1 3 1 4 ST Visual Programmer STVP STVP is a easy to use graphical interface allowing to read write and verify the code and data programmed in your STM8 microcontroller Flash program memory data EEPROM and option bytes STVP also features a project mode for saving programming configurations and automating programming sequences C and assembly compilers The C and assembly compilers are seamlessly integrated into the STVD development environment They allow to directly configure and control the building of your application from an easy to use graphical interface The supported compilers are the following e Cosmic C compiler for STM8 free version up to 16 Kbytes of code For more information refer to http www cosmic software com e hRaisonance C compiler for STM8 free up to 16 Kbytes of code For more information refer to http www raisonance com e STMB8 assembler linker This is a free assembly toolchain included in the STVD toolset It allows to assemble and link your application source code Firmware libraries The STMBS standard firmware library is a complete package consisting of drivers for all the standard peripherals of Performance line STM8S20x and Access line STM8S10x microcontrollers It is written in strict ANSI C code and is fully MISRA C 2004 c
14. with ST products STMicroelectronics NV and its subsidiaries ST reserve the right to make changes corrections modifications or improvements to this document and the products and services described herein at any time without notice All ST products are sold pursuant to ST s terms and conditions of sale Purchasers are solely responsible for the choice selection and use of the ST products and services described herein and ST assumes no liability whatsoever relating to the choice selection or use of the ST products and services described herein No license express or implied by estoppel or otherwise to any intellectual property rights is granted under this document If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION OR INFRINGEMENT OF ANY PATENT COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT
15. 0 0 e eee eee 28 5 3 1 Creating your project structure 00 00 cece eee 28 2 42 Doc ID 16499 Rev 3 ky UM0834 Contents 5 3 2 Creating your STVD project 000 e eee 29 5 3 3 Linking the libraries to your STVD project 00 0 eee 31 5 4 Updating the libraries llle 36 5 4 1 Updating the STM8S standard firmware library 4 36 5 4 2 Updating the STM8 touch sensing library llle 36 6 Building debugging and running your application 37 6 1 Building your application 2s esckekkkeRE amp e ieee X REPE REX RERESE EN EE 37 6 2 Debugging your application liliis 38 6 3 Online help cessus o XAR REO EUER ie tga ki bead de RR CR EORR RU amp 40 7 Revision history iuuissacm im kn nOn Q8 8 8 e aa we 41 ky Doc ID 16499 Rev 3 3 42 List of tables UM0834 List of tables Table 1 Table 2 4 42 Touch sensing library configuration for STM8S DISCOVERY using TS1 touchkey Document revision history lisse n Doc ID 16499 Rev 3 UM0834 List of figures List of figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Figure 8 Figure 9 Figure 10 Figure 11 Figure 12 Figure 13 Figure 14 Figure 15 Figure 16 Figure 17 Figure 18 Figure 19 Figure 20 Figure 21 Figure 22 Figure 23 Figure 24 Figure 25 Figure 26 Figure 27 Figure 28 Figure 29 Figure 30 Figur
16. Console For Help press F1 Ln 1 Col 1 MODIFIED READ CAP NUM SCRL OVR Ready 3 Check that the compiler STM8 Cosmic or Raisonance and its path are correct by selecting Project gt settings from the STVD main menu see Figure 26 Doc ID 16499 Rev 3 29 42 Building and running your STVD project UM0834 30 42 Figure 26 Checking the selected compiler Project Settings 5 stvd project Settings for Debug x General Debug MCU Selection C Cornpiler Assembler KIG Defaults Toolset Info Toolset STM8 Cosmic X Project specific toolset path Toolset sub paths relative to the Root path Bin path Include path Library path Output directory Cancel 4 Go to Projects gt settings gt MCU selection and select STM8S105C6 from the MCUs list Make sure that MCU selected is displayed in the selected MCU field before clicking OK see Figure 27 Figure 27 Select the MCU Project Settings Settings for Debug m Es stvd project General Debug MCU Selection C Compiler Assembler 4 gt Filter Show MCUs containing MCUs STM8L152C6 I Ccoccccccceeeece STM8S103F2U STM8S103F3P STM8S103F3U STM8S103K3U STM8S105C4 v Select Selected MCU STM8S105C6 Cancel Doc ID 16499 Rev 3 q UM0834 Building and running your STVD project 5 3 3 5 Configure
17. EY PIA RUE dicere gee Y SCKEY_P1_DRIVEN_SHIELD_MASK 0x08 i ur Pin 3 for active shield fc NI J Key port P2 not used P3 COU 0 Key port P3 not used Multichannel key feature Multichannel key NUMBER OF MULTI CHANNEL KEYS 0 disabled GPIOA ELECTRODES MASK 0x00 GPIOB ELECTRODES MASK 0x00 GPIOC ELECTRODES MASK Ox0A Defines the electrode GPIOD ELECTRODES MASK 0x00 mask for each GPIO Electrode mask GPIOE ELECTRODES MASK 0x00 used GPIOF ELECTRODES MASK 0x00 Mask must be set to 0x00 GPIOG ELECTRODES MASK 0x00 for unused GPIOs GPIOH ELECTRODES MASK 0x00 GPIOI ELECTRODES MASK 0x00 3 2 3 20 42 Developing your application with the STM8S touch sensing library Figure 16 shows the main flowchart that is to be followed to develop an application using the touch sensing library with the STM8S DISCOVERY The application code must call some API functions to initialize the library and manage the acquisition state machines The function TSL nit must be called once during the initialization of the complete system It is usually done in the main routine The ExtraCode Init performs the initialization of all the touchkeys implemented and enabled in the STM8 TSL RC Configuration h The function TSL Action must be called periodically during system execution It is the main state machine which sequences all the actions concerning all the touchkeys The application user code must be developed inside the function ExtraCode StateMachine
18. Kit STMS Lite Toolset Register for a C compiler license to output up to 16 Kbytes of code This registration allows you to get an activation code for the Lite toolset to output code up to 16 Kbytes in size for STMB and ST7 First download and install Ride and RKit STM8 Free downloads Then obtain the Activation Code on this page Instructions are provided below Name Company Address1 Address2 City Zip code Country Select a County E mail The Activation Code will be sent to this email do not want to receive other product news from Raisonance mail Subsctibe Unsubscribe Doc ID 16499 Rev 3 13 42 Installing the development toolchain UM0834 2 2 3 14 42 Figure 9 Serial key information form Address 2 Attp www mcu raisonance com index php PHPSESSID 9f9F6om 7 1 jv3kc8fdco6otck46 amp bdx amp aliasestm8 st7 registration M Support Recent newsletters Your E mail s RKit STM8 Lite Toolset Register for a C compiler license to output up to 16 Kbytes of code This registration allows you to get an activation code for the Lite toolsetto output code up to 16 Kbytes in size for STM8 and ST7 First download and install Ride and RKit STM8 Free downloads Then obtain the Activation Code on this page Instructions are provided below Serial Key EL qp JL Get your Activation Code Compil
19. STVD to use ST LINK as debug instrument see Figure 23 a Click Debug instrument gt Target Settings b Select target Swim ST Link in the target list 6 Copy stm8s h to the Include Files FWLib directory of your STVD workspace see Figure 28 Right click on the FWLib directory under stvd project A Select Add Files to Folder Browse the sm8s h file location in STM8S DISCOVERY dev Libraries STM8S_StdPeriph_Driver inc 7 Make sure include stm8s h is present of your main c file Figure 28 Copy stm8s h to Include Files FWLib Workspace x saa include stm8s h Private defines Hrs STVD workspace stw stvd project Source Files LE main c a stm _interrupt_vector c o o a 2 ag Private function prototypes A zm 5558 X Sy Include Files ARE B stm s_it h Private functions re 555585558 04 2 53 TSLib External Dependencies void main void T 3 E Workspace main c Folders x E stm s h E stm amp s rst h STMeS Discovery dev A E stm s adci h E stm8s_spi h 3 Libraries i stm8s adc2 h iE stm8s tim1 h STM8 TouchSensing Driver B stm s_awu h stm s tim2 h C STMSS stdPeriph Driver j stm8s beep h stm8s tim3 h om B stm8s_can h EJ stm8s tim4 h sre B stm8s clk h Z stm8s tim5 h amp O Project A stm8s_exti h i stm8s tim6 h 3 apc ig stm s flash h B stm8s type h C Discover j stm s_gpio h E stm8s uartl h
20. UE u32 16000000 The peripheral interrupt function file stm8s_it c must be modified to include the code to handle the interrupts used by your application The stm8s_type h file includes common 16 42 Doc ID 16499 Rev 3 ky UM0834 Description of firmware libraries types and constants used by the peripheral drivers Each peripheral driver is made up of the following files e The source code stm8s_ lt periph gt c containing all the software functions required to use the corresponding peripheral e The header stm8s_ lt periph gt h including the peripheral function prototypes as well as the variables constant and structures used within these functions The flow that must be followed to create your application software using the STM8S standard firmware library is described in Section 5 3 Creating your STVD project Figure 12 stm8s conf h peripheral define statements FG dA EE ECCL CLLCLCLCLCLELCLLLELLLELLLEEILLET CLE WokchoW WB A 8 WB A 8 n n Ns nn a a a define CLK 1 fOWCRCRCHCACh A Ch h hCh ACA ACA hCh hCh A Ch ACA Ch Ch ACA Ch Ch A A A A A A A T EXTI KRESS define EXTI 1 fot d d d d d d d dd d dk kddtitttttttt t FLASH DAT EEPROM 555 55t 514t define FLASH 1 qONONCNCAChONCAChOHCA Ch AONChCAONCh A ON Ch Ch A CR A AUN A AUN UN A N OPTION BYTES Wok Wk oW A8 WB 8 A8 n Ns Nn ntn define OPT 1 JOWCRCRCCACH A Ch h hCh hCh hCh hCh hCh hCh hCh Ch Ch Ch Ch ACA A A Ch A A A A GPIO Wohn WB WA 8 A8 n x8 Nn n x
21. VSTM8S Discovery My own project Libraries STM8 TouchSensing Driver 36 42 Doc ID 16499 Rev 3 ky UM0834 Building debugging and running your application 6 6 1 Building debugging and running your application Once your have developed your application code created your workspace environment and launched STVD you can start building debugging and programming your application to the target microcontroller Building your application Once your project is created the build context is enabled by default It allows to access all the commands required to set up customize and build your application The build configuration is available by selecting Build gt Configurations from the STVP main menu toolbar It allows to change the application building settings Two preset configurations are available in STVD e Debug This configuration creates a version of your application that allows using all the STVD advanced debugging features When using this configuration output files are saved in the Debug directory in your workspace directory e Release This configuration creates a version of your application that uses the default optimization for your toolset This version of your application is ready to be programmed to your target microcontroller Follow the sequence below to build a project 1 Ensure that the Debug configuration is selected by clicking Build Configurations If the Debug configuration is not selected highli
22. ate If it is not download the latest release see Section 5 4 Updating the libraries Follow the steps below to link the touch sensing library to your STVD project 1 Configure the library according to the number of touchkeys up to 24 sliders up to 2 and wheels up to 2 used in your application a b d Configure STM8 TSL RC Configuration h To use only the touch sensing key TS1 reuse the configuration file from the Discover project by copying STM8 TSL RC Configuration h from STM8S DISCOVERY_dev Project Discover inc to your project folder STM8S DISCOVERY_dev Project My_own_project inc Otherwise copy the original configuration file STM8 TSL RC Configuration TOADAPT h available in STM8S DISCOVERY_dev Libraries STM8_TouchSensing_Driver inc to your project folder STM8S DISCOVERY_dev Project My_own_project inc Rename it STM8 TSL RC Configuration h Set the parameters in compliance with your application hardware refer to the touch sensing library online help available in the installation directory Copy STM8 TSL RC Configuration h to the root of the Include Files directory in the STVD workspace panel All the sources and header files c and h except for the STM8 TSL RC Configuration TOADAPT h see above have to be copied from STM8SDISCOVERY_dev Libraries STM8S_TouchSensing_Driver sre and STM8SDISCOVERY_dev Libraries STM8S_TouchSensing_Driver inc to Source Files TSLib and Include Files TSLib respectively Ad
23. d Innovation 7 ABOUTUS NEWS REVENTS CONTACT US PRODUCTS A SEHVICES SUPPORT DOWNLOAD ate FREE 26h Download of the FREE stmD 16k version Thank you for the information gt gt cl hare to download lt lt Don t forget thet this product olii n suon ab Rd 3 Step3 Follow the wizard instructions to install the Compiler see Figure 4 Do not forget to register for a free license and click Register by Email You will receive the license file by e mail Figure 4 Cosmic compiler installation wizard Cosmic 16K Compiler Registration 16K C Compiler InstallShield Wizard REGISTER NOW TO GET YOUR FREE LITE VERSION TOOLS PRODUCT exse H OSTID exsxeononenen USER USER DISPLAY lt DISPLAY gt HOSTNAME lt HOSTNAME gt DISK_SERIAL_NUM lt DISK_SERIAL_NUM gt u USER Create a desktop icon DEM d Register your license skip the registration if you already have a license Company lt COMPANY gt Country Janeane Phone Fax Optional Jansen ienna Register by Email Edit Email and Register Write to File Cancel required 10 42 Doc ID 16499 Rev 3 UM0834 Installing the development toolchain 4 Step 4 Copy the licence file that you have received into the directory Program files COSMIC CXSTM8_16K License see Figure 5 Figure 5 Cosmic compiler C Program Files COSMIC CXSTM8_16K License File Edit View Favorite
24. d in the Discover project Please refer to Section 3 2 STMS8S touch sensing library for more information and to user manual Adjustable LED blinking speed using STM8S DISCOVERY touch sensing key UM0833 for an example Doc ID 16499 Rev 3 35 42 Building and running your STVD project UM0834 Figure 33 Linking the STM8 touch sensing library step 2 Project Settings Settings for Debug S MCU Selection C Compiler Assembler Pre Link Linker gt E stvd project Category Input Defaults Script Lkf file name OutputPath Target Nam n v Auto Vector file name Vector addr Asre stm8_interrupt_vector c Bl ox8000 Segment Section name From To Options Code Constants 0x8080 Oxtfff const text TSL_IO_ALCODE Eeprom 0x4000 0x43ff Zero Page 0x0 Oxff Ram 0x100 Ox5ff Command line cink ToolsetLibOpts o DutputPath TargetSName smB A m OutputPath T argetSName map v Cancel 5 4 Updating the libraries 5 4 1 Updating the STM8S standard firmware library To update the STM8S standard firmware library 1 Download the new release from http www st com mcu 2 Copy the inc and src directories in VSTM8S DISCOVERY_dev Libraries STM8S_StdPeriph_Driver 5 4 2 Updating the STM8 touch sensing library To update the STMB8 touch sensing library 1 Download the new release from http www st com mcu 2 Copy the inc and src directories in
25. d the include stm8 tsl rc api h statement in your main c file Doc ID 16499 Rev 3 ky UM0834 Building and running your STVD project Note Figure 32 Linking the STM8 touch sensing library step 1 Workspace Ges STVD workspace stw gs stvd project Source Files tm8_interrupt_vector c E stm s_it c FWLib 3 8 TSLib E stm8 tsl rc api c stm8 tsl rc iodriver c stm8 tsl rc multichannelkey c stm8 tsl rc services c EA stm8 tsl rc singlechannelkey c ES stm8 tsl rc timerdriver c Sy Include Files B stm8_tsl_rc_configuration h E stm8s ith FWLib B stm8s h J E TSUb 8 stm8 tsl rc api h 8 stm8 tsl rc checkconfig h E stm8 tsl rc internal B stm8 tsl rc iodriver h B stm8_tsl_rc_multichannelkey h B stm8 tsl rc services h E stm8 tsl rc singlechannelkey h E stm8 tsl rc timerdriver h External Dependencies i A Workspace X include stm8 tsl rc api h void main void gt Infinite loop while 1 lt 2 Some functions must be aligned to even memory addresses see Figure 33 a Click project gt setting from the STVD main menu b Select the linker tab and then select the input category c Under Segment Section name add TSL IO ALCODE in the code Constants section and assign the r2 option to it A specific main c structure is required to correctly use the touch sensing features This structure is already implemente
26. dded to the project stm8_tsl_rc_api c defines the functions used to communicate between the STM8S touch sensing library and the user code It is associated with stm8_tsl_rc_api h that contains the API function prototypes structures variables and constants stm8_tsl_rc_api h must be included in the main routine STM8_TSL_RC_Configuration h contains the library static configuration parameters that must be set in compliance with your application hardware Check that the define statements are filled in with the correct values See Table 1 for an example of define statement configuration for an application using the single touch sensing button of STM8S DISCOVERY TS1 The other define statements must remain unchanged thresholds integrator settings IIR filter settings The STM8 TSL RC Configuration h file can be updated to support up to 24 keys and 2 wheels or sliders Doc ID 16499 Rev 3 19 42 Description of firmware libraries UM0834 Table 1 Touch sensing library configuration for STM8S DISCOVERY using TS1 touchkey Function define statement Value Comment MCU selection STM8S 1 TIMACQ TIM3 isiti i TIM Acquisition timer TIMACQ CNTR ADD 0x5328 3 base address Time base timer TIMTICK TIM4 LOADREF_PORT_ADDR GPIOC_BaseAdress m EN p Port PC4 select Load I O LOADREF BIT 0x04 ort PC4 selected SCKEY P1 KEY COUNT 1 Mean pl ies 1 SCKEY_P1_PORT_ADDR GPIOC_BaseAddress di ee Single channel ke SEK
27. e 31 Figure 32 Figure 33 Figure 34 Figure 35 Figure 36 Figure 37 Figure 38 Figure 39 Figure 40 STVD OVOIVIOW ix wicca ceed pad Geddes ered nha n dac a oe aad week rom des 6 Cosmic compiler form llsseseeeeeeeeeee hrs 9 Downloading Cosmic compiler software wizard lille 10 Cosmic compiler installation wizard llle 10 Cosmic compiler i 22m l2224k2smId cec 2 edd dea ea de o a due bate ree t ene Rd a 11 Raisonance compiler installation wizard llle 12 Activation code registration ille eh 13 Personal information form illis 13 Serial key information form assau aaaea 14 Selecting the Cosmic compiler for the Discover project 000000 eee eeae 14 STMSBS standard firmware library architecture llle 16 stm8s conf h peripheral define statements 0 00 eee 17 STM8 firmware library online help home page lselseleele 17 STMBS touch sensing library software architecture 0 00 cee eee eee 18 STMBS touch sensing functional architecture llle 19 User application flowchart llis RI eee 21 STMSBS touch sensing library online help home page lsselselsensnse 21 Select your MCU sssssseeeeeseees hh hrs 22 STVP option byte selection menu 2 20 ae 23 STVP option byte programming menu sssseeeeseee 24 STVP option byte programming message sssleselel ee 24 STMB8S Discov
28. ed see Figure 21 Doc ID 16499 Rev 3 23 42 Configuring the option bytes for your application UM0834 24 42 Figure 20 STVP option byte programming menu no project STVP ll File Edit Project Configure Read Program Verify Erase Blank Check View Help s ecu EN NUNC ahha ITEE Mal All tabs on active sectors if any Value 100 00 80 00 00 00 00 00 00 Function AIN2 a D Alternate Function TL Port DO Alternate Function TIM3_CH2 Port Do Alternate Function TIM3_CH2 euin mina m eman rn Program the current Unknown ST4INK STM8S105x6 SWIM o Figure 21 STVP option byte programming message Function AIN4 gt Programming OPTION BYTE area ti lt OPTION BYTE programming completed Verifying OPTION BYTE area OPTION BYTE successfully verified lt Unknown ST LINK STM85105x6 SWIM Doc ID 16499 Rev 3 UM0834 Building and running your STVD project 5 5 1 5 1 1 Building and running your STVD project Description of the STM8S DISCOVERY development package ST provides a complete development package the STM8S Discovery_dev It allows to easily get started with the STM8S DISCOVERY by simplifying application code development and execution using the touch sensing or the standard peripherals drivers This package can be downloaded together with the present user manual from http www st com stm8s di
29. er settings STVD uses the default compiler defined at the first launch of the toolchain This compiler is not defined during the installation You can select a different compiler for a specific project in the General tab of the STVD Project gt Settings window Figure 10 Selecting the Cosmic compiler for the Discover project Project Settings Settings for Debug General Debug MCU Selection C Compiler Assembler 4 8 discover Defaults Toolset Info Toolset STM8 Cosmic v v Project specific toolset path Root path Program Files COSMIC CXSTMS 16K ER Toolset sub paths relative to the Root path Bin path Po Include path JHstmB Library path bb Dutput directory Cancel q Doc ID 16499 Rev 3 UM0834 Description of firmware libraries 3 3 1 Description of firmware libraries The STM8S microcontroller family is provided with both the STM8S standard firmware library and the touch sensing firmware library It is strongly recommended to use the libraries to develop your project as proposed in the the STM8S Discovery development package and implemented in the Discover and PWM projects see Section 5 1 Description of the STM8S DISCOVERY development package The development package also contains the ADC project which uses neither the STM8S standard firmware library nor the touch sensing firmware library The STMBS standard firmware library and the
30. ery dev package content 0 00 cece eese 25 Selecting the debug instrument 0 0 0 cette 28 Creating your project structure 2 2 0 tte 28 Creating the STVD workspace for your project 60 0c cece eee eee eee 29 Checking the selected compiler 000 0c eee eae 30 Select the MOU i memoirs iure ghe Bean TRU EO RARE She Se eee 30 Copy stm8s h to Include Files FWLib 2 0 0 0 0 BB 31 No libraries linked llis Ar 32 Linking the STM8S standard firmware library step 1 0 0000 e eee eee 32 Linking the STM8S standard firmware library step 2 0 00 00 c eee eee eee 33 Linking the STM8 touch sensing library step 1 lille 35 Linking the STM8 touch sensing library step 2 000000 ee 36 Selecting the project configuration 0 0 ee 37 Building your project 0 0 0 cee ttt 38 Building successful message 00 teens 38 Debugging your application 0 0 0 III 39 Peripheral registers window 1 1 0 eee 39 Watch windOW issus sena mee ace eg a Re ce eed bare E ens 40 STVD online help llssieeeeseeeee RR hu 40 Doc ID 16499 Rev 3 5 42 Overview of STM8 software development toolchain UM0834 1 Overview of STM8 software development toolchain To develop compile and run an application software on an STM8S microcontroller the following software toolchain components are required e Integrated development en
31. ght it and click Set Active see Figure 34 Figure 34 Selecting the project configuration Project Configurations Project a Configurations Debug Add Release Remove EM Set Active Es Rename 2 Once the building options are correctly configured configure your project settings a Select Project gt Settings from the STVD main menu toolbar b The Project settings window opens and displays all the options of your toolset compiler assembler and linker You can then customize these options For more Doc ID 16499 Rev 3 37 42 Building debugging and running your application UM0834 information on the available options for your toolset refers to the STVD online help available by clicking Help in the STVD main menu toolbar Once your MCU is selected Project gt Settings gt MCU Selection and your building options are configured use the Build menu to build and rebuild your application or compile your source files see Figure 35 The build command lines and possible warnings and or errors are displayed in the build tab of the Output window see Figure 36 Figure 35 Building your project 1 ST Visual Develop Discover stw main c amp File Edit View Project Build Debug Debuginstrument Tools Window Help 8 edo amp compile main c Ctr F7 i3 Build F7 Rebuild all Workspace Batch Build lg Discover stw Clean discover Configu
32. guration Hardware ST MDT2 KIT ST MDT4 EPB ST MDT4 KIT ST MDTS EPB ST MDT6 EPB2 ST MDT EPB2 ST MDTH1 EPB ST MDTS1 EPB ST MDTU2 EPB ST MDTU3 EPB Port r Programming made Device STM8L101x2 STM8L101x3 STM8L101x3_Cutl STM8L152x6 STM85103F2 STM8S103F3 STM85103K3 STM85105x4 STM85105x6 lt Select the OPTION BYTE tab and click Read gt Current tab in the menu toolbar All the STM8S105 option bytes and their respective values are displayed in the window see Figure 19 Doc ID 16499 Rev 3 UM0834 Configuring the option bytes for your application Figure 19 STVP option byte selection menu no project STVP File Edit Project Configure Read Program Verify Erase Blank Check View Help EcGec t Il mE i BE A Address Range Ar All tabs on active sectors if any Value 00 00 80 00 00 00 00 00 00 Port B5 Alternate Function AINS Port B4 Alternate Function AIN4 Port B3 Alternate Function AIN3 Port B2 Alternate Function AIN2 Port D Alternate Function TLI Port DO Alternate Function TIM3 CH2 Port DO Alternate Function TIM3 CH2 mi om s Read the current tat Bene ST LINK STMBS105x6 SWIM 7 To program an option byte to a new value a Click the option byte description and select the value b Click Program gt Current tab in the main menu toolbar see Figure 20 c Ifthe operation has completed successfully the Output windows is display
33. ication note AN2927 available on http www st com mcu Warning The STM8S touch sensing library versions earlier than V2 X X are not compatible with the Raisonance compiler Figure 14 STM8S touch sensing library software architecture Application layer Configures the library STM8S105 resources STM8S touch sensing library working principles ai17224 The STMBS touch sensing library is a set of compatible C files It includes the API that makes the interface with the other software layers a core set of files performing basic functions main state machine key state machine services plus the drivers to control timers and GPIOs Doc ID 16499 Rev 3 ky UM0834 Description of firmware libraries 3 2 2 Note The touch sensing library is based on a 2 state machines see Figure 15 e Main state machine The main state machine manages the sequence of the common actions concerning the touch sensing keys Signal acquisition Data interpretation e Key state machine Each key has its own state machine to manage its states calibration idle detect etc Figure 15 STM8S touch sensing functional architecture Application layer Core E state mace fo Mainstate machine H Services STM8S105 ressources ai17225 Configuring the STM8S touch sensing library In applications using the STM8S touch sensing library all the library sources and header files must be a
34. lchain eee 8 2 1 Downloading and installing STVD 0 0 c eee eee 8 2 2 Downloading and installing the compilers 000 eee 8 2 2 1 Installing the Cosmic compiler lille 8 2 2 2 Installing the Raisonance compiler sellers 11 2 2 3 Compiler settings lilssleie eh 14 3 Description of firmware libraries Ls 15 3 1 STM8S standard firmware library llle 15 3 1 1 Description of the STM8S standard firmware library 16 3 1 2 STMSBS standard firmware library online help Lese 17 3 2 STM8S touch sensing library llle 18 3 2 1 STMBS touch sensing library working principles 18 3 2 2 Configuring the STM8S touch sensing library 4 19 3 2 3 Developing your application with the STM8S touch sensing library 20 3 2 4 STMBS touch sensing library online help 2 00005 21 4 Configuring the option bytes for your application 22 5 Building and running your STVD project 25 5 1 Description of the STM8S DISCOVERY development package 25 5 1 1 Eibrari8s siia see dg e onec eon e eb Redde e Bem Goa a wR Rus 25 5 1 2 Application code examples sessiles 26 5 1 3 Project structure esince istaci wa a ere 26 5 2 Running the STM8S Discovery examples sls 27 5 3 Creating your STVD project 0 0
35. llation The serial key will appear as shown in Figure 7 b To get your free 16 Kbyte activation code go to http www raisonance mcu com Fill the question form with your personal information see Figure 8 and the registration form with your serial key see Figure 9 After this operation you will receive your activation code by e mail and you will be granted a free 16 Kbyte Raisonance compiler licence to be used by STVD 12 42 Doc ID 16499 Rev 3 q UM0834 Installing the development toolchain Figure 7 Activation code registration Activation Code Registration Type the Serial Number you received when you purchased the kit With the Following Serial Key identifying your computer and your Serial Number you can request an Activation Code from Web or by email Paste the Activation Code in the edit box and then select Next to activate it Step 1 User Information Serial Number This computer Serial Key Eig m lari Reyes aris ny d arii oy ea AeA Step 2 Use one of the Following links to request an Activation Code http www Raisonance com license raisonance com Step 3 Paste the Activation Code and select Next Figure 8 Personal information form http www mcu raisonance com index php PHPSESSID 9F9f om 1 jv3kc8Fdcosotck46 amp _bdx alias stm8_st _registration INTROLLER Support Recent newsletters R
36. ng your ST microcontroller Building and debugging appl Introduction Welcome to ST Visual Develop STVD STVD is a powerful integrated development environment for ST microcontrollers This Windows based environment provides interfaces for all phases of application development from building and debugging your application to ications For building your application STVD supports ST Assembler Linker Cosmic C Raisonance C and Metrowerks C toolsets Its graphic interface provides easy access to a range of options when building your application for debugging or programming to your microcontroller When debugging your application STVD supports a complete range of in circuit debugging and emulation hardware It can also be used as a stand alone tool providing a software Doc ID 16499 Rev 3 UM0834 Revision history 7 Revision history Table 2 Document revision history Date Revision Changes 04 Nov 2009 1 Initial release Updated list of reference documents on cover page Modified url of STM8S DISCOVERY page 08 Feb 2010 2 Added warning in Section 3 2 STM8S touch sensing library Reworked Section 5 Building and running your STVD project Replaced 04 Jan 2011 3 http www st com stonline products support micro files sttoolset exe by http www st com Doc ID 16499 Rev 3 41 42 UM0834 Please Read Carefully Information in this document is provided solely in connection
37. nut a define GPIO 1 3 1 2 STM8S standard firmware library online help 4 An online help stm8s_fwlib_um chm is available inside the firmware installation directory to help you with the structure of the library see Figure 13 Figure 13 STM8 firmware library online help home page E STMBS Firmware Library O G amp amp Hide Locate Refresh Home Font Print Options Main Page Related Pages Modules Data Structures Files Directories Contents Index Search Favorites z EXE Firmware Library x ADC2 Examples 2 E C Aw Examples 1 BEEP Examples 1 s CAN Examples 1 STMSS Firmware CLK Examples 3 x EXT Examples 1 Lib ary xi FLASH Examples 5 S GPIO Examples 2 A inne D eas lt Doc ID 16499 Rev 3 17 42 Description of firmware libraries UM0834 3 2 3 2 1 18 42 STM8S touch sensing library The STM8S touch sensing library is composed of a set of functions variables and structures see Figure 14 The STMB8S touch sensing library allows detecting physical touch on the capacitive sensing keys by controlling the charge discharge timing cycle of an RC network composed of a single resistor and the touch electrode capacitance Any variation in the RC charge discharge timing resulting from a change in the electrode capacitance is detected and then filtered For detailed information related to the RC acquisition principle refer to the appl
38. ompliant The STMBS touch sensing library endows any STM8 microcontroller with touch sensing capabilities This firmware offers a complete and robust solution to manage capacitive sensing keys wheels and sliders Refer to Section 3 1 STM8S standard firmware library and Section 3 2 STM8S touch sensing library for details on the installation and configuration of these libraries Doc ID 16499 Rev 3 7 42 Installing the development toolchain UM0834 2 2 1 2 2 Note 2 2 1 8 42 Installing the development toolchain Downloading and installing STVD STVD software is available from http www st com To install STVD download the installation software and follow each step of the installation wizard When the installation is complete the executable is available from START gt Programs gt ST Toolset gt Developement Tools gt ST Visual Develop or under C Program Files STMicroelectronics st_toolset stvd Downloading and installing the compilers Cosmic and Raisonance compilers are compatible with STVD They are available together with their documentation at the following urls e Cosmic http www cosmicsoftware com download stm8 16k php e Raisonance http Awww mcu raisonance com A free license is required to use the compilers Installing the Cosmic compiler To install the Cosmic compiler follow the sequence described below Doc ID 16499 Rev 3 ky UM0834 Installing the development toolchain 4
39. r 1 045009 PB CR2 Port B control register 2 Port C Port D Port E Port G Flash External Interrupt Control Register ITC Reset RST Clock Control CLK Window Watchdog W wDG Independent Watchdog IWDG Auto Wake Up AWU Beeper BEEP Serial Peripheral Interface SPI 12C Bus Interface I2C TIN Tinivareal semal h ranaivar tranemittar MARTI Value 0x00 Oxc0 0x00 0x00 0x00 Doc ID 16499 Rev 3 39 42 Building debugging and running your application UM0834 6 3 40 42 Figure 39 Watch window BlinkSpeed 6 O06 unsigned char 0x0 _tick_factor 0 O000 unsigned char _Oxa NumberD Start 10 E int Usb CheckFlag 1 dnt _ 0x3 5 SI o vwaten 1 watch y watcha watch 4 Online help For more information on building and debugging features refer to embedded STVD online help page Help gt Help Home Page Figure 40 STVD online help E STVD help 1 Hide Print Options Contents Index Search Favorites mj Q amp 1 Getting started with STVD x 2 Your STVD graphical environment amp 3 Project creation and build amp 4 Basic debugging features amp 5 Simulator features e B In circuit debugging x 7 DVP and EMU2 HDS2 emulator features amp 8STice features x Q amp 3EMUS emulator features x 10 Program x Q amp 11 STM8C tutorial 12ST Assembler Linker build tutorial yy programmi
40. rations Figure 36 Building successful message clnk 1 C Program Files COSMIC CXSTM8_16K Lib cvdwarf Debug discover sm Running Post Build step chex o Debug discover s19 Debug discover sm discover elf O error s O warning s v lt gt gt gt Build Tools FindinFiles1 A FindinFles2 Debug Cc For Help press F1 Ln Col MODIFIED READ CAP NUM SCRL OVR Ef 6 2 Debugging your application Once your application has been successfully built access the Debug context from the STVD main menu to access the debugging features that are supported by your debugging instrument The debug instrument must be selected before starting debugging 1 2 3 4 38 42 Select Debug Instrument gt Target settings from the STVD main menu toolbar Select Swim ST LINK which is your debug instrument see Figure 23 Click Apply to confirm and OK to close the window Select Debug gt Start Debugging to start your debug session and access the debug context STVD then connects to your debug instrument loads the code into the microcontroller Flash memory and provides access to the debug commands and menus You can now start debugging your application see Figure 37 Doc ID 16499 Rev 3 ky UM0834 Building debugging and running your application 4 Figure 37 Debugging your application Cf File Edit view Project Build asa a e Q EBE Workspace x Discover stw
41. rd firmware library stm8s conf h These files are used to tailor the libraries for your application src This directory contains all the source files dedicated to your application code such as main c stm8s_it c and stm8_interrupt_vector c interrupt mapping file used only for Cosmic compiler STVD Cosmic or Raisonance This directory is used to store STVD workspace files for example pwm stw It includes the project and workspace for the Cosmic or Raisonance compiler depending on the compiler you have selected Doc ID 16499 Rev 3 ky UM0834 Building and running your STVD project 5 2 Running the STM8S Discovery examples Before starting developing your own application run one of the examples provided with the STM8S DISCOVERY development package to check if your STM8S DISCOVERY is correctly configured Follow the steps below 1 PNA Install the development toolchain see Section 2 Installing the development toolchain Cosmic or Raisonance compiler STVD Download the STM8S Discovery_dev zip file and extract the directory STM8S Discovery_dev on your PC see Section 5 1 Description of the STM8S DISCOVERY development package Run STVD From START gt Programs gt ST Toolset gt Development Tools gt ST Visual Develop a Select File gt Open Workspace b Browse for the project file stw of the example you intend to run according to the compiler you have installed Discover example STM8S Discovery_de
42. s B mae 53 Source Files 8 O STM8 TouchSensing Driver ul STs mec FA mai Cj STM8S StdPeriph Driver EJ stm8s_tim3 c us UE inc stm amp s clk c E stm8s tim4 c stm8 interrupt vector c e E stm8s exti c E stm8s tim5 c t stms it c B Q3 Project stm8s flash c E stm8s_tim6 c i a apc stm8s gpio c E stmBs_uart1 c Discover stm8s i2c c E stm8s uart2 c D My own project stm s_ite c E stm8s uart3 c 2 i a ee Project template stmBs_iwdg c 5 stm8s wwdg c Ey Include Files m 8 stm8s_conf h t gt ig stm8s it h Folders E stm8s iwdg h E stm8s uart3 h 3 3 STM85 Discovery dev B stm s_rst h E stm amp s wwdg h C Libraries E stm amp s spih S O STM8 TouchSensing Driver Seas iih stm amp s gpio h E sTM8S StdPeriph Driver E stm amp s timz h tm8s t h om E stm amp s tim3 h SMS pn src stm8s_tim4 h amp l C3 Project amp stm8s tim5 h i BE E stm s tim6 h 1 External Dependencies i C anc E tms tim Discover E stm8s type h es 8B My own project j E stm8s uartl h Workspace E Project template Z stmBs ch stm8s_uart2 h amp gt Doc ID 16499 Rev 3 33 42 Building and running your STVD project UM0834 34 42 Linking the STM8 touch sensing library to your STVD project This section explains step by step how to link the STM8 touch sensing library to your STVD project Prior to linking the library to your project check that the library is up to d
43. s Tools Help Q Back lt a 7 yo Search lig Folders Address C Program Files COSMIC CXSTMB_16K License v Go Name Type File and Folder Tasks x License_US pdf Adobe Acrobat Doc i Adobe Acrobat Doc Other Places LIC File c CXSTM8 16K E My Documents 3 My Computer My Network Places Details License File Folder Date Modified Today October 21 2009 9 47 AM 2 2 2 Installing the Raisonance compiler To install the Raisonance compiler follow the sequence described below Doc ID 16499 Rev 3 11 42 Installing the development toolchain UM0834 1 Step 1 Download Ride and the Raisonance kit RKit STM8 from http www raisonance mcu com and follow the installation wizard instructions see Figure 6 Figure 6 Raisonance compiler installation wizard Launcher Ride The following components are currently installed on this machine Ride 7 20 09 0139 Select the new components you want to install ta RKit STMB for Ride ProductName RKit STM8 For Ride7 Version 2 24 09 0238 Use the Following web address to get technical support and updates http www raisonance com Select the destination directory for Ride IDE and its components d Available Space 12987 MB Start install 2 Step 2 Register for a free 16 Kbyte license a You need a computer serial number To get it open Ride click Help gt Licence and enter your name you company and select Manual insta
44. s discovery Doc ID 16499 Rev 3 15 42 Description of firmware libraries UM0834 Figure 11 STM8S standard firmware library architecture Application layer registers definition memory mapping configures the library Standard Peripheral drivers stm8s flash stm8s opt stm8s gpio stm8s i2c sin8s iwdg stm8s rst sms sn stm8s_tim1 stm8s t m2 stm8s type h stm8s tim3 stm8s_tim4 stm8s wwdg ai17223 3 1 1 Description of the STM8S standard firmware library The stm8s h header file contains the definitions of constants and register structures for all peripherals Uncomment define USE STDPERIPH DRIVER when using the STM8S standard firmware library In addition stm8s h must be included in your main routine The stm8s conf h file of the STM8S standard firmware library is used to configure the library by enabling the peripheral functions that are only used by your application see Figure 12 In stm8s conf h some peripheral define statements are conditioned by supported devices For example Sif defined STM8S208 defined STM8S207 defined STM8S105 define TIM3 1 endif In stm8s_conf h the HSE value define statement may be adjusted to the oscillator frequency or to the external clock generator frequency It is also conditioned by supported devices Make sure you have the correct value for the STM8S DISCOVERY external oscillator expressed in Hz For example define HSE VAL
45. scovery The package is structured as follow Figure 22 STM8S Discovery_dev package content 3 STM85 Discovery dev 3 O Libraries O STM8 TouchSensing Driver B inc C3 src O STM8S StdPeriph Driver B inc src O Project amp C ADC O Discover 3 Project template o i PwM O inc B src C STD E C3 Cosmic t e Raisonance Libraries The libraries are located in the Libraries directory e STMS8 TouchSensing Driver This directory contains the source and header files of the STM8S touch sensing library e STMS8S StdPeriph Driver This directory contains the source and header files of the STM8S standard firmware library Warning Itis strongly recommended to upgrade the libraries as soon as new releases are available see Section 5 4 Doc ID 16499 Rev 3 25 42 Building and running your STVD project UM0834 5 1 2 5 1 3 26 42 Application code examples The application code examples are located in the Project directory Discover The Discover demonstration firmware comes preprogrammed in the STM8S DISCOVERY It makes LD1 LED blink at different speeds when the touch sensing key is pressed This example uses the STM8S standard firmware library and the STM8 touch sensing library For more details on the Discover application code implementation and library configuration refer to user manual Adjustable LED blinking speed using STM8S DISCOVERY touch sensing key UM0833
46. tmBs h Linking the STM8S standard firmware library to your STVD project This section explains step by step how to link the STM8S standard firmware library to your STVD project Prior to linking the library to your project check that the STM8S library is up to date If it is not download the latest release see Section 5 4 Updating the libraries Follow the steps described below to link the STM8S standard firmware library to your STVD project 1 Edit stm8s h and uncomment define USE STDPERIPH DRIVER see Figure 30 Figure 30 Linking the STM8S standard firmware library step 1 Workspace x tn N Res STVD workspace stw stvd project Sy Source Files main c stm8 interrupt vector c amp stmas it c E FwLib 53 O if defined USE STDPERIPH DRIVER 54 E Comment the line below if you will als drivers drivers will a not use the perip 55 In this tk not be included and the application a code will he TSLib 26 4 Sy Include Files 57 B stm s_it h ES Fwlib P3 iim E stm8s h E 60 For FLASH routines select whether a R pointer will be declared as near 2 a External Dependencies BYTES BANALE X Workspace main c stm8s h 2 Copy stm8s conf h from the My own projectVnc directory of STM8S DISCOVERY dev to the Include File root of your STVD project In stm8s_conf h uncomment the define statements corresponding to the
47. v Project Discover STVD Cosmic Discover stw PWM example STM8S Discovery_dev Project PWM STVD Cosmic PWM stw or STM8S Discovery_dev Project PWM STVD Raisonance PWM stw ADC example STM8S Discovery_dev Project ADC STVD Cosmic ADC stw or STM8S Discovery_dev Projecti ADC STVD Raisonance ADC stw Configures STVD to use ST LINK as debug instrument see Figure 23 a Click Debug instrument gt Target Settings b Select target Swim ST LINK in the target list Click Build gt Rebuild All to build your application Clicking Debug gt Start Debugging to start the debug session Click Debug gt Run to run you application The application code example you have selected is now running Check if it operates in compliance with what is described in the associated user manual You can also use STVD debug capabilities to run the code step by step and monitor the variables see Section 6 2 Debugging your application Doc ID 16499 Rev 3 27 42 Building and running your STVD project UM0834 5 3 5 3 1 28 42 Figure 23 Selecting the debug instrument Debug Instrument Settings Target Debug Instrument Selection Select the Target you want to use for debug session Swim ST Link Simulator STice Swim Blink V Restart the application wil Swim STice Target Port Selection Select the connection port for the Target selected above usb usb bd Add Remove Show the selected target notification
48. vironment IDE composed of the ST Visual Develop STVD and the ST Visual Programmer software interface STVP e Compilers e Firmware libraries they are optional and allow to easily create a new application STMicroelectronics provides a free software package including STVD and STVP 1 1 ST Visual Develop STVD STVD is a full featured development environment It is a seamless integration of the Cosmic and Raisonance C compilers for STM8 microcontroller family These compilers are free when developing code up to 16 Kbytes STVD main features are e Seamless integration of C and ASM compilers e Full featured debugger e Project management e Syntax highlighting editor e Integrated programming interface Figure 1 STVD overview Isis le Edt Mew Project Buid Qebug Debugicstrument lods Window Hep je scu scgvseesesmj xe asm xj Workspaces fir tutorial sto ta C Documents and Settings gussenho data temp stvd 10 case RED 72 nextState GREEN 73 break n case OFF 75 nextState 0FF 76 break 7 default 78 nextState currentstate i 7 break 62 Sinterrupt nostack void trapISR t 64 color next tate if state nextState stateOccurence lt MAX currentState nexcstate state currentState stateOccurence Py s WATCHDOG SOF TUARE WDG_HALT RESET Run Application stopped Breakpoint 1 trapISR at
49. z discover C3 Source Files main c ia stm8 interrup FWLib TSLib Include Files External Dependen Debug Debuginstrument Tools Window Help o Stop Debugging Go To PC Alt Num Run Ctr FS FE Chip Reset Ctrl Shift F5 Restart Continue F5 T9 Step Into Fil n c Run to Cursor amp set pc P Step Into ASM Alt F11 T Step Over ASM Alt F10 P Step Out sw discover iff foni tioni 0 DOms timebase b User Start BteMachine Several debug windows are available in STVD You can access them by selecting View menu when a debug session is ongoing One of the most useful windows is the Peripheral registers window It can be used to display the content of the STM8S105C6 peripheral registers during the debug session see Figure 38 The Watch window displays the values the code variables Just drag and drop a variable from your code into the Watch window The information displayed in the debug windows are refreshed when the program is stopped for example by a break point see Figure 39 Figure 38 Peripheral registers window Peripheral Registers X Peripheral registers E STM85105C6 o oo ee ec CC H H Port Port B 0 5005 PB_ODR Port B data output latch register 0 5006 PB_IDR Port B input pin value register 0 5007 PB DDR Port B data direction register 045008 PB_CR1 Port B control registe

Download Pdf Manuals

image

Related Search

Related Contents

EVGA 02G-P4-2680-KR NVIDIA GeForce GTX 680 2GB graphics card  Control units  Manuale tecnico - HeatMaster 115 N  DBS User`s Manual  INSTALLATION INSTRUCTIONS  C om unicação Profibus  HP Pavilion 15-n230us  406 EPIRB USER MANUAL  Nikon MH-60 User's Manual    

Copyright © All rights reserved.
Failed to retrieve file