Home
Getting started with STM8L
Contents
1. NRST gt System reset I Illegal op code reset Pulse generator I IWDG WWDG software reset min 20 us lt SWIM reset EMS reset TE Delay POR BOR reset External reset 16 42 Doc ID 16139 Rev 1 ky Reset control AN3029 5 1 1 Output characteristics e A valid pulse on the pin is guaranteed with a 20 ns pulse duration on the internal output buffer e After a valid pulse is recognized a pulse on the pin of at least 20 us is guaranteed starting from the falling edge of A Figure 8 Output characteristics A 220n gt gt A A P 20 us pulse stretch min gt Pad Reset requested 5 1 2 Input characteristics e All pulses with a duration less than 50 ns are filtered e Alltrain burst spikes with a ratio of 1 10 must be filtered This means that a negative spike of up to 50 ns is always filtered when a 5 ns interval between spikes occurs ratio 1 10 e All pulses with duration more than 300 ns are recognized as valid pulses Figure 9 Input characteristics A gt 5 ns gt 5 ns 300 ns I 50 ns 50 ns 50 ns Fred A a Negative train of glitch filtered Valid Reset reguested dix 5 2 Hardware reset implementation In most cases the STM8L does not require an external reset circuit to power up correctly The STM8L10
2. E 2 Hide Locate ach onward Stop Refresh Home Print Options Contents Ind ch Favorit X E ae Search Favorites Main Page Modules Data Structures Files Directories STM Firmware Library a D Modules E Data Stuctures STM8 Firmware Library and Examples E Data Fields is File List E e On line Help Manual E Globals STMicroelectronics ky Doc ID 16139 Rev 1 AN3029 Setting up the STM8 development environment 10 8 10 3 1 Running the demonstration software e Goto www st com mcu and search for STM8L products e Choose STM8L1x EVAL or STM8L1526 EVAL firmware e Open the project demo STVD Cosmic project stw To run the demonstration software on the STM8 evaluation board the project has to be compiled and the correct HW tool must be selected before the debug session can be started Compiling the project The project can be compiled using the Build function in the Build menu see Figure 20 Figure 20 STVD Building the project 1 ST Visual Develop project stw main c C5 File Edit View Project Build Debug Debuginstrument Tools Window Ta Compile main c CtrltF ae n f Bui F7 Workspace ES Rebuild All ies project stw project Batch Build s s i Source Files Clean sise x Include Files 9r aA External Depen faut i i dver Configurations r idat 8 t keeee 9 in T
3. Reset control AN3029 5 Reset control 5 1 Reset management overview The reset pin is a 3 3 V bidirectional I O After startup it can be programmed by software to be used as a general purpose I O Its output buffer driving capability is fixed to Iolwin 2 MA 0 45 V in the 1 8 V to 3 6 V range which includes a 45 k pull up Output buffer is reduced to the n channel MOSFET NMOS The receiver includes a glitch filter whereas the output buffer includes a 20 us delay There are many reset sources including e External reset through the NRST pin e Power on reset POR and brown out reset BOR During power on the POR keeps the device under reset until the supply voltage Vpp and Vppjo reach the voltage level at which level the BOR starts to function STM8L101 has only a POR e Independent watchdog reset IWDG e Window watchdog reset WWDG only for STM8L15x e Software reset The application software can trigger reset e SWIM reset An external device connected to the SWIM interface can request the SWIM block to generate a microcontroller reset e Illegal opcode reset If a code to be executed does not correspond to any opcode or prebyte value a reset is generated e Electromagnetic susceptibility EMS reset Generated if critical registers are corrupted or badly loaded Figure 7 shows a simplified functional I O reset schematic Figure 7 Reset management STM8 lt gt Fitr
4. ky AN3029 Application note Getting started with STM8L Introduction This application note complements the information in the STM8L datasheets by describing the minimum hardware and software environment required to build an application around an STMBL 8 bit microcontroller device A brief description of the principal hardware components is given The power supply analog to digital converter ADC clock management and reset control are described in some detail In addition some hardware recommendations are given This application note also contains detailed reference design schematics with descriptions of the main components The STM8L uses the same toolchain The STM8 development tools and software toolchain are common to STM8L STM8S and STM8A and are presented in Section 8 and 9 Section 10 describes how to set up the STM8 development environment Finally Section 11 provides a list of relevant documentation and online support resources September 2009 Doc ID 16139 Rev 1 1 42 www st com Contents AN3029 Contents 1 Hardware requirements summary eeeeeeeeeeeeeeeeeeeeee 7 2 Power SUDDIV sex eaux BHAN AL AS Parse AC R ABC al BSL gh AR bed COR ig ic i ces 7 2 1 Power supply overview 0 0000 seen ee en ne eee 7 2 2 Main operating voltages eseeeeeee ee ee ee ee ee 8 2 3 Power on power down reset POR PDR eeeeeeeeeeeee eee eee 9 3 Analog to digital converter ADC 200 cee eee eee
5. ICD ICP connector on application board SWIM connector linked to microcontroller X ST microcontroller on application board A RLink and STLink RLink and STLink are debug tools that allow the STM8L evaluation board or any user application board with the SWIM interface to be connected to a host PC via USB for debugging and programming See Section 10 3 3 Connecting the hardware on page 35 Doc ID 16139 Rev 1 ky AN3029 STMB software toolchain 9 STMS software toolchain To write compile and run the first software on an STMB8L device the following components of the software toolchain are required see Figure 16 e Integrated development environment e Compiler e Firmware library optional used to ease the start up Figure 16 STM8 software toolchain fee sr visual Develop 7 1 eae reise Re ES e Ss ET kl IS Is A g E E e m a mm IE as E n Further interrupts are masked by hardu E Workspace ax f tutorial stw cosmic L0 ES ee case RED nextState GREEN 4 break Include Files case OFF QQ External Dependenci Binterrupt nostack void trapISR nextState OFF ER st7 asm Et break color nextState default nextState currentStateci break Determine next state Go to next state and update traced var 4 4 if state nextState stateOccurence lt MAX 71 case RED 22 nevrSraresGRFFM currentState nextState state currentState stateOccur
6. 1 22 42 STM8 development tools Typically the following tools are needed to get started e STVD for integrated development environment e STM8C compiler from Cosmic or Raisonance e ST toolset and STM8 firmware library from STMicroelectronics STM8L10x StdPeriph Lib for STM8L101 or STM8L15x StdPeriph Lib for STM8L15x e STM8 evaluation board from STMicroelectronics STM8L101 EVAL for STM8L101 and STM8L1526 EVAL for STM8L 15x e f you use STM8L101 EVAL you also need the HW debug interface Rlink from Raisonance The debug interface ST LINK is included in STM8L1526 EVAL Single wire interface module SWIM SWIM overview In circuit debugging mode or in circuit programming mode are managed through a single wire hardware interface based on an open drain line featuring ultra fast memory programming Coupled with an in circuit debugging module the SWIM also offers a non intrusive read write to RAM and peripherals This makes the in circuit debugger extremely powerful and close in performance to a full featured emulator The SWIM pin can be used as a standard I O with 8 mA capability which has some restrictions if the user wants to use it for debugging The most secure way to use it is to provide a strap option on the PCB Please refer to the STM8 SWIM communication protocol and debug module user manual UM0470 for more SWIM protocol details Figure 11 Debug system block diagram 100 kHz Osc v Peripheral SW
7. com Figure 14 STice in emulation configuration Free ST STMB toolset STVD and STYP running on your PC drive STice STice SYSxxx Includes all emulation resources MEB TEB and PEB CF FPxxx Connection flex to connect to application board ff 3 FA N M Le gt N E C d a Se AD xxxx Connection P AS xxxx Adapter socket on yo adapter to link IN application board to plug in connection cable to iY emulator in place of microcontroller microcontroller Doc ID 16139 Rev 1 25 42 STM8 development tools AN3029 8 2 3 8 3 26 42 In circuit programming and debugging In the in circuit debugging programming configuration STice allows the application to be programmed in the microcontroller and for the application to be debugged while it runs on the microcontroller on the application board STice supports the SWIM protocol making it possible to in circuit program and debug the microcontroller using only one general purpose I O In both the emulation and the in circuit programming debugging configuration STice is driven by the ST visual develop STVD or ST visual programmer STVP integrated development environment running on the host PC This provides total control of advanced application building debugging and programming features from a single easy to use interface Figure 15 In circuit programming and debugging ICD ICP flat cable connects STice to microcontroller via
8. tools Typical setups are described below for the following SW and HW tools e STM8C compiler from Cosmic e STtoolset and STM8 firmware library from STMicroelectronics STM8L10x StdPeriph Lib for STM8L101 or STM8L15x StdPeriph Lib for STM8L15x e STMB8 evaluation board from STMicroelectronics STM8L101 EVAL for STM8L101 and STM8L1526 EVAL for STM8L 15x e f you use STM8L101 EVAL you also need the HW debug interface Rlink from Raisonance The debug interface ST LINK is included in STM8L 1526 EVAL Installing the tools All software tools are delivered with a setup wizard which guides the user through the installation process It is recommended to install the tools in the following order 1 C compiler 2 ST toolset 3 STM8 firmware library ST LINK does not need any dedicated software installation in the STM8 development environment because the necessary drivers are delivered with the ST toolset The R link drivers must be launched separately as follows Start Programs STtoolset Setup Install Rlink driver Doc ID 16139 Rev 1 29 42 Setting up the STM8 development environment AN3029 10 2 Nole 30 42 Using the tools Once the tools installation is complete the ST visual develop STVD integrated development environment can be launched The user then has the choice to generate either a new workspace with a new project or to open an existing workspace If using the STVD for the first time it is recommend
9. 1 reset state is released 1 ms after the POR value 1 35 V to 1 65 V is reached At this time Vpp should be in the 1 65 V to 3 6 V range The STM8L15x reset state is released 1 ms after the BOR minimum value 1 75 V is reached Doc ID 16139 Rev 1 17 42 Recommendations AN3029 6 6 1 6 2 6 3 6 4 18 42 Recommendations Printed circuit board For technical reasons it is best to use a multi layer PCB with a separate layer dedicated to the Vss and another layer to the Vpp supply This results in a good decoupling as well as a good shielding effect For many applications economical reguirements prohibit the use of this type of board In this case the most important feature is to ensure a good structure for the Vss and power supply Component position A preliminary layout of the PCB must separate the different circuits according to their electromagnetic interference EMI contribution This reduces cross coupling on the PCB for instance noisy high current circuits low voltage circuits and digital components Ground and power supply Vss Vpp The Vss should be distributed individually to every block noisy low level sensitive and digital with a single point for gathering all ground returns Loops must be avoided or have a minimum surface The power supply should be implemented close to the ground line to minimize the surface of the supply loop This is due to the fact that the supply loop acts as an antenn
10. 10 3 1 Analog power i cicotcigcewe NEUES dae nee mas Osta eae ea RE hin qa 10 3 2 Analog input sues iv we RA ERR RRERR ERA UR REX GERE X AER RGAG ERES 4 10 4 Clock management ieeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 12 4 1 Clock management overview 00 0c eee sees 12 4 2 Internal clocks 4 me te td ig Sa ig a hea cin E ea RR ees 12 4 3 External clock 2 si c2i046 504084 rrr dr be PESE RE RES 12 4 3 1 HSE Clk i iu d poke d adis dora Une Dacos AUD t d 12 4 3 2 lin MED 14 4 3 3 External source LSE bypass eeseeeeeeeeeeeeee nee ene 15 4 3 4 External crystal ceramic resonator LSE crystal 15 5 Reset CONN tcataatoss dees seer eR ROUES EE RM E RR CECI 16 5 1 Reset management overview uussa aaan ee ee ee ee 16 5 1 1 Output characteristics llli 17 5 1 2 Input characteristics liliis 17 5 2 Hardware reset implementation llle 17 6 Recommendations lelleeee enne 18 6 1 Printed circuit board iris kx REX REX REM REP RES ee ee nee ee ee ei ee 18 6 2 Component position eeeeeeeee eew ees eeivnceat seed RE AER 18 6 3 Ground and power supply Vss Vpp eee eee tee 18 6 4 Decoupling PTT 18 65 Othersignals see ee eee bie dss e wa seeds beeen eee 19 6 6 Unused I Os and features 0 00 e ees 19 2 42 Doc ID 16139 Rev 1 ky AN3029 Contents 6 7 User options se sore aige eruti GIRLS Shaor ho eee ra ceva er Mo
11. HE Doc ID 16139 Rev 1 33 42 Setting up the STM8 development environment AN3029 10 3 2 34 42 Selecting the correct debug instrument In the example below the Rlink tool is used for communicating via the SWIM interface with the on board debug module of the STM8 The Rlink tool can be selected from the Debug Instrument Selection list in the Debug Instrument Settings dialog see Figure 21 Figure 21 STVD Selecting the debug instrument Debug Instrument Settings Target Debug Instrument Selection Select the Target you want to use for debug session Swim Blink X Target Port Selection Select the connection port for usb Hlusb the Target selected above Add Remove Show the selected target notification at start of debugging session Doc ID 16139 Rev 1 ky AN3029 Setting up the STM8 development environment 10 3 3 Connecting the hardware The debug tool STLink is included on the STM8L1526 EVAL board You can connect the PC to the USB connector This connection ensures the debug connection and the power If the jumpers on the boards are no longer in the default position please read STM8L1526 EVAL user manual to select power and debug support jumpers For the STM8L101 EVAL the Rlink tool can be connected to the PC by a standard USB connection It is also powered by the USB interface On the controller side the connection to the STM8 evaluation board is made usi
12. IM entry cup lt gt DM gt SM8 a gt RAM decode DBG Comm layer gt NVM Internal RC Doc ID 16139 Rev 1 ky AN3029 STM8 development tools 8 1 2 SWIM connector pins The SWIM connector pins consist of four pins as described in Table 2 Table 2 SWIM connector pins Pin number Pin name Pin 1 Vpp Pin 2 SWIM pin Pin 3 Vss Pin 4 Reset 8 1 3 Hardware connection Figure 12 Hardware connection AD ICC SWIM adapter SWIM connector Application board 1X Voo SWIM cable STM8 Caution Itis recommended to place the SWIM header as close as possible to the STM8L device as this minimizes any possible signal degradation caused by long PCB tracks Doc ID 16139 Rev 1 23 42 STM8 development tools AN3029 8 2 8 2 1 24 42 STice emulator STice overview The STice is a modular high end emulator system which connects to the PC via a USB interface and to the application board in place of the target microcontroller It is supported by the free STM8 toolset IDE ST visual develop STVD programmer ST visual programmer STVP and STM8 assembler Please refer to the STice emulator for STMa for more details STice has two distinct modes of operation which are described further in this section e Emulatio
13. V 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 UNLESS EXPRESSLY APPROVED IN WRITING B
14. Y 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 2009 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 16139 Rev 1 ky
15. a and is therefore the main emitter and receiver of EMI All component free surfaces of the PCB must be filled with additional grounding to create a kind of shield especially when using single layer PCBs Decoupling The standard decoupler for the external power is a 100 uF pool capacitor Supplementary 100 nF capacitors must be placed as close as possible to the Vss Vpp pins of the microcontroller to reduce the area of the current loop As a general rule decoupling all sensitive or noisy signals improves electromagnetic com patibility EMC performances There are two types of decouplers e Capacitors close to components Inductive characteristics which apply to all capacitors beyond a certain frequency must be taken into account If possible parallel capacitors with decreasing values 0 1 0 01 uF should be used e Inductors Although often ignored ferrite beads for example are excellent inductors due to their good dissipation of EMI energy and there is no loss of DC voltage which is not the case when simple resistors are used Doc ID 16139 Rev 1 ky AN3029 Recommendations 6 5 6 6 6 7 6 8 Other signals When designing an application the following areas should be closely studied to improve EMC performances e Noisy signals clock e Sensitive signals high impedance e Signals for which a temporary disturbance permanently affects operation of the application for example interrupts and hand
16. dh gh Aoi ai 19 6 8 Bootloader lt a dua pates wd Saas Ru Vil e ade da ee 19 7 Reference design ona canner eee cee e dene eee eee 20 7 1 Component references 0000 eee 20 7 2 SCHBmsliBS a c25 ccna taro See nee NU AO ROREIKCH Te dia aie SUR CR apa BG ATA 21 8 STM8 development tools slllsles 22 8 1 Single wire interface module SWIM seeeeeee ee sees 22 8 1 1 SWIM overview sseee Rh teens 22 8 1 2 SWIM connectorpins veeeeeeeee nee eee 23 8 1 3 Hardware connection eeeeeeeeee ee ee ee ee non ee ee ne sis 23 8 2 STice emulator see ee ee ee ee nn ee GH sos TED RE AER RAS 24 8 2 1 STice overview 6 ee ee ee ise ne se nos non non non non en non ns 24 8 2 2 STice in emulation configuration 0 000 cc eee 25 8 2 3 In circuit programming and debugging ee eee eee 26 8 3 RLink and STLink e ph ee CR ee ee ee ns see non son ou eer ke x 26 9 STM8 software toolchain 00 cece eee eee eee ee 27 9 1 Integrated development environment lille elles 28 9 2 Pon PPP 28 9 3 Firmware library 404 4 bes bedi eee hbk Eae baka Oh AIR e einne ae 28 10 Setting up the STM8 development environment 29 10 1 Installing ihetoolS sisse RR ERRRRA REFERRE RE RR REEL 29 10 2 Using the TOS csse uae rr ax o op e cd net a RR YR Pn s 30 10 2 1 Projectediting AR RC AR NNCRL SE AC AL SEA ees 31 10 2 2 Onli
17. ed to open an existing project from the STM8 firmware library Even if you are not intending to use the library an existing library project can be used as a template to configure all the compiler options Enter your own code after main The STM8 firmware library includes several examples for each peripheral plus one workspace containing a blank project which is ready to receive your C code It is located in the firmware subdirectory Project Template see Figure 17 You can choose between STVD Cosmic STVD Raisonance or RIDE Figure 17 STVD open example workspace 4 ST7 Visual Develop File Edit View Project Build Debug Debug instrument Tools Window Help ime sjaja re la Oo ga jac mmuijmeies em mig ms gt Workspace figs No Workspace Open Workspace Look in 3 15TMB8 Firmware Library YProjectiCosmic 4 fo SR Eg L Debug f amp Workspace Release project stw File name project stw pen Files of type Project Workspace stw Cancel Find in Files 1 Find in Files 2 Ln Cel MODIFIED READ CAP NUM SCRL OVA Ready Doc ID 16139 Rev 1 ky AN30 29 Setting up the STM8 development environment 10 2 1 Project editing All project source files are visible and can be edited see Figure 18 Figure 18 STVD MCU edit mode ST Visual Develop project stw main c ie File Edit View Project Build Debug Debuginstrument Tool
18. encec t i C merc CADocume WATCHDOG SOFTWARE WDG_HALT RESET gt Run Application stopped Breakpoint 1 trapISR at timer c 69 4 Doc ID 16139 Rev 1 27 42 STM8 software toolchain AN3029 9 1 9 2 9 3 28 42 Integrated development environment The integrated development environment ST visual develop STVD provides an easy to use efficient environment for start to finish control of application development from building and debugging the application code to programming the microcontroller STVD is delivered as part of the free ST toolset which also includes the ST visual programmer STVP programming interface and the ST assembler linker To build applications STVD provides seamless integration of C and assembly tool chains for ST including the Cosmic and Raisonance C compilers and the ST assembler linker When debugging STVD provides an integrated simulator software and supports a complete range of hardware tools including the low cost RLink in circuit debugger programmer and the high end STice emulator To program applications to an STM8L the STVD also provides an interface for reading from the microcontroller memories writing to them and verifying them This interface is based on the ST visual programmer STVP and supports all the target devices and programming tools supported by STVP The free ST toolset for STM8 is available from STMicroelectr
19. ge includes Application e STM8L101 and STM8L15x datasheets e How to program Flash memory and data EEPROM on STM8L microcontrollers PM0054 e STM8L101 and STM8L15x reference manuals e STM8 CPU programming manual PM0044 Tools e STM8L101 and STM8L15x firmware library and release note detailed descriptions of the library are included as help files e STice advanced emulation system for ST microcontrollers data briefing e STice user manual e Cosmic or Raisonnance C compiler user manual e STM8L101 EVAL or STM8L1526 EVAL evaluation board user manual e STM8L1x EVAL or STM8L1526 EVAL firmware e ST visual develop tutorial included as help files in the ST toolchain e ST visual develop STVD user manual e STM8 SWIM communication protocol and debug module user manual UM0470 The microcontroller discussion forum on www st com can be used by developers to exchange ideas It is the best place to find different application ideas In addition the website has a knowledge base of FAQs for microcontrollers which provide answers to many queries and solutions to many problems Doc ID 16139 Rev 1 ky AN3029 Revision history 12 Revision history Table 3 Document revision history Date Revision Changes 09 Sep 2009 1 Initial release Doc ID 16139 Rev 1 41 42 AN3029 Please Read Carefully Information in this document is provided solely in connection with ST products STMicroelectronics N
20. he choice refer to the gmcerit calculation in AN2867 Oscillator design guide for ST microcontrollers 2 OSC32 IN and OSC32 OUT pins can be used also as GPIO but it is recommended not to use them as both RTC and GPIO pins in the same application 3 The value of Rgxr depends on the crystal characteristics A 0 Q resistor works with most oscillators A typical value is in the range 5 to 6 Rg To fine tune the Rgxz value refer to AN2867 Oscillator design guide for ST microcontrollers q Doc ID 16139 Rev 1 AN3029 Clock management 4 3 3 External source LSE bypass In this mode an external clock source must be provided It must have a frequency of 32 768 kHz The external clock signal Square sine or triangle with a duty cycle of about 50 has to drive the OSC32_IN pin while the OSC32_OUT pin must be left high impedance see Figure 5 and Figure 6 4 3 4 External crystal ceramic resonator LSE crystal The LSE crystal is a 32 768 kHz low speed external crystal or ceramic resonator It has the advantage of providing a low power but highly accurate clock source to the real time clock peripheral RTC for clock calendar or other timing functions The resonator and the load capacitors have to be connected as close as possible to the oscillator pins in order to minimize output distortion and start up stabilization time The load capacitance values must be adjusted according to the selected oscillator Doc ID 16139 Rev 1 15 42
21. ion 0000 eae 37 STVD Run the software hh 38 STM8 evaluation board 00 0 eee 39 Doc ID 16139 Rev 1 ky AN3029 Hardware requirements summary 2 1 Hardware requirements summary To build an application around an STM8L device the application board should provide the following features e Power supply mandatory e Clock management optional e Reset management optional e Debugging tool support Single wire interface module SWIM connector optional Power supply Power supply overview The STM8L101 can be supplied through a 1 65 V to 3 6 V external source The STM8L 15x can be supplied through a 1 8 V to 3 6 V external source However after startup it can run on voltages down to 1 65 V An on chip power management system provides the constant digital supply to the core logic both in normal and low power modes This garantees that the logic consumes a constant current over the voltage range It is also capable of detecting voltage drops and generate reset to avoid heratic behaviour The STM8L device also provides e One pair of pads Vpp Vss 1 65 V or 1 8 V to 3 6 V The STM8L15x device also provides in the 48 pin package e One pairs of pads dedicated for Vppio Vssio which are used to power only the I O s Vppio and Vss o must be at the same potential respectively as Vpp and Vss e One pair of pads VppA VssA dedicated to analog functions Vppa and Vssa must be at the same poten
22. llation stability Cj and Cj normally have the same value Typical values are in the range from below 20 pF up to 40 pF cload 10 to 20 pF The parasitic capacitance of the board layout also needs to be considered and typically adds a few pF to the component values A clock security system prevents any CPU fatal error from a HSE failure as it safely switches to HSI Doc ID 16139 Rev 1 13 42 Clock management AN3029 4 3 2 14 42 Recommendations In the PCB layout all connections should be as short as possible Any additional signals especially those that could interfere with the oscillator should be locally separated from the PCB area around the oscillation circuit using suitable shielding LSE clock The low speed external clock signal LSE can be generated from two possible clock sources e LSE external crystal ceramic resonator see Figure 5 e LSE user external clock see Figure 6 Figure 5 External clock Microcontroller OSC32 IN OSC32 OUT Hi Z External source ai15765 1 OSC32 IN and OSC32 OUT pins can be used also as GPIO but it is recommended not to use them as both RTC and GPIO pins in the same application Figure 6 Crystal ceramic resonators Microcontroller OSC32 IN OSC32 OUT a XI ai15764 1 To avoid exceeding the maximum value of C 4 and C a 15 pF it is strongly recommended to use a resonator with a load capacitance C 7 pF To fine tune t
23. ly pair should be decoupled with filtering ceramic capacitors C at 100 nF with one chemical C 1 2 uF in parallel on the STM8L device The ceramic capacitors should be placed as close as possible to the appropriate pins or below the appropriate pins on the opposite side of the PCB Typical values are 10 nF to 100 nF but exact values depend on the application needs Figure 2 shows the typical layout of such a Vpp Vss pair Figure 2 Typical layout of Vpp Vss pair STM8 Doc ID 16139 Rev 1 9 42 Analog to digital converter ADC AN3029 3 3 1 3 2 10 42 Analog to digital converter ADC This section is unigue for the STM8L15x Analog power For 48 pin packages the ADC unit has an independent analog supply voltage isolated on input pin Vppa which allows the ADC to accept a very clean voltage source This analog voltage Vppa should be identical to the digital voltage supply on pin Vpp To filter some noise a ferrite bead can be added between Vpp and Vppa This ferrite bead should be choosen according to the frequencies to be filtered The 48 pin package also provides a separate external analog reference voltage input for the ADC unit on the Vref pin This gives better accuracy on low voltage input as follows Vnrr input analog reference positive The higher positive reference voltage for the ADC should be below or equal to Vpp4 When Vppa is below 2 4 V Vref must be equal to Vppa This i
24. m ji PRESENT SOFTWARE WHICH IS FOR ODING INFORMATION REGARDING L AS A RESULT STHMICROELECTRON CT INDIRECT OR CONSEQUENTIAL THE CONTENT OF SUCH SOFTWARE NG INFORMATION CONTAINED HEREI kcenter amp copy COPYRIGHT 2007 bmp main c mono_led c mono lcd h Doc ID 16139 Rev 1 37 42 4 Setting up the STM8 development environment AN3029 10 3 5 Running the software After entering debug mode the software can be started by the run command in the menu Debug Run see Figure 25 Figure 25 STVD Run the software as STMBAL SI xx STM SWIM project stw Debug project elf main c C Hie Edt Yow propt RUM Debus Cebugkytrament lods wedon Heb set bugan o ETR MPATE g SAER SERED Xe aop oshun eee B Gtt i oa edi Oni tita Abime jinctions 16 nCount 1 ELI TE Cho Reset Cbleshftaes 5 noova ant 0 X reet sta adc sth a c ud ores 5 stra keep 5 is nm dhe 8 stm exte Q Rep Into mi nm i tna fesh TB aeo Over fo LL by F tr spo c stn 8c Ph Step Ito ASM AkeF11 gt E stma_tcc Oh Step Over AM Lopes S tee oi i x 5 stn dga P Rep Oe Qfil E wain c 45 E E st er a ponto curser QrleF 30 0x8902 Delayeios 0x85 is sna rit 0x8903 Delagell 0x81 RET f tna spie Z sete La main c 47 void main void el a smi Emte sel 0x8904 main Ox5204 SUDU 32 40x05 3 ema E ci fere 57 GPIO InicScr
25. n mode e in circuit mode It can also be used instead of RLink for SWIM connection Figure 13 Connection description Emulation system Connection flex Connection adapter Adapter socket Emulation system STice e Emulator box e Cables for USB power supply trigger and analyzer input Connection flex e 60 pin or 120 pin cable for connection to the application board Connection adapter e Links the connection flex to the footprint of the STM8L microcontroller Adapter socket e Package specific socket for connection adapter and STM8L microcontroller Doc ID 16139 Rev 1 AN3029 STM8 development tools 8 2 2 3 STice in emulation configuration In emulation configuration the STice is connected to the PC via a USB interface and to the application board in place of the target microcontroller being used e Connection flex Flexible cable 60 pin or 120 pin depending on the target microcontroller that relays signals from the STice to the application board e Connection adapter Links the connection flex to the footprint of the target microcontroller on the users application board e Adapter socket Socket that solders to the application board in place of the microcontroller and receives the connection adapter The above accessories are not included with the STice system To determine exactly what is required for any supported microcontroller refer to the online product selector on www st
26. nal clock is used OSCIN and OSCOUT can be used as general purpose VOs Figure 4 describes the external clock connections External clock e Frequency 0 kHz 16 MHz e Input hysteresis 100 mV Without prescaler a duty cycle of 45 55 maximum must be respected at high speed Doc ID 16139 Rev 1 ky AN3029 Clock management Crystal ceramic resonator Frequency range 1 to 16 MHz Stabilisation time Programable from 1 to 4096 cycles Oscillation mode Preferred fundamental Output duty cycle Max 55 45 I O s Standard I O pins multiplexed with OSCjy and OSCoyt Cload 10 to 20 pF Drive level maximum at least 100 pW Figure 4 HSE clock sources Hardware configuration STM8 OSCiN OSCour I O available External clock External source STM8 OSC iy OSCour Q1 i Cu Cle A Load capacitors E 1 The value of Rgxr depends on the crystal characteristics A 0 Q resistor works well with most oscillators but it is not optimal A typical value is in the range 5 to 6 Rs resonator series resistance To fine tune the Rgx value refer to AN2867 Oscillator design guide for sf microcontrollers Crystal ceramic resonators The values of the load capacitors C 4 and C are heavily dependent on the crystal type and frequency Refer to the datasheet of the crystal manufacturer to select the capacitances For best osci
27. ne help cg AA ey En HC RR EROR a BIR BC ACH RC RR dhon NR See REE 32 10 3 Running the demonstration software vveeeeeeeee eee 33 10 311 Compiling the project 0 0000 33 10 3 2 Selecting the correct debug instrument see ee ee einne 34 10 3 3 Connecting the hardware llle 35 10 3 4 Starting the debug session seseeeeee ee ee ee nee ee ee 37 10 35 Running the sofware useeeeeeeeeeee ee see ee 38 10 3 6 Follow up ee eg ac Rr mE ah aig aig S IA r vee ewe ea ah AC 39 ky Doc ID 16139 Rev 1 3 42 Contents AN3029 11 Documentation and online support eeeeeeeeeeeeeeeeeeene 40 12 REVISION history iuauaceaik ene hee os RCRCRCRCR CR ARE Al AA eee ee een eee es 41 4 42 Doc ID 16139 Rev 1 ky AN3029 List of tables List of tables Table 1 Component list 2 5 d dares faba a sis Nar ise inaa TEE RM E Rb buc ended nates 20 Table 2 SWIM connectorpins seeeeeeeeee ee ee ee ee tetas 23 Table 3 Document revision history 0 8 CRUA RC RC a GC teens 41 ky Doc ID 16139 Rev 1 5 42 List of figures AN3029 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 6 42 Power Supply c is cate
28. ng the SWIM interface cable The STM8L101 EVAL evaluation board is powered by an external 5 V supply see Figure 22 Figure 22 Connecting the debug instrument to the STM8L101 EVAL evaluation board W MN il V Doc ID 16139 Rev 1 35 42 AN3029 Setting up the STM8 development environment Figure 23 Connecting the debug instrument to the STM8L15x EVAL evaluation board STMELIS26 EVAL 3 Tct a pon On the Rlink adapter board for STM8 the SWIM jumper must be set If there is no pull up on the application SWIM line the ADAPT jumper is also set The PW 5V and 12MHz Caution jumpers must not be set Doc ID 16139 Rev 1 36 42 AN3029 Setting up the STM8 development environment 10 3 4 Starting the debug session Debug mode can be entered by the command Debug Start Debugging see Figure 24 Figure 24 STVD Starting the debug session was ST Visual Develop project stw main c l File Edit View Project Build Debug Debug instrument Tools Window Help lascia OMM Sam 05 cc ir i Il Workspace Ires project stw LosvRidPCPPAGCULITIRId dod dd d g9 project S Source Files i Poe FS D Pf This file contains the firm mono lcd c t STH week i hor STMicroelectronics Library i Bion VO 04 E main c E aa ana stm8 it c stp7 interrupt v Include Files Sq External Dependencie j 8 mods0 h
29. nput is bonded to Vppa in devices that have no external Vpgre pin packages with 32 pins or less Vnrr input analog reference negative The lower negative reference voltage is internally bonded to Vssa Analog input STM8L15x devices have up to 28 analog input channels including four fast channels each multiplexed with an I O which are converted by the ADC one at a time The analog input interface of the ADC is shown in Figure 3 The Rapc Capc and I real values are given in the chip datasheet The external input impedance Ran max value in order to achieve an error below 1 4 of LSB can be calculated with the formula Equation 1 Pain lt 2 nse NW Rape fcpu prescal x CroraL X In 2 Where fcpy is the CPU frequency Prescal is a programmable ADC clock prescaler with a value of 1 or 2 Usually fcpy prescal is between 0 320 MHz and 16 MHz Nsc is the programmable number of sampling cycles Usually the minimum number of cycles is four and the maximum is 384 Crora is the approximate sum of Cparasitic and Capc N is the resolution which is programable between 6 and 12 but is usually 12 Rapc is the sampling switch resistance which is usually around 1kQ Please refer to Figure 3 Doc ID 16139 Rev 1 ky AN3029 Analog to digital converter ADC Figure 3 Analog input interface STM8L15x Sample and hold ADC converter AINx 12 bit converter Please refer to the STM8L15x da
30. onics homepage see www st com Compiler STMBL devices can be programmed by a free assembler toolchain which is included in the ST toolset As the core is designed for optimized high level language support use of a C compiler is recommended C compilers for STM8 are offered by the third party companies Cosmic and Raisonance A free version of the C compiler with up to 16 Kbytes of generated code is available at www cosmic software com and www raisonance com Firmware library The STM8 firmware library is a complete set of source code examples for each STM8 peripheral It is written in strict ANSI C and it is fully MISRA C 2004 compliant All examples are delivered with three workspace and project definition files one for STVD and Cosmic C compiler one for STVD and raisonance Compiler and one for Raisonance integrated debugging environment and compiler This enables the user to load and compile them easily into their preferred development environment The examples run on the STMicroelectronics STM8L evaluation board and can be tailored easily to other types of hardware For additional information and download of the STMB8L firmware library connect to www st com mcu Doc ID 16139 Rev 1 ky AN3029 Setting up the STM8 development environment 10 10 1 Setting up the STM8 development environment The STM8 development environment setup looks different depending on the supplier of the software SW and hardware HW
31. s Cad guin ar ee eae Sr gra gh ae UCC ag ar aad aw aug ER aed are ale Re he 8 Typical layout of Vpp Vss pair ee IRI IIIA 9 Analog input interface 2l en 11 HSE clock sources llseseeseeseeeeeee ehh mrs 13 External CloCK i234 ose lose doma cebsue m eg Loewe dae ae aw dae Gad wx eee t 14 Crystal ceramic resonators llli 14 Reset management 0 00 cee lh hr 16 Output characteristics leslie 17 Input characteristics s sso ess ciem cuocere E ek RR RO ACE Re UR Rn Ar RR e i 17 Reference design sea ais aon a Ce CCR ag CA tarwiri CB AS GUR RR RA een 21 Debug system block diagram seveeeeeeee tees 22 Hardware connection RUA RCS AC GUR SL AC AR AC ii ACRA ett 23 Connection description llis 24 STice in emulation configuration liliis 25 In circuit programming and debugging l i 26 STM8B software toolchain ee 0 000 ee nee ee ee ee ee ee hh 27 STVD open example workspace eeeeeeee ee ee tetas 30 STVD MCU edit mode LL seeee ee ee ee tenes 31 STMa firmware library online help manual severe eeee ee ee nee ae 32 STVD Building the project severe eeee ee teas 33 STVD Selecting the debug instrument 00 000 cece ete eee 34 Connecting the debug instrument to the STM8L101 EVAL evaluation board 35 Connecting the debug instrument to the STM8L15x EVAL evaluation board 36 STVD Starting the debug sess
32. s Window Help space project stw project is Ey Source Files E mono Icd c E43 Library stm8 adc c L stm8 awu c tes io OoO 2o0O50mWMp stp7 interrupt vector c 5 Include Files E mono Icd h Library stm8 conf h B stm8 it h ii Gy External Dependencies E modso h RS Workspace sdue water E center amp c html Includes include stm8 lib h include mono lcd h define define define define define e amp Bm Bao jsje6os TATERTTSTAEREERTESATTRATERTATAERTATATATATTTATATAYTTAATTATATTAATTETATETAZTITATTAETTTTATRT4 WITH RESPECT T FTWARE AND OR THE U INTAINED HEREIN IN CONNECTION WITH THEIR PRO OPYRIGHT 2007 STMicroelectronics iefines i I s configuration LEDS PORT GPIOH LEDi PIN GPIO PIN 3 LED2 PIN GPIO PIN 2 LED3 PIN GPIO PIN 1 LED4 PIN GPIO PIN O Private function prototypes Jii mono lcd c Build Tools FindinFles 1 FindinFiles2 A Debug Console For Help press F1 In amp Cai8 MODIFIED READ CAP NUM SCRL OVF METRI TENE Doc ID 16139 Rev 1 31 42 Setting up the STM8 development environment AN3029 10 2 2 32 42 Online help An online help manual is available inside the firmware installation directory see Figure 19 to help the user understand the structure of the STM8 firmware library Figure 19 STM6 firmware library online help manual E HTML Help x IE
33. s have an internal regulator with a nominal target output of 1 8 V 8 42 Doc ID 16139 Rev 1 ky AN3029 Power supply 2 3 Power on power down reset POR PDR The input supply to the main and low power regulators is monitored by a power on power down reset circuit The monitoring voltage begins at 0 7 V During power on the POR PDR keeps the device under reset until the supply voltages Vpp and Vppio reach their specified working area This internal reset is maintained during 1ms in order to wait for supply stabilization At power on a defined reset should be maintained below 0 7 V The upper threshold for a reset release is defined in the electrical characteristics section of the product datasheets A hysteresis is implemented POR gt PDR to ensure clean detection of voltage rise and fall The POR PDR also generates a reset when the supply voltage drops below the Vpor ppr threshold isolated and repetitive events For better power monitoring the STM8L15x provides a programmable power voltage detection PVD and a brown out reset BOR for an earlier detection of voltage drop Recommendations All pins need to be properly connected to the power supplies These connections including pads tracks and vias should have the lowest possible impedance This is typically achieved with thick track widths and preferably dedicated power supply planes in multi layer printed circuit boards PCBs In addition each power supp
34. shaking strobe signals but not LED commands A surrounding Vss trace for such signals increases EMC performances as does a shorter length or absence of noisy and sensitive traces crosstalk effect For digital signals the best possible electrical margin must be reached for the two logical states Slow Schmitt triggers are recommended for eliminating parasitic states Unused I Os and features Microcontrollers are designed for a variety of applications where often a particular application does not use 100 of the microcontroller resources To avoid unnecessary power consumption especially important for battery powered applications and also to improve EMC performance unused clocks counters or I Os should not be left free I Os should be forced externally pull up or pull down to the unused I O pins and unused functions should be frozen or disabled Alternatively unused I Os can be programmed as push pull low to keep them at a defined level without using external components However in this case the I O is not driven during the power up phase until the I O is configured This can add a little extra power consumption and may be undesirable in very power sensitive applications User options STMBL devices have user option features that can be used for remapping or enabling disabling an automatic reset or low speed watchdog For more details please refer to the product datasheets Bootloader STM8L15x devices ha
35. tasheet and reference manual for more details ky Doc ID 16139 Rev 1 11 42 Clock management AN3029 4 4 1 4 2 4 3 4 8 1 Note Caution 12 42 Clock management The STM8L101 has no external clock so no precautionary measures are needed The following paragraph deals with STM8L15x chips only Clock management overview STM8L15x devices offer a flexible way of selecting the core and peripheral clocks ADC memory and digital peripherals The devices have internal and external clock source inputs both of which have a high speed and a low speed version Any of those four clocks can be use for the CPU and most of the peripherals through a programable prescaler An I O can be programmed as output clock CCO to reflect one of the four clocks with or without prescaling The signal which leaves the I O represents an output clock CCO divided by a division factor Internal clocks STMBL devices have two kinds of internal clock A high speed internal clock HSI running at 16 MHz and a low speed internal clock LSI running at 38 kHz After reset the CPU starts with the internal RC HSI clock signal divided by 8 i e 2 MHz External clock STMBL devices have two kinds of external clock A high speed external clock HSE running at up to 16 MHz and a low speed external clock LSE running at 32 768 kHz HSE clock STM8L15x devices can connect to an external crystal or an external oscillator When no exter
36. tial respectively as Vpp and Vss Refer to Section 3 Analog to digital converter ADC for more details The STM8L152 device manages the supply voltage needed by the LCD in three different ways see Figure 1 1 If the LCD feature is not used connect the VLCD pin to Vpp 2 Apply to VLCD the voltage to be applied to the LCD 3 Leave the STM8L 152 to provide the correct voltage via its programmable LCD booster by connecting the VLCD pin to a 1pF capacitor Doc ID 16139 Rev 1 7 42 Power supply AN3029 Figure 1 Power supply Only if internal boosteris usedto To power LCD power LCD specfi cally If LCD is unused For noisy environment For noisy environment VDDA TR VRef OSC IN NSS VDDIO OSC_OUT VDD 3 6 V 1 8 V 1 65 V see note 1 vssio OSC32_IN VSS VSSA V Ref OSC32 OUT Biggest package VSS 1 The device keeps operating as long as the battery voltage is above 1 65 V and no reset is generated Note The capacitors must be connected as close as possible to the device supplies Placing a crystal resonator on OSCIN OSCOUT is optional The resonator must be connected as close as possible to the OSCIN and OSCOUT pins The loading capacitance ground must be connected as close as possible to Vss 2 2 Main operating voltages STMBL devices are processed in 0 13 um technology The STM8L core and I O peripherals need different power supplies In fact STM8L device
37. ucture GPIO Pi main c 56 GPIO InitStructure GPIO Node GPIO MODE OUT PP LOU FA GPIO Init LEDS PORT amp GPIO 2 stm emae w Se 0x8908 lt main 4 gt Ox6802 LD 0xO2 SP A main c 57 GPIO InitStructure GPIO Pin LEDi PIN LED2 PIN L Ox890s lt main gt OxASOF LD A soxos Ox890e maine Ox 6001 up 0x02 5P A ef fy c l Wea d chess ADOS b 3tw EL 2823888839 idi gt Stocks pc TRIN wW sp 0x1753 x e300 v 0xB9Ce Accumulstor Condition Flag A o0 cc x a rear NF l N Nzrlt 38 42 Doc ID 16139 Rev 1 ky AN3029 Setting up the STM8 development environment The LCD display on the STM8 evaluation board indicates a successful debug session see Figure 26 Figure 26 STM8 evaluation board ky7 _ STMBL1526 EVAL z Y lt DI 5 10 3 6 Follow up Step by step additional peripherals of STM8L devices can be run following on from the initial debug session described above Many features of STM8L devices are supported by dedicated hardware on the STM8 evaluation board The necessary software drivers including STM8L peripheral drivers USART ADC SPI and drivers for the EVAL board modules LCD serial memory are delivered in the STM8L1x firmware library Doc ID 16139 Rev 1 39 42 Documentation and online support AN3029 11 40 42 Documentation and online support Documentation resources related to tool usa
38. ve a bootloader embedded in a ROM memory Through this firmware the device memory can be re programmed via the USART communication interface Doc ID 16139 Rev 1 19 42 Reference design AN3029 7 7 1 20 42 Reference design Component references Table 1 Component list ID Component name Reference Quantity Comments Refer to the pinouts and pin description I Meon jsw oio te Peay reac ton package 2 Battery 1 65 V to 3 6 V 1 Min 1 8 V for STM8L15x 3 Capacitor 1 uF n Decoupling capacitor 4 Capacitor 100 nF n Ceramic capacitor decoupling capacitor Components below are optional 6 Crystal 1to 16 MHz 1 7 Capacitor 20 to 40 pF 2 Used for crystal Crystal 32 kHz 1 8 Capacitor 5 to 20 pF 2 Used for crystal Ferrite bead Depends on noise to be filtered 9 SWIM connector 4 pins 1 Doc ID 16139 Rev 1 4 AN3029 Reference design 7 2 Schematics Figure 10 Reference design Only if internal booster isusedto To power LCD power LCD specfi cally If LCD is unused For noisy environment For noisy environment Only if accurate High Speed Oscillator is needed T VRef OSC_IN VSS VDDIO OSC_QUT 36V 48V a L6 vssio OSC32_IN VSS VSSA V Ref OSC32 OUT Biggest package vss Only if Accurate bw Seed Oscillator 6 needed 4 Doc ID 16139 Rev 1 21 42 STM8 development tools AN3029 8 8
Download Pdf Manuals
Related Search
Related Contents
M - Sanitätshaus Burbach + Goetz TESA-SCAN 50 CE Plus Benuzterhandbuch ログハウス調犬舎(小) 取扱説明書 2-1 a/d/s/ PQ40.2 Car Stereo System User Manual 取扱説明書と施工説明書をお渡しください。 NOTAS TÉCNICAS: INSTALACIÓN Copyright © All rights reserved.
Failed to retrieve file