Home
STM-STM8-STM8L101F2-Learning Centre MCU-User
Contents
1. Q amp 10 Program Welcome to ST Visual Develop STVD STVD is a powerful integrated development Q 11 STM8 C tutorial environment for ST microcontrollers This Windows based environment provides interfaces for 12 ST Assembler Linker build tutorial all phases of application development from building and debugging your application to programming your ST microcontroller Building and debugging applications 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 Ayr Doc ID 17891 Rev 1 49 51 Revision history UMO0991 7 Revision history Table 1 Document revision history ome ams O 14 Sep 2010 Initial release 50 51 Doc ID 17891 Rev 1 ky UM0991 Please Read Carefully Information in this document is provided solely in connection 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 co
2. CT UMO991 Sf User manual Developing and debugging your STM8L DISCOVERY application code Introduction This document complements the information in the STM8L datasheets by describing the software environment and development recommendations required to build an application around the STM8L DISCOVERY It also explains how to use the STM8L firmware library 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 STM8L DISCOVERY This package includes application code examples and a project template The STM8L DISCOVERY is based on the STM8L15x MCU however it can be used to get to know the main features of other STM8L microcontrollers Reference documents e STM8L DISCOVERY user manual UM0970 e ST Visual Develop STVD user manual UM0036 e Discover STM8L15x power saving modes using the built in Ipp measurement feature of the STM8L Discovery AN3269 e Building a wave generator using the STM8L DISCOVERY AN3252 STMS8L 15x reference manual RM0031 e SIM8L15xx datasheet September 2010 Doc ID 17891 Rev 1 1 51 www st com Contents UMO991 Contents 1 Overview of STM8 software development toolchains 6 1 1 SI Visual Develop STVD 0 0 0 cc eee 6 1 2 SI Visual Programmer STVP leeren 7 13 Candassembly compilers llle 7 1 4 IAR Embedded
3. 30 51 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 W Restart the application wil Swim STice Swim ST Link Target Port Selection Select the connection port for the Target selected above usb usb Add Remove Show the selected target notification at start of debugging session Cancel With IAR Embedded Workbench Follow the steps below 1 ONO Oo Install the development toolchain see Section 2 Installing the development toolchain IAR Embedded Workbench for STM8 Download the STM8L Discovery_dev zip file and extract the directory STM8L Discovery_dev on your PC see Section 5 1 Description of the STM8L DISCOVERY development package Run IAR Embedded Workbench From START gt Programs gt IAR Systems gt IAR Embedded Workbench for STMicroelectronics STM8 gt IAR Embedded Workbench a Select File gt Open gt Workspace b Browse for the project file eww of the example you intend to run Discover example STM8L Discovery_dev Project Discover EWS TM8 Discover eww WavesGenerator example STM8L Discovery_dev Project WavesGenerator EWS TM8 WavesGenerator eww Configures IAR to use ST LINK as debug instrument see Figure 23 a Right click your project name then select Options b Select Driver ST LINK in the setup tab of the Debugger Categ
4. strn8 FREE 16k Download of the FREE stm8 16k version Thank you for the information gt gt Click here to download lt lt Don t forget that this product x 3 f le you through the necessar y steps For more information abo File Download i E oy Devownroan 2suppor dmm LG contact Us cod Xx J f cxstm8_16k exe from www cosmicsoftware com jh oer Ea Ges 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 Note that the procedure is not done automatically it may take a few hours or a few days after the week end depending on your location and time zone before you receive your license file Doc ID 17891 Rev 1 11 51 Installing the development toolchain UMO991 Figure 4 Cosmic compiler installation wizard Cosmic 16K Compiler Registration Ej 16K C Compiler InstallShield Wizard REGISTER NOW TO GET YOUR FREE LITE VERSION TOOLS PRODUCT xxxxxxexxxxey HOS TID xxxxxexexxeHe USER lt USER gt DISPLAY lt DISPLAY gt HOSTNAME lt HOSTNAME gt DISK_SERIAL_NUM lt DISK_SERIAL_NUM gt onal tasks Select the additional tasks you would like Setup to perform while installing COSMIC STM8 15K C Compiler then click Next Create a desktop icon User lt USER gt fd Register your license skip the registration if you already have a license Company
5. COMPANY Address HRRRRARRARARAARRAR RAR RAR ARR ARR ARRAS Country mR m Phone Fax Optional m m Register by Email Edit Email and Register Cancel remind Glocke set REERERRLS 4 Step4 Copy the licence file that you have received into the corresponding directory Program files COSMIC CXSTM8_16K License or Program files COSMIC CXSTM8_32K License see Figure 5 Figure 5 Cosmic compiler 8 C Program Files COSMIC CXSTMB_16K License SEE File Edit View Favorites Tools Help Q Back d pe Search lig Folders Gi Address C3 C Program Files COSMIC CXSTM8_16K License v Go Name Size Type File and Folder Tasks Y i License LIS pdf 53KB Adobe Acrobat Doc 49 KB Adobe Acrobat Doc Other Places 1KB LICFile E cxsTMa 16k E My Documents i 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 12 51 Doc ID 17891 Rev 1 UM0991 i Installing the development toolchain 1 Step 1 Download Ride7 and the Raisonance kit RKit STM8 from http www mcu raisonance com microcontrollers link free download html and follow the installation wizard instructions see Figure 6 Figure 6 Raisonance compiler installation wizard Launcher amp Ride The Following compon
6. 3 inc E stmali5x h src User 53 inc stmali5x it h 5 src main c sktma interrupt vector c stm li5x_it c External Dependencies is Workspace Workspace ies STYD_workspace stw stvd project STMBL15x StdPeriph Driver SY inc stmali5x h Sy sre User 5 inc stmali5x conf h E stmaltx it h 4 src main c Fal sktm amp inberrupt vecbar c E stmaltsx it c External Dependencies is Workspace i include stmallis5x nh Uncomment the line below to enable peripheral header file inclusion ri Fi KS i S At include include inc lude include include inc lude inc lude include stmSll5x adc h somBllsx Deep stmalis5x clk h ari sthBllsx comp h stmalis5x dac h wf stmali5x dma h stmSli5x exti h tr stmali5x flash h finc lude stmolisx gpio h H lric Luce atio 2x lec x include stmG l1iSx irtim h main c std Se hi stmall5 amp canf h Folders C3 STM8L Discovery dev C3 Libraries C3 STM8L15x StdPeriph Driver o src O Project i Discover H My own project 23 Project template i3 3 qi 3 3 qi i3 3 03 miti stm liSx h stm8l1S5x_adc h stm liSx_beep h stm liSx_clk h stm liSx_comp h stm8li5x dac h stm8li5x dma h stm8l15x exti h stm amp li5x Flash h stm8l15x gpio h stmali5x i2c h stm8l15
7. Creating your project structure 1 0 ee 31 5 3 2 Creating your STVD project 0 0 eee 32 2 51 Doc ID 17891 Rev 1 ky UM0991 Contents 5 3 3 Linking the libraries to your STVD project 00000 0s 35 5 3 4 Creating your IAR Embedded Workbench project 38 5 3 5 Linking the libraries to your IAR project 0 00 c eee eee 41 5 4 Updating the libraries llle 44 5 4 1 Updating the STM8L15x standard firmware library 44 Building debugging and running your application with STVD 45 6 1 Building your application 0 0 cc tees 45 6 2 Debugging your application 0 cc ees 46 6 3 Online help 48 HOVISIOB DISIOT V uusRdad ues REGE xackd pu Rd EAS ENE A 50 Doc ID 17891 Rev 1 3 51 List of tables List of tables Table 1 Document revision history 4 51 UM0991 Doc ID 17891 Rev 1 ky UM0991 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 Figure 31 Figure 32 Figure 33 Figure 34 Figure 35 Figure 36 Figure 37 Figure 38 Figure 39 Figure 40 Figure 41 Figure
8. ID 17891 Rev 1 ky UMO0991 Overview of STM8 software development toolchains Figure 1 STVD overview ST Visual Develop Ble Edt View Project Buld Debug Debug instrument Tools Window Help j e aco OS c upe ecusm Xe BM x Itsy tutorial ster ta C Documents and Settings gussenho data temp stvd case RED nextState GREEN break case OFF interrupt nostack void trapISR nexcState OFF Bt break color nextState default nextState currencStace i break Go to next state and upda traced var if state nextState stateOccurence lt MAX case RED nevr raremzp rM CurrentState nexcstate state currentState stateOccurence WATCHDOG SOF TUARE WDG_HALT RESET Run Application stopped Breakpoint 1 trapISR at rimer c 69 1 2 ST Visual Programmer STVP SIVP 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 1 3 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 versi
9. Workbench llle 8 1 5 Firmware libraries llle 8 2 Installing the development toolchain 9 2 1 Downloading and installing STVD ee 9 2 2 Downloading and installing the compilers Less 9 2 2 1 Installing the Cosmic compiler llle 9 2 2 2 Installing the Raisonance compiler 000 c eee eee 12 2 2 3 Compiler settings 0 0 0 0 ccc IIR 15 2 3 Downloading and Installing IAR Embedded Workbench 16 3 Description of firmware library lees 21 3 1 STM8L15x standard firmware library 0 0000 21 3 1 1 Description of the STM8L 15x standard firmware library 22 3 1 2 STM8L15x standard firmware library online help 23 4 Configuring the option bytes for your application 24 5 Building and running your project 27 5 1 Description of the STM8L DISCOVERY development package 27 5 1 1 LIDOS saos werk x 9RASEOSSENUE AMENS RASA Edi SEE PE B E S 27 5 1 2 Application code examples eee eee 27 5 1 3 miis eds c C O 28 5 2 Running the STM8L Discovery examples 28 5 2 1 ptshusm r m 28 5 2 2 With IAR Embedded Workbench 0 0000 eee eee ees 30 5 3 Creating your own project 0 0 cc eee ee 31 5 3 1
10. examples The application code examples are located in the Project directory e Discover The Discover demonstration firmware comes preprogrammed in the STM8L DISCOVERY This demo displays the STM8L152C6T6 Idd consumption on the STM8L Discovery LCD while the MCU is in Run or in low power saving modes This example uses the STM8L15x standard firmware library For more details on the Discover application code implementation and library configuration refer to application note yy Doc ID 17891 Rev 1 27 51 Building and running your project UMO0991 5 2 5 2 1 28 51 AN3269 Discover STM8L15xx power saving modes using the built in Idd measurement feature of STM8L Discovery The Discover application project is compatible both with Cosmic Raisonance compilers and also with IAR Embedded Workbench e WavesGenerator This application transforms the STM8L Discovery into a basic wave generator This code has been optimized and use only the LCD driver of the library Refer to application note AN3252 Building a wave generator using the STM8L DISCOVERY for details on the WavesGenerator application software code implementation and library configuration The WavesGenerator project is compatible both with Cosmic and Raisonance compilers and also with IAR Embedded Workbench e Project template This directory contains a standard project template that should be used to start any application software development Project structure Each project
11. stmali5x h 5g User 5g inc E stmali5x it h lt q src main c stme_interrupt_vector c E stmali5x it c External Dependencies is Workspace 36 51 Doc ID 17891 Rev 1 L Comment the line below if you will not use the peripherallgpgk 0 In this case these drivers will not be included and the application conde Tide ue based on direct access ta peripherals registers Sdefine USE STDPERIPH DRIVER t brief In the following line adjust the value of External High Speed oscillator Hoe used in your application stmall5x h UM0991 Building and running your project 2 Copy stm8l 15x conf h from the My own projectWinc directory of STM8L DISCOVERY dev to User inc of your STVD project In stm8l15x conf h uncomment the define statements corresponding to the peripherals used by your application The c and h files corresponding to the peripherals which define statement are uncommented must be copied from STM8L DISCOVERY_dev Libraries STM8L15x_StdPeriph_Driver inc and STM8S DISCOVERY_dev Libraries STM8L15x_StdPeriph_Driver src into STM8L15x_StdPeriph_Driver inc and STM8L15x_StdPeriph_Driver srce 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 32 Linking the STM815x standard firmware library step 2 Workspace Hefo TYD workspace stw styd_ project STMBL15x_StdPeriph_Driver
12. 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 gt Configurations If the Debug configuration is not selected highlight it and click Set Active see Figure 40 Figure 40 Selecting the project configuration Project Configurations Project Configurations Debug Release Remove Add Set Active Rename Doc ID 17891 Rev 1 45 51 Building debugging and running your application with STVD UMO991 6 2 46 51 2 Once the build options are correctly configured configure your project settings a Select Project 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 information on the available options for your toolset refers to the STVD online help available by clicking
13. their pathes are correct Figure 34 Checking the Additional Include Directories path Options for node project Category Factory Settings General Options Multi file Compilation C C Compiler ja Assembler Output Converter Language Optimizations Output List Preprocessor Diagnostic 4 gt Custom Build Build Actions Linker Ignore standard include directories Debugger Additional include directories one per line ear PROJ_DIRS inc sTice PROJ DIR Libraries STM8L15x StdPeriph Driversinc ST LINK Preinclude file Defined symbols one per line Preprocessor output to file r Doc ID 17891 Rev 1 39 51 i Building and running your project UM0991 Select the MCU to be used right click on projects Debug in the workspace window then select options and General Option as Category Then browse the Device STM8L152C6 from the STMB8L list Make sure that MCU selected is displayed in the Device field before clicking OK see Figure 35 Figure 35 Select the MCU Options for node project Category General Options C C Compiler Assembler Output Converter Target Dutput Library Configuration Library Options Stack Heap lt gt Custom Build Build Actions Device Linker Debog STM8L152C6 Simulator STice Code model ST LINK Small Data model Medium E 40 51 Doc ID 17891 Rev 1 UMO0991 Building and running your project 5 Configu
14. wwdg h tmali5x exti h Type H File C Discover B P iih Date Modified 14 Jul 10 11 04 E E My own project a inr vies Size 5 77 KB C Project_template stmaiTsx gpio 5 3 5 Linking the libraries to your IAR project If no library linked to your IAR project If your application does not require any library follow the instructions below i Doc ID 17891 Rev 1 41 51 Building and running your project Note 42 51 UM0991 1 Edit stm8 15x 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 only partially uses the library refer to the WavesGenerator project in the STM8L DISCOVERY development package Figure 37 No libraries linked workspace define _IAR_ Files en Ba perse error Unsupported Compiler Sfajproject Debug tv Ha 3 STM8L15x_StdPeriph_Driver linc gif defined USE STDPERIPH DRIVER k stm8l15x h Comment the line below if you will not use the peripl L Erse In this case these drivers will not be included and Compiler defi La sre main c co stmBl15x itc Lm 71 Output b udi E n arrea el m mala Frea i blaa Fa Tae saan fame press weasel project ased on direct access to peripherals registers Ha User based on direct t pherals registers Heine define USE STDPERIPH DRIVER E stmali5x i
15. 15x irtim h stn8115x itc h f stm3115x iwdg h stn3115x lcd h stm3115x pwr h stmdlisx rst h stm liSx_timi h 7 stmeliSx_tim2 h B stm liSx_tim3 h stmal15x tim4 h B stm8l15x usart h stm8li5x wfe h B stm8l15x wwdg h Folders X E stmali5x h C3 STMaL Discovery dev g stm8l15x_adc h m stmali5x beep h C3 Libraries amp ies E C STMeL1Sx StdPeriph Driver 578 19x C Z stm8li5x comp h om src stm8li5x dac h 3 Proj E stmali5x dma h inc i Praject ma amp 3 Discover Z stm8li5x exti h zz Beers _ E G3 My own project E stmal 5 flash h 8 E stmali5x gpio c ik Eric template E stmal15x gpio h E stm8l15x gpio h Ject temp j lt I stmal15x irtim c E stml15x_itc c B stm8l15x_iwdg c Z stm8l15x Icd c stmali5x pwr c B stm8li5x rst c E stmaliSx_rtc c stmali5x i2c h stmali5x irtim h stmali5x itc h stm8li5x iwdg h stmali5x lcd h stm8li5x pwr h stm8li5x rst h stmali5x rtc h stmali5x spi h stmBliSx_syscfg h Files ez BE afa project Debug v Ha C1 STM8L15x_StdPeriph_Driver stm8l15x_tim2 c f stm8li5x tim3 c stm8l15x tim4 c stmeliSx_usart c 2 stm8lil5x wfe c 2 stm8l15x wwdg c stmali5x adc c stm8l15x beep c stm8li5x clk c stmali5x comp c stmali5x dac c stmali5x dma c stmali5x exti c Folders C3 STM8L Discovery dev C
16. 3 Libraries O STM8L15x StdPeriph Driver Ce inc E stm8l15x itc cm Output hile 73 Discover project i O My own project i 73 Project template I E stm8l15x conf h L F stm8l15x ith stm8l15x Size 11 2 KB Doc ID 17891 Rev 1 43 51 i Building and running your project 5 4 Updating the libraries 5 4 1 Updating the STM8L15x standard firmware library To update the STM8L15x standard firmware library 1 Download the new release from http www st com mcu 2 Copy the inc and src directories in STM8L DISCOVERY dev Wibraries STM8L15x StdPeriph Driver 44 51 Doc ID 17891 Rev 1 UMO0991 UMO0991 6 Note 6 1 Building debugging and running your application with STVD Building debugging and running your application with STVD Once your have developed your application code created your workspace environment and launched STVD you can start building debugging and programming your application for the target microcontroller This section refers to STVD if you are using AR Embedded Workbench please refer to the IAR Getting Started documentation 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 you to change
17. 42 Figure 43 Figure 44 Figure 45 Figure 46 SZA SIVD OVEINIOW A RTT 7 Cosmic compiler lOi sse 454 oe o eae ent Beebe peu d iecore bet ebb ee ee ee c oe lt 10 Downloading Cosmic compiler software wizard 0 000 eee 11 Cosmic compiler installation wizard n anaoa ccc eee nee 12 COSMIC COMPIIGN TPRRTRTTLTIT TR OTRO UTIMS 12 Raisonance compiler installation wizard llle 13 Activation code registration 0 0 ce eee een hn 14 Personal information form 0 6 aaaea rrr 14 Serial key information form 0 0 0 0 0 e ees 15 Selecting the Cosmic compiler for the Discover project 0000 ce eee eee 16 Product Registration and Download form n anaana aa aeae 17 Download software naaa drum aaa e acu 446 o4anes ep RU dH Ro seu SCR CR Bod 18 Enter User INIONNAVON sess sssr ded actae adde da doa qr deed eee aa bee ERE d eee kaa es 19 Enter license key CIT 20 STM8L15x standard firmware library architecture anana 22 stm8l15x conf h peripheral define statements n nananana naaa 23 SIMe firmware library online help home page 000 cc eee eee eee ee 23 wed oo ca 24 STVP option byte selection menu 2 eee eee eee 25 SIVP option byte programming menu 1 6 eee 26 SIVP option byte programming message 0 0 cee eee 26 STM8L Discovery_dev package content llle 27 Selecting the debug instrume
18. 8L Discovery_dev package User src has the same content as STM8L DISCOVERY_dev Project My_own_projectisrc User inc contains My own project include files STM8L15x StdPeriph Driverlsrc contains the STM8L standard library source files STM8L15x StdPeriph Driverlinc contains the STM8L standard library include files 38 51 Doc ID 17891 Rev 1 ky UMO0991 Building and running your project Figure 33 IAR Embedded Workbench workspace window JF IAR Embedded Workbench IDE File Edit View Project Tools Window Help Dueb amp Workspace f mmm Files void mainivoid Hil project Debug Infinite loop a 3 STMBL15x StdPeriph Driver dde 1 L inc sre Ha user Ha inc L E stm8l15x_cont h L F stm8l15x ith Hbrief Inserts s delay time E sre Hparam nCount specifies the delay time length main c fretval None stm8l15x itc sf L 3 Output 1ifdet USE FULL ASSERT project Massages m Ready Errors 0 Warnings 0 Ln 43 Cal 22 3 Check that Additional Include Directories Paths are correct This list is to point out your project and library include files The argument variable PROJ_DIR automatically point to the directory of the current project right click on project Debug in the workspace window select Options select Category C C Compiler in the left window select the Preprocessor tab right andLibrary and User header files as well as
19. D workspace skw p eens stvd project STMBL15x StdPeriph Driver eX inc Jtt Gaddtogroup Template ut uf stmali5x it h T E puedes 3 src uer culpe 5 main c stme_interrupt_vector c strliSx_it c j External Dependencies J ES Workspace Folder X E stmali5x h stm amp lisx irtim h stmali5x tim3 h p E stm8li5x adc h E stmali5x itc h E stmali5x tim4 h 2 aec 59 s stmBll5x beep h stm amp l15x iwdag h stm amp li5x usark h BE eee E stm amp l15x clk h stm amp l15x lcd h E stmBli5x wfe h p om E stmBli5x comp h E stm liSs_pwr h E stmBl15x wwdg h e t stmal15x dac h stmal15x rst h E fa Project Z stmali5x dma h E stm l15x_rte h ae s stmall5x exk h Z stm amp l15x spi h x E Mv own praject Z stmali5x Flash h E stmali Sx _syschg h e ce ante E stmBli5x gpio h E stmali5x timi h eo MAN stmali5x izc h stmali5x timz h 5 3 3 Linking the libraries to your STVD project If no library linked to your STVD project If your application does not require any library follow the instructions below Doc ID 17891 Rev 1 35 51 i Building and running your project UM0991 1 Edit stm8 15x h and comment define USE_STDPERIPH_DRIVER to be able to use the register structures memory mapping and constant definitions for each peripheral Note For an example of application code that only partially uses the library refer to the WavesGenerator p
20. EATH 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 2010 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 yl Doc ID 17891 Rev 1 51 51
21. Help Ox O MAD Ds Yer O Z Z a DAS Address amp http fwww cosmicsoftware com download stm8 16k php Embedded Innovation ABOUT US NEWS amp EVENTS CONTACT US PRODUCTS amp SERVICES SUPPORT DOWNLOAD Home Download stm8 FREE 16k Download of the FREE stm8 16k version Fill and submit the form below to download the free stm8 compiler 16K version To use this product you must register with Cosmic Software The installation procedure will instruct you to send a message to Cosmic Software at stm8 16k gcosmicfr to perform this registration As a result you will receive the appropriate free license for this product Name Company Address ZiPCode sid City Country Select Phone Fax E mail TJ DOWNLOAD 2suprort Copyright 2008 COSMIC Software LG contact us 10 51 Doc ID 17891 Rev 1 UM0991 Figure 3 Installing the development toolchain 2 Step2 Download and run the installation software wizard see Figure 3 Downloading Cosmic compiler software wizard Cosmic Software Download Microsoft Internet Explorer provided by Corporate Package Fabric st File Edit View Favorites Tools Help O O HAG D 49 82a Vas Address amp l http wvww cosmicsoftware com dwldstm8 16k ok php s Embedded Innovation 5 Ai ABOUTUS NEWS amp EVENTS CONTACT US PRODUCTS amp SERVICES SUPPORT DOWNLOAD Home Download
22. Help in the STVD main menu toolbar 3 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 47 4 The build command lines and possible warnings and or errors are displayed in the build tab of the Output window see Figure 42 Figure 41 Building your project 1 ST Visual Develop Discover stw main c 32a File Edit View Project Build Debug Debug instrument Tools Window Help 8 cs n El amp a Compile main c Ctrl F Fe Rebuild Al Workspace Batch Build is Discover sbw Clean discover Configurations Figure 42 Building successful message clnk 1 C SProgram Files COSMIC CEZSTMS 15EXLib cvdwarf Debug discover sm Running Post Build step chex o Dehbug discover s19 Debug discover sm discover amp elf O error s O warningiz gt RY HJ Build 4 Tools Find in Files 1 Find in Files 2 Debug A Cc For Help press F1 Lin Col MODIFIED READ CAP NUM SCRL OVA af 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 Doc ID 17891 Rev 1 UMO991 Building debugging and running your application with STVD Select Debu
23. STB HSE STB BOR_TH bits BOR_TH bit2 BOR_TH biti BOR_ON CPU can enter Halt mode wro Ww DG reset Window Watchdog activated by Software Independant Watchdog continues running in HATLASCTHALT made Independant Watchdog activated by Software 1 clock cycle 1 clock cycle 0 0 0 B rownout reset OFF PROGRAM MEMORY A DATA MEMORY OPTION BYTE Read Ehe current bab or ac im Unknown ST LIME STMBL1S2x6 Sw IM 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 a confirmation message is displayed in the Output window see Figure 21 i Doc ID 17891 Rev 1 25 51 Configuring the option bytes for your application UMO0991 Figure 20 STVP option byte programming menu no project STVP File Edit Project Configure Read Program Verify Erase Blank Check View Help i PE STH adicurrent tab Ctrl F Value Ad DO 00 00 00 00 00 00 Description PCODESIZE bit T T All tabs fon active sectors iF any Ww wOG HALT WAW DG HY NU MOG IN HALT Window Watchdog generates a reset when CPU enters Halt mode WD Hw Independant Watchdog activated by Software L5E STB 1 clock cycle Hcr CTR 1 elael ucla PROGRAM MEMORY A DATA MEMORY OPTION BYTE Program the current tab or Linknownz ST LIMK STM8L152x6 SWIM Figure 21 STVP option byte p
24. TM8L Discovery dev zip file and extract the directory STM8L Discovery dev on your PC see Section 5 1 Description of the STM8L DISCOVERY development package Run STVD From START gt Programs gt ST Toolset 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 STM8L Discovery dev ProjectiDiscoverlS T VDICosmicDiscover stw or STM8L Discovery_dev Project Discover S T VD Raisonance Discover stw WavesGenerator example STM8L Discovery_dev Project WavesGenerator ST VD Cosmic WavesGenerator stw or STM8L Discovery_dev Project WavesGenerator S TVD Raisonance WavesGenerator 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 application note 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 17891 Rev 1 29 51 Building and running your project UMO0991 5 2 2
25. and follow the installation wizard instructions Note The procedure described here is for the 8 KB limited Kickstart edition installation only 2 Step Fill in the Product Registration and Download form Figure 1 1 and click Submit Registration An email asking you to confirm the registration is then sent to the address you have specified in the registration form It might take some time before to receive the email as the operation is manual 1 6 51 Doc ID 17891 Rev 1 UMO0991 Installing the development toolchain Figure 11 Product Registration and Download form SIAR SYSTEMS Product Registration and Download IAR Embedded Workbench for STMicroelectronics STMS 8K KickStart Edition v 1 10 When vou have registered below you will receive an e mail containing information that is required to install the software Please make sure ta spell your e mail address correctly First name PO Last name Phone Doo fE Fax PT I m already a customer of I amp R Systems 3 Step 3 Open the mail and click the URL A web page opens with the License Number and the License Key This page also give you information on how to download and install the product see Figure 12 4 Step 4 To download the product click the Europe HTTP site URL see Figure 12 Once IAR Embedded Workbench downloaded the installation process starts automatically i Doc ID 17891 Rev 1 17 51 Installing the developmen
26. 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 Browse to the root path depending on the the compiler you want to use see Figure 10 Hoot pathes for compilers are e Cosmic 16K C Program Files COSMIC CXSTM8_16K e Cosmic 32K C Program Files COSMIC CXSTM8_ 32K e Raisonance 32K C Program Files Raisonance Ride Doc ID 17891 Rev 1 15 51 i Installing the development toolchain UMO0991 Figure 10 Selecting the Cosmic compiler for the Discover project Project Settings Settings For Debug General Debug MEU Selection E Compiler Assembler 4 ui discover Defaults Toolset Info Toolset STM8 Cosmic T v Project specific toolset path Foot path Program Files COSMIC CAS TM 16K Toolset sub paths relative to the Root path Bin path Include path Hstm Library path Lib Output directory Cancel 2 3 Downloading and Installing IAR Embedded Workbench IAR Embedded Workbench for STM8 is available at http www iar com in the Downloads tab It integrates the IAR C Compiler and assembler To install IAR Embedded Workbench follow the sequence described below 1 Step Download the installation software either the 30 day evaluation edition or the 8 KB limited Kickstart edition according to your requirements from http www iar com
27. ctWnc directory of STM8L DISCOVERY dev to User inc of your IAR project In stm8 15x_conf h uncomment the define statements corresponding to the peripherals used by your application The c and h files corresponding to the peripherals for which the define statements are uncommented must be copied from STM8L DISCOVERY_dev Libraries STM8L15x_StdPeriph_Driver inc and STM8L DISCOVERY_dev Libraries STM8L15x_StdPeriph_Driver src into STM8L15x_StdPeriph_Driver inc and STM8L15x_StdPeriph_Driver src of IAR project respectively You can also decide to copy the whole set of drivers c and h files from the library to your STVD project Figure 39 Linking the STM8L standard firmware library step 2 Ww or ks p ace stm amp li5x h main c Files PR Uncomment the line below to enable peripheral header E s project Debug 5 iv H STM8L15x_StdPeriph_Driver inc L K stm8l5x h Src User inc iir SIC 7 main c Output project stm8l15x_conf h L T stm8I15x ith E stm8l15x itc include include include include include include include include stm3115x adc h stm3115x beep h Ssin8115x clk h stn3115x comp h stm3115x dac h stmdlisx dma h stn8115x exti h stmdlisx flash h include stm8ll5x gpio h include include include include include include include stn8115x i2c h tf stn81
28. e the corresponding peripheral e The header stm8lt5x periph 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 STM8L15x standard firmware library is described in Section 5 3 Creating your own project Doc ID 17891 Rev 1 UMO0991 Description of firmware library Figure 16 stm8l15x conf h peripheral define statements Uncomment the line below to enable peripheral header file inclusion include stms8ll5x adc h include stms8ll5x bsep h include stms8ll5x clk h include stms8ll5x comp h include stms8ll5x dac h include stm amp 8ll5x dma h include stm8ll5x exti h include stms8ll5x flash h include stmsll5x gpio h s amp include stm8ll5x i12c h f include stms8ll5x irtim h zinclude stmsll5x itc h 7 include stm amp sll5x Twdg h s include stmsll5x lcd h 7 include stmasll5x pwr h 7 include stmsll5x rst h 7 include stm8ll5x rtc h f include stm amp sll5x spi h include stmsll5x syscf SH wy zinclude stms8ll5x timl h include stm8ll5x tim2 h zinclude stms8ll5x tims h include stm8ll5x timd h zinclude stms8ll5x usart h include stm llix_wfe h z 3 1 2 STM8L15x standard firmware library online help An online help STM8L15x_stdperiph_lib_um chm is available inside the firmware
29. ents are currently installed on this machine Ride 7 20 09 0139 Select the new components vou want to install RKit 5TMB for Ride Producthlame RKit 5TM For Ride Version 2 24 09 0238 Use the Following web address to get technical support and updates http AWA raisonance com Select the destination directory For Ride IDE and its components Available Space 12987 i ME Start install 2 Step 2 Register for a free 32 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 Activation The computer serial key will appear as shown in Figure 7 b To get your free 32Kbyte activation code go to http www mcu raisonance com stm8 registration html see Figure 7 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 Copy the activation code received by e mail into installation window see Figure 7 and you will be granted a free 32Kbyte Raisonance compiler licence to be used by STVD Doc ID 17891 Rev 1 13 51 Installing the development toolchain 14 51 Figure 7 Activation code registration Activation Code Registration Type the Serial Number you received when you purchased the kit With the Following Serial Kev identifying your computer and your Se
30. finition stm8l15x h Memory mapping type definition stm8l15x_conf h Configures the library stm8l15x adc h stm8l15x beep h stm8l15x clk h stm8l15x comp h stm8l15x dac h stm8l15x dma h stm8l15x_exti h stm8l15x_flash h stm8l15x gpio h stm8l15x i2c h stmal15x irtim h stm8l15x itc h stm8l15x iwdg h stm8l15x lcd h stm8l15x pwr h stm8l15x rst h stm8l15x rtc h stm8l15x spi h stm8l15x syscfg h stm8l15x tim1 h stm8l15x tim2 h stm8l15x tim3 h stm8l15x tim4 h stm8l15x usart h stm8l15x wfe h stm8l15x wwdg h STM8L152 resources Description of the STM8L15x standard firmware library The stm8 15x h header file contains the definitions of constants and register structures for all peripherals Uncomment define USE STDPERIPH DRIVER when using the STM8L15x standard firmware library It also includes common types definition used by the peripheral drivers In addition stm8l15x h must be included in your main routine The stm8lt15x cont h file of the STM8L15x standard firmware library is used to configure the library by enabling the peripheral functions that are only used by your application see Figure 16 The peripheral interrupt function file stm8l15x it c must be modified to include the code to handle the interrupts used by your application Each peripheral driver is made up of the following files e The source code stm8 15x_ lt periph gt c containing all the software functions required to us
31. g Instrument 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 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 43 a d i Figure 43 Debugging your application c File Edit View Project Build Debug Debug instrument Tools Window Help e x Aso ale WE Ga 4 7 456 o Stop Debugging Qo l HREL discover Debug c Go To PC Alt Num Workspace ips Discover stw Run Ctrl F5 discover 72 Chip Reset Ctrl Shift F5 EM Restart STM8L15x StdPeriph a E P Continue inc src amp y User inc p 3 r 3 Step Into F11 Hauthor MCD stmali5x cc E Peete F10 llication Team stmali5x it i 3 eg src P Step Into ASM Alt Fi1 version V1 3 0 Djecct Template main c f mainc T Step Over ASM anri 90e Ur 2366010 x i fi brief Main Li stm8 interri 3 Step Out Ckri F11 Bou Hodo i stmal15x it gram body External Dependencie iS Workspace 2o 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 i
32. installation directory to help you with the structure of the library see Figure 17 Figure 17 STM8 firmware library online help home page E STMBL15x Standard Peripherals Library 2 Hide Locate Stop Refresh 6G Home Font Print Options Contents Indes Search Favorites Main Page STMSLISx Standard Peripherals Library 3 SIPS TMSL15e Standard Peripherals Life Use ADC to indicate if the converte E Use ADC to convert continuously C E Use ADC ta measure live IDD curre E Use ADC to convert continuausly C E System clack switching between H E Use Comparator 1 to exit MCU from E Use DAC with DMA to generate sq Use DMA to transfer continuously d Use DMA to transfer continuously d Ill gt lt wt Doc ID 17891 Rev 1 23 51 i Configuring the option bytes for your application UMO0991 4 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 STM8L152x6 datasheet for a detailed description STVP can be used to program the STM8L 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 i
33. is structured as follows e inc This directory contains all the header files for your application including the configuration files for the standard firmware library STM8L 15x conf h These files are used to tailor the library for your application o SIC This directory contains all the source files dedicated to your application code such as main c stm8l15x it c and stm8 interrupt vector c interrupt mapping file used only for Cosmic compiler e STVD Cosmic or Raisonance This directory is used to store STVD workspace files for example discover stw It includes the project and workspace for the Cosmic or Raisonance compiler depending on the compiler you have selected e EWSTM8 This directory is used to store IAR Embedded Workbench workspace files for example discover eww It also include the project file for example discover ewp Running the STM8L Discovery examples Before starting developing your own application run one of the examples provided with the development package to check if is is correctly configured Take care to read the example related documentation before proceeding because some examples may require additional hardware to work properly With STVD Follow the steps below 1 Install the development toolchain see Section 2 Installing the development toolchain Cosmic or Raisonance compiler Doc ID 17891 Rev 1 ky UM0991 p ou Building and running your project SIVD Download the S
34. ment toolchain UMO991 Figure 14 Enter license key IAR Embedded Workbench for SIMicroelectronics 51M8 Enter License Key The license key can be either your QuickStart key or your permanent key IF vau enter the QuickStart key found an the CO cover you have 30 days to try the product aut IF you have received the permanent key via email you paste it into the License Key textbox License 9546 377 059 8643 License Key Dl T C ues u PAD Pp ed PER m w 4 L i n 1 T Pe e 1 E J a E a D i ai z E eai t L T Nur d b S i agaa we a M b m Ln ee P in Read License Kev From File InstallShield 20 51 Doc ID 17891 Rev 1 UM0991 3 3 1 Description of firmware library Description of firmware library The STM8L 15x microcontroller family is provided with the STM8L15x standard firmware library It is strongly recommended to use the library to develop your project as proposed in the the STM8L Discovery development package and implemented in the Discover project see Section 5 1 Description of the STM8L DISCOVERY development package The development package also contains the WavesGenerator project which don t use the STM8L standard firmware library except for the LCD driver The STM8L standard firmware library is part of the STM8L DISCOVERY development package that is available from the STM8L DISCOVERY web page at http www st com stm8l discovery Warning Make sure
35. nditions 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 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 D
36. nt 0 0 0 0 cc eee eee 30 Selecting the debug instrument 0 0 00 ee eee eee 31 Creating your project Structure 1 eet rs 32 Creating the STVD workspace for your project 000 ee eee 33 Checking the selected compiler 0 000 llle 33 vies MOU P 34 Copy stm8l15x h to Include Files FWLib llle 35 INO WIDE UMS m O 36 Linking the STM8L 15x standard firmware library step 1 llle 36 Linking the STM815x standard firmware library step 2 0 00 cee eee 37 IAR Embedded Workbench workspace WiIndOW 000 cece eee eee 39 Checking the Additional Include Directories path 2 0 0 cece eee 39 SeleChiINe MOD Sa dee Ries poate tages aes eae yee eee eeeedeeauueteueaes 40 Copy stm8s h to Include Files FWLib 1 1 eee 41 N liprarn s INKE PT r 42 Linking the STM8L standard firmware library step 1 nananana cee ee ee 42 Linking the STM8L standard firmware library step 2 0 ce ee 43 Selecting the project configuration n aana aa eee eee 45 B ilding vour DIOJGCL s 325 02 arr ated de heen eee Ree eee es RR ERE wa eee 46 Building successful message 1 ee eee ee eee 46 Debugging your APPIICALION 9 22 xa m9eRE UE EG CR hex kisi sid bin aadi OR X RE Re DG as 47 Peripheral registers window llle RI rn 48 Waton re
37. o PPD rrLS 48 IRUBRguISrlloMRTCCPRRCCTTPT m 49 Doc ID 17891 Rev 1 5 51 Overview of STM8 software development toolchains UMO0991 1 1 1 6 51 Overview of STM8 software development toolchains To develop compile and run an application software on an STM8L microcontroller the following software toolchain components are required e Integrated development environment 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 ST toolset including STVD and STVP You may also use the IAR Embedded Workbench for STMicroelectronics STM8 This toolchain is made up of the following components Integrated development environment for building and debugging embedded applications e Compiler Warning IAR Embedded Workbench supports STM8L firmware library versions 1 3 0 and higher 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 Full featured debugger Project management Syntax highlighting editor Integrated programming interface Doc
38. on up to 16 Kbytes of code and temporary storage of up to 32 KBytes For more information refer to http www cosmic software com e Hhaisonance C compiler for STM8 free up to 32Kbytes of code For more information refer to http www raisonance com e STM8 assembler linker This is a free assembly toolchain included in the STVD toolset It allows you to assemble and link your application source code Doc ID 17891 Rev 1 7 51 i Overview of STM8 software development toolchains UMO0991 1 4 1 5 8 51 IAR Embedded Workbench IAR Embedded Workbench is a set of development tools for building and debugging embedded system applications using assembler and C It provides a completely integrated development environment that includes a project manager editor build tools and C SPY debugger The C compiler for STM8 which is included in the toolset is free for up to 8Kbytes of code Firmware libraries The STM8L15x standard firmware library is a complete package consisting of drivers for all the standard peripherals of STM8L 15x microcontrollers It is written in strict ANSI C code and is fully MISRA C 2004 compliant Refer to Section 3 1 STM8L 15x standard firmware library and for details on the installation and configuration of this library Doc ID 17891 Rev 1 ky UM0991 2 2 1 2 2 Note 2 2 1 Installing the development toolchain Installing the development toolchain Downloading and installing STVD STVD sof
39. ontains My own project include files STM8L15x StdPeriph Driverlsrc contains the STM8L standard library include files 32 51 Doc ID 17891 Rev 1 ky i UMO0991 Building and running your project Figure 26 Creating the STVD workspace for your project 1 ST Visual Develop STVD workspace stw main c BAE C5 File Edit view Project Build Debug Debug instrument Tools Window Help el x ag gd H amp Workspace STYO workspace stw Es stvd project void main void STMBL15x_StdPeriph_Driver i ER m Infinite loop while 1 9 User f inc stmali5x it h i c SIC Lae main c TEN siia medun vester t Hhbrierf Inserts a delay time E stall Sx gt param ncount specifies the delay External Dependencies Gene Senge retyval None d ES Workspace x Build Tools Find in Files 1 Find in Files 2 Debug 4 Console For Help press F1 Ln 8 Cal 3 MODIFIED READ CAP NUM CAL OVR Ready 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 27 3 Figure 27 Checking the selected compiler Project Settings Settings for Debug General Debug MCU Selection C Compiler Assembler 4 stvd project Defaults Toolset Info Toolset STM8 Cosmic X Project specific toolset path Evan L Toolset sub paths relative to the Root path Bin path Incl
40. ory Click Project gt Rebuild All to build your application Clicking Project gt Download and Debug io start the debug session Click Debug gt Go 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 application note You can also use Doc ID 17891 Rev 1 ky UMO0991 Building and running your project IAR debug capabilities to run the code step by step and monitor the variables see IAR Embedded Workbench help Figure 24 Selecting the debug instrument Options for node project Category Factory Settings General Options ClC Compiler Assembler Output Converter Setup Extra Options Images Plugins Custom Build Build Actions Linker Driver Simulator STice ST LIMK ST LINK Setup macros Use macro file Device description file Override default Cancel 5 3 Creating your own project This section explains step by step how to create your own application project using either STVD or IAR Embedded Workbench environments The firmware library can be used or not according to the kind of application code to develop All projects must be created starting from STM8L Discovery_dev development package see Section 5 1 Description of the STM8L DISCOVERY development package 5 3 1 Creating your project structure The best way to proceed is to start from the Project_template direc
41. re IAR to use ST LINK as debug instrument see Figure 23 a Right click on project Debug and select options b Select Debugger as Category and ST LINK in the Driver field 6 Copy stm8lt15x h to the STM8L15x StdPeriph Driver inc directory of your IAR workspace see Figure 29 Right click on the STM8L15x StdPeriph Driver inc directory in the IAR workspace window Select Add gt Add Files Browse the sm8 15x h file location in STM8L DISCOVERY_dev Libraries STM8L15x_StdPeriph_Driver inc 7 Make sure include stm8115x h is present of your main c file Figure 36 Copy stm8s h to Include Files FWLib stmal1 xh Files a lud tnall5x h Ha G STMBL15x StdPeriph Driver a i Bir addtogroup Template 8 f Ha 3 User Ha G inc Private typedef L E stmalt5x ith Private define La src Private macro main c Private variables stmBl15x itc Private function prototypes a 71 Output Peres functions einen Y project Fddes ox seh stmalx E stmelisx timt h C3 STMBL Discovery dev 3 H stm amp li5x adc h E stmali5x irkim h B stmali5x rtima h E E Libraries stmeli5x_beep h stmaltsx itc h E stmali5x tim3 h E 3 STMBL15x StdPeriph Driver E stmalisx ck h E stmaliSx_iwdg h E stmali5x tim4 h om B skmall5x camp h E stmali5x lcd h E stmell5x usart h e E B stm liSx_dac h E stm ll5x_pwr h Z stm amp li5x wfe h E E Project B sktm amp li5x dma h Bll5x
42. rial 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 ik Step 1 User Information This computer Serial Key ERA sd Maal ae aA de ou FRAU Step 2 Use one of the Following links to request an Activation Code Athos www Raisonance com licensem raisonance com Step 3 Paste the Activation Code and select Next Figure 8 Personal information form Company Address 1 Addressz Ed City Zip code Country select a Country w The Activation Code will be sent to this email F da not want to receive other product news from Raisonance Doc ID 17891 Rev 1 UM0991 UMO0991 Installing the development toolchain Figure 9 Serial key information form S http www mcu raisonance com index php PHPSESSID 9F Sf 60m 1 jy3kc8Fdcobotck46 amp _bdx alias stm8_st _registration MICROCONTROLLER v Support 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 toolset to output code up to 16 Kbytes in size for STM8 and ST First download and install Ride and RKitSTM8 Free downloads Then obtain the Activation Code on this page Instructions are provided below Serial Key 2 2 3 Compiler settings STVD uses the default compiler defined
43. rogramming message h PROGRAM MEMORY A DATA MEMORY OPTION BYTE gt Programming OPTION BYTE area z OPTION BYTE programming completed gt Verifying OPTIOH BYTE area lt OPTION BYTE successfully verified lt i ia lt Unknown gt ST LIMK STMBS51USxb5 Sw IM 26 51 Doc ID 17891 Rev 1 UMO0991 Building and running your project 5 Building and running your project 5 1 Description of the STM8L DISCOVERY development package ST provides a complete development package the STM8L Discovery_dev It allows to easily get started with the STM8L DISCOVERY by simplifying application code development and execution using the standard peripherals drivers This package can be downloaded together with the present user manual from http www st com STM8L discovery The package is structured as follow Figure 22 STMSL Discovery dev package content 3 STMBL Discovery dev 3 iC Libraries 3 E STMBL15x StdPeriph Driver c inc 3 src 3 E Project 3 i Discover 3 EWSTMES c inc 3 src I STVO O Cosmic oo Raisonance Ly My mun project C Project template WavesGenerator 5 1 1 Libraries The library is located in the Libraries directory e SIM8L15x StdPeriph Driver This directory contains the source and header files of the STM8L standard firmware library Warning Itis strongly recommended to upgrade the library as soon as new releases are available see Section 5 4 5 1 2 Application code
44. roject in the STM8L DISCOVERY development package Figure 30 No library linked Workspace Eres STVD workspace sty stvd project Sy STMBL15x StdPeriph Driver 5 inc stmalt5x h lt q User Sy inc stmali5x it h 5g src main c stm _inkerrupt_vector c stmalt5x it c External Dependencies E Workspace Gl Comment the line below if you will not use the peripherals drivers In this case these drivers will not be included and the application code will he based on direct access ta peripherals registers define USE STDPERIPH DRIVER Rendi brief In the following line adjust the value of External High Speed oscillator HSE used in your application stmall5s h Linking the STM8L 15x standard firmware library to your STVD project This section explains step by step how to link the STM8L standard firmware library to your STVD project Prior to linking the library to your project check that the STMaL 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 STM8L standard firmware library to your STVD project 1 Edit stm8 15x h and uncomment define USE STDPERIPH DRIVER see Figure 38 Figure 31 Linking the STM8L 15x standard firmware library step 1 Workspace pes STVD workspace sty stwd project 9 STMBL15x StdPeriph Driver amp inc
45. s available from the Windows start menu 1 Open the STVP GUI and select Configure Configure ST Visual Programmer from the main menu toolbar The configuration dialog box opens 2 Inthe hardware list select ST LINK as programming board 3 Inthe 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 4 inthe programming mode list select SWIM The programming modes displayed depend on your programming equipment 5 Inthe device list select STM8L152x6 as the ST microcontroller you are going to program see Figure 16 Figure 18 Select your MCU Configuration Hardware Device ST MDT2 EIT STMSAHB18 ST 7MDT4 EPB ST7MDT5 EPB STHSL101z2 ST MDT6 EPB2 aes elel Le mek STHSL101x3 ST7HDT7 EPB 2 STHSL151x4 ST7MDTH1 EPB STMSL1S1x6 STMSL15 24 6 Select the OPTION BYTE tab and click Read gt Current tab in the menu toolbar All the STM8L152C6T6 option bytes and their respective values are displayed in the window see Figure 19 24 51 Doc ID 17891 Rev 1 Ayr UM0991 no project STVP Configuring the option bytes for your application Figure 19 STVP option byte selection menu File Edit Project Configure Read Program WerlPy Erase Blank Check View Help e ri Current tab Ctrl R ah All tabs fon active sectors iF any Value 44 00 00 00 00 00 00 OLI WiwDG_ HALT Ww DG Hw NO_IWOG_IN_HALT PD Hw LSE
46. s the Peripheral registers window It can be used to display the content of the STM8L105C6 peripheral registers during the debug session see Figure 44 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 45 Doc ID 17891 Rev 1 47 51 i Building debugging and running your application with STVD UMO0991 6 3 48 51 Figure 44 Peripheral registers window Peripheral registers Value BS STMSL152C6 ee e Ez CES ET E E E E23 ER Peripheral Registers Figure 45 Watch window Watch 1 watch2 J Watch A Watch Online help For more information on building and debugging features refer to embedded STVD online help page Help gt Help Home Page Doc ID 17891 Rev 1 ky UMO991 Building debugging and running your application with STVD Figure 46 STVD online help E STVD help Ho amp m Hide Bac Print Options Contents Index Search Favorites 1 Getting started with STYD e 2 Your STVD graphical environment 7 3 Project creation and build 4 Basic debugging features 5 Simulator features el e B In circuit debugging Ay rd I nt rod u ct ion e DYP and EMU2 HDS2 emulator features e 8 STice features Q 3 EMU3 emulator features
47. t toolchain UMO991 Figure 12 Download software OIAR SYSTEMS Registration Confirmed Thank vou for your registration of the product IAR Embedded Workbench for STMicroelectronics STM 8K KickStart Edition v 1 10 Download software EXE 78 MB Download fram Europe HTTP site Europe FTP site File Download Security Warning When ins License ee Do you want to run or save this file Name EWSTMS8 K5 1101 exe Type Application 78 0 MB From supp iar cam Hun ave Cancel While files from the Internet can be useful this File type can potentially harm your computer IF you da nat trust the source do nat rur or save this software what s the risk If vau prefer vau can have the License Number and Key sentto you by email for later reference 5 Step5 Go through the installation steps and copy the License Number to the License field see Figure 13 1 8 51 Doc ID 17891 Rev 1 UMO0991 Installing the development toolchain Figure 13 Enter User Information Enter your name the name of your company and your IAA Embedded workbench for ST Microelectronics 5 TMB 1 10 1 Kickstart license number Company 3 Microelectronics Can be found an the CO cover or via e mail registration License InstallShield 6 Step6 Enter your License Key in the License Key textbox see Figure 14 Click Next to finish the installation process i Doc ID 17891 Rev 1 19 51 Installing the develop
48. th Fendi brief In the following line adjust the value of Ext used in your application Linking the STM8L standard firmware library to your IAR project This section explains step by step how to link the STM8L standard firmware library to your IAR project Prior to linking the library to your project check that the STMaL 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 STM8L standard firmware library to your IAR project 1 Edit stm8 15x h and uncomment define USE STDPERIPH DRIVER see Figure 38 Figure 38 Linking the STM8L standard firmware library step 1 x define IAR_ gelse error Unsupported Compiler endif i f Compiler deri Ha 3 STMBL15x StdPeriph Driver La G inc L F stmall5xh L src User Ha inc L H sre main c stmBll5x itc Output L E stmBl5x ith project Doc ID 17891 Rev 1 10 defined USE STDPERIPH DRIVER Comment the line below if you will not use the periph In this case these drivers will not be included and based on direct access to peripherals registers endif fret brief In the following line adjust the value of Exte used in your application dag Spi axe d anxia ee ee deed us 53 An geesuul a cpu p E cell UMO0991 Building and running your project 2 Copy stm8l 15x conf h from the My own proje
49. tory 1 Extract the content of STM8L Discovery_dev zip file on your PC 2 Copy the Project_template directory and rename it My_own_project see Figure 25 Your STVD or IAR project comes already structured thus simplifying the project creation SZ Doc ID 17891 Rev 1 31 51 Building and running your project UMO0991 Figure 25 Creating your project structure G STMSL Discovery_dev 7 Siam ct it Libraries O My_own_projec 5 EWSTMB G STMSL15x_StdPeriph_Driver z E It Project E src Discover 3 STD y My own praject e E E Cosmic C Project template E Raisonance j WavesGenerator 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 STM8L DISCOVERY_dev Project My_own_project STVD Cosmic STVD_workspace s tw for Raisonance select STM8L DISCOVERY_dev Project My_own_project STVD Raisonance STVD_workspa ce stw stvd project appears in the STVD workspace window as shown in Figure 26 Its structure is slightly different from the structure of My_own_project directory in STM8L Discovery_dev package User src has the same content as STM8L DISCOVERY_dev Project My_own_project src TM8L15x_StdPeriph_Driver sre contains the STM8L standard library source files User inc c
50. tware is available at http www st com stonline products support micro files sttoolset exe 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 Cosmic http www cosmicsoftware com download stm8 32k php e Raisonance http www mcu raisonance com Please note that the Cosmic 32K version does not include direct support from Cosmic 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 17891 Rev 1 9 51 Installing the development toolchain UMO991 1 Step 1 Connect to http www cosmicsoftware com download_stm8_16k php or to http www cosmicsoftware com download_stm8_32k php and fill in the information form see Figure 2 Click Submit to access the download page Figure 2 Cosmic compiler form Cosmic Software Download Microsoft Internet Explorer provided by Corporate Package Fabric st _ Fabric st File Edit View Favorites Tools
51. ude path Hstm8 Library path Output directory Cancel Go to Projects gt settings gt MCU selection and select STM8L152C6 from the MCUs list Make sure that MCU selected is displayed in the selected MCU field before clicking OK see Figure 28 Doc ID 17891 Rev 1 33 51 Building and running your project UMO991 Figure 28 Select the MCU Project Settings Settings for Debug General Debug MCU Selection C Compiler Assembler 4 gt Filter Show MCUs containing MCUs STM8L101F3P STM8L101F3U STM8L101G2U STM8L101G3U STMSL1OTK3T STMSL101K3U STM8L151C4 STM8L151C6 STM8L151G4 STMSL151G5 STMSL151K4 STMSL151KB STMSL152C4 Selected MCU STM8L1 52C6 a stvd project CCCCCCCCO0006 OK Cancel 34 51 Doc ID 17891 Rev 1 UMO0991 Building and running your project 5 Configure 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 stm8l15x h to the STM8L15x_StdPeriph_Driver ine directory of your STVD workspace see Figure 29 A Right click on the STM8L15x_StdPeriph_Driver ine directory under stvd project Select Add Files to Folder Browse the sm8 15x h file location in STM8L DISCOVERY devLibrariesY STM8L15x StdPeriph DriverVinc 7 Make sure include stm8115x h is present of your main c file Figure 29 Copy stm8l 15x h to Include Files FWLib Workspace Tas TY
52. x irtim h stmali5x itc h stmliSx_iwdg h stmliSx_Ied h stm liSx_pwr h stmali5x rst h stmali5x rtc h stm8l15x spi h stm8li5x svscfg h stm8li5x tim1 h stm8l15x tim2 h stmali5x tim3 h stmliSx_tim4 h stm8li5x usart h stm8li5x wfe h stmali5x wwdg h STM8L Discovery dev O Libraries C3 STM8L15x StdPeriph Driver inc o C3 Project 73 Discover ae My_own_project i 73 Project template Doc ID 17891 Rev 1 3pud pipi E qm pr mit n yu stm8l15x adc c stm liSx_beep c stm liSx_clk c stm8li5x comp c stm8li5x dac c stm8li5x dma c stmal15x exti c stmali5x irtim c stmBl15x_itc c stmali5x iwdg c stmali5x lcd c stm8li5x pwr c stm8l15x rst c stm8l15x rtc c stm amp l15x Size 11 2 KB stmali5x tim2 c stmali5x tim3 c stmali5x tim4 c stm amp li5x usart c stmali5x wfe c stm8li5x wwdg c 37 51 Building and running your project UMO0991 5 3 4 Creating your IAR Embedded Workbench project 1 Open IAR Embedded Workbench and click File gt Open gt Workspace 2 Browse for the Workspace location and select workspace eww in the EWSTM8 directory STM8L DISCOVERY_dev Project My_own_project EWSTM8 workspace eww project Debug appears in the workspace window as shown in Figure 26 Its structure is slightly different from the structure of My_own_project directory in STM
53. you have the latest version of the STM8L standard firmware library see http www st com mcu STM8L15x standard firmware library The STM8L15x standard firmware library contains a collection of routines data structures and macros covering the features of the STM8L 15x peripherals as well as a description of the device drivers see Figure 15 The STM8L 15x standard firmware library allows to develop an application on any STM8L15x 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 examples for each peripheral All these examples are provided with workspace and project definition files for STVD and C compilers and for IAR Embedded Workbench for STM8 to allow loading and compiling them easily into you development environment These examples are developed to run on an STM8L 15x device with SIMicroelectronics STM8L1526 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 STM8L DISCOVERY They are available from the STM8L DISCOVERY web pages at http www st com stm8l discovery Doc ID 17891 Rev 1 21 51 Description of firmware library UMO991 3 1 1 22 51 Figure 15 STM8L15x standard firmware library architecture Application layer Register de
Download Pdf Manuals
Related Search
Related Contents
e Instructions f Mode d`emploi D Anleitung N Pantalla Táctil ComboTouch - SGI Sistemas G-SERIES 取扱説明書 A COVER.fm - Nilfisk PARTS HiTi Manual del usuario Moen T2343 User's Manual M-Audio KeyStudio 25 Electronic Keyboard User Manual Copyright © All rights reserved.
Failed to retrieve file