Home
Getting started with the STM8S
Contents
1. Table 2 SWIM connector pins Pin number Pin name Pin 1 Vpp Pin 2 SWIM pin Pin 3 Vss Pin 4 Reset 22 42 ky AN2752 STM8 development tools 8 1 3 Hardware connection Figure 14 Hardware connection AD ICC SWIM adapter Application board SWIM connector Vpp 4 1X Voo 2 2 STM8 3 3 4 4 SWIM cable Caution Itis recommended to place the SWIM header as close as possible to the STM8S device as this minimizes any possible signal degradation caused by long PCB tracks 8 2 Emulator STice 8 2 1 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 STMB8 for more details Figure 15 Connection description Emulation system Connection flex Connection adapter Adapter socket 23 42 STM8 development tools AN2752 8 2 2 24 42 Emulation system STice e Emulator box e Cables for USB power supply trigger 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 STM8S microcontroller Adapter socket e Package speci
2. v AN2752 Y7 Application note Getting started with the STM8S Introduction This application note complements the information in the STM8S datasheets by describing the minimum hardware and software environment required to build an application around an STMB8S 8 bit microcontroller device It is divided into the following sections m Power supply Analog to digital converter ADC Clock management Reset control and development Debugging tool support STMB8 software toolchain Setting up the STM8 development environment This application note also contains detailed reference design schematics with descriptions of the main components In addition some hardware recommendations are given September 2008 Rev 2 1 42 www st com Contents AN2752 Contents 1 Hardware requirements summary eese 6 2 PoOWer SUDDIV s x eaux EUR OROROR Parse RR Ec uU bed eeaewa ages 7 2 1 Power supply overview llsssseeeeeelee nne 7 2 2 Main operating voltages llleeseell nl 8 2 3 Power on power down reset POR PDR ssslss erlernen 8 3 Analog to digital converter ADC slleesss 10 3 1 Analog power i cicotcigcewe NEUES dae nee mas Osta eae ea RE dd qa 10 3 2 Analog Input sues iv ieeehiees cease Sia RARE RE X AXE RGAG ERE SE 10 4 Clock management eeeeeeeee eene 12 4 1 Clock management overview 000 0c eee eee 12 4 2 Internal ClOCK bres cpu
3. e STM8 CPU programming manual PM0044 Tools e STM8 firmware library and release note detailed descriptions of the library are included as help files STice advanced emulation system for ST microcontrollers data briefing STice user manual Cosmic C compiler user manual STM8 128 EVAL evaluation board user manual UM0482 ST visual develop tutorial included as help files in the ST toolchain ST visual develop STVD user manual 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 AN2752 Revision history 12 Revision history Table 3 Document revision history Date Revision Changes 03 Jun 2008 1 Initial release STM8S207 208 replaced by STM8S20xxx Figure 11 Reference design on page 20 and Figure 12 LQFP 80 01 Sep 2008 2 pin pinout on page 21 modified to be in line with the pin description of the STM8S20xxx datasheet Figure 7 Reset management on page 14 modified ky 41 42 AN2752 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 corre
4. 16 MHz and a low speed internal clock LSI running at 128 kHz After reset the CPU starts with the internal RC HSI clock signal divided by 8 i e 2 MHz External clock STMB8S devices can connect to an external crystal or an external oscillator When no external clock is used OSCIN and OSCOUT can be used as general purpose IOs Figure 6 describes the external clock connections AN2752 Clock management Figure 6 Clock sources Hardware configuration STM8 OSC OSCour E o 9 2 t I O available c E g External source Frequency 32 kHz 24 MHz Comparator hysteresis 0 1 Vpp Caution Without prescaler a duty cycle of maximum 45 55 6 must be respected STM8 OSCN OSCour LI NE il L Cu Ci Ra Load capacitors A Frequency range 1 24 MHz Wake up time lt 2 ms 24 MHz Oscillation mode Preferred fundamental Output duty cycle Max 55 45 l O s Standard I O pins multiplexed with OSC and OSCoyt Cload 10 20 pF Maximum crystal power 100 pW Crystal ceramic resonators The values of the load capacitors C 4 and C are heavily dependent on the crystal type and frequency The user can refer to the datasheet of the crystal manufacturer to select the capacitances For best oscillation stability Cj 4 and C normally have the same value Typical values are in the range from below 20 pF up to 40 pF cload 1
5. nominal target output of 1 8 V Stabilization for the main regulator is achieved using an external capacitor via the VcAp pin The typical value is 470 nF with low equivalent series resistance ESR Care should be taken to limit the series inductance per pad to less than 15 nH Figure 2 External capacitor ESR C ESL ooo e Rleak Where ESR is the equivalent series resistance ESL is the equivalent inductance The typical value of C is 470 nF with an ESR between 0 05 0 2 Ohm 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 range is 0 7 V to 2 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 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 datasheet 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 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
6. zZ 2 2 uo d hog r uoO2 z mir E XY SW 5 X x ee z aan 23g z z5t88329 Suse ERRSECAE 09 ESSLLLL geez Ga8BaBRBaBBrel i u unoooosx qQdadadadagadadnada aaraa 3QO O 0 r QD 10 sr CO N O O ORK OD 10 st NNT 0o P P PR P Po PoP P P P O XO KO QO CO KO QO CO YO NRSTO 1 60 PIS OSCIN PA10 2 59 Q PI2 OSCOUT PA2LI 3 58 CIPI Vssio 1l 4 57 OPIO Vssl 5 56 D PG4 VCAPLI 6 55 PG3 Vppll 7 54 1 PG2 Vppio 1l 8 53 LIPG1 CAN RX TIM3 CH1 TIM2 CH3 PA3LI 9 52 1 PGO CAN_TX UART1_RX PA4L 10 51 PC7 SPI_MISO UART1 TX PASLI 11 50 PC6 SPI MOSI m ER SSIO 2 HS PH1LI 14 47 PC5 SPI SCK PH2L 15 46 LIPC4 HS TIM1_CH4 PH3LI 16 45 1 PC3 HS TIM1_CH3 AIN15 PF7L 17 44 PC2 HS TIM1 CH2 AIN14 PF60 18 43 LIPC1 HS TIM1 CH1 AIN13 PF5L 19 42 PCO ADC ETR AIN12 PFALI 20 41 PE5 SPI NSS T CN CO st 10 XO P O0 O Q v Q CO st 10 K O P 0D OO CN OU QUI OV QU QU ON CN C0 cO CO CO C C CO CO C2 t C j O l CQ 10 st C QN r O st 10 CO F P OO ra 5889 uL m con c m cn cn m cn T T LT I Lu Lu Q m r0 0 Q Q Q Q Q 0 Q A n gt O xondzogd comgjzzzeoo z zL22222222rpw w 22 zzxzzzzubib5xx JTZZz 9 tr bp ao pE9ONT Z Oo Og clIIrir FZZ oo 999 FFE NNS rE HS High sink capability mE 222 CEBE 1 HS high sink capability 2 alternate function remapping option If the same alternate function is shown twice it indicates an exclusive choice not a duplication of the function 4 21
7. 0x02 SP B stma usart Initialize SPI for LCD main c 57 GPIO_InitStructure GPIO Pin LED1 PIN LED2 PIN LI 151 stmB veda Ox890a lt main 6 gt DxASOF LD A 0x0f 0x890c lt main 8 gt Ox6BO1 LD 0x01 SP A s id WS Workspace mono Icd c mono gt Program Counter Stacks Index registers PC SLEEN sP Ox17f3 x 0x100 y x89cc Accumulator j Condition Flags A 0x00 Cc jOx2a iA HMI N ivzT Concurrent IT Nested IT Core Registers 38 42 Ti AN2752 Setting up the STM8 development environment The LCD display on the STM8 evaluation board indicates a successful debug session see Figure 28 Figure 28 STM8 evaluation board MN y wil DU una F Cum MEMINI 10 3 6 Follow up Step by step additional peripherals of STM8S devices can be run following on from the initial debug session described above Many features of STM8S devices are supported by dedicated hardware on the STM8 evaluation board The necessary software drivers CAN driver LIN driver buttons memory cards buzzer etc are delivered in the STM8 firmware library ky 39 42 Documentation and online support AN2752 11 40 42 Documentation and online support Documentation resources related to tool usage includes Application e STM8S20xxx datasheet e STMB8 Flash programming manual PMOO051 e STMS8S Family reference manual RM0016
8. 22 Table 3 Document revision history lt gt ciisresirssrrirsaikoerd rietara trenera rradisa 41 4 42 ky AN2752 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 Power supply deett bake Sea depu aed cea ed acre EU aed ory abe E ax 7 External capacitor asiste d bea ae dores a eR heals a eure E ew NR URN S Ren 8 Typical layout of Vpp Vss Pair IRI III 9 Analog input interface llle m n 10 System clock distribution internal clock 00 0c eee 12 Clock sources vard dumin a gee piri TE E een hr 13 Reset management 0 00 cece tee nr 14 Output characteristics 0 teeta 15 Input characteristics 2 2 00 eee 15 esee CIT 16 Reference design 000 cece teens 20 LQFP 80 pin pinout 0 2 0 eee 21 Debug system block diagram 1 0 ce tenes 22 Hardware connection 0 000 cece te tees 23 Connection description llis 23 STice in emulation configuration 0 00 ccc ee 25 In circuit programming and debugging 0 eee ee 26 STM8 software toolchain unaua 0 00 teen ae 27 STM8 firmware library examples 0000 cece etna 29 STVD ope
9. Gc GN TIG e s cH 8 ang RR sen T s Further interrupts are masked by hardy s Mh Jes axl case RED nextState GREEN break case OFF Binterrupt nostack void trapISR nextState OFF et break color nextState default nextState7currentState 1 break J ext state and update rra vat if scate nextState stateOccurence lt MAX case RED j t jnevr amp rearenGDPFN currentState nextState state currentState stateOccurence WATCHDOG SOFTWARE WDG_HALT RESET gt Run Application stopped Breakpoint 1 trapISR at timer c 69 27 42 STM8 software toolchain AN2752 9 1 9 2 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 e
10. 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 2008 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 Singapore Spain Sweden Switzerland United Kingdom United States of America www st com q 42 42
11. PDZ TL CTIA cha PH7 TIM1 CHIN 8 VDDIO 1 Plo yop E VDDIO 2 PH VDD PI2 2 VODA PI3 vss PIA 4 VSSA PIS a VSSIO 1 Pl6 VSSIO 2 PI7 ur a o6 w A P o o oanu a a Ceo ME PT s ITI can a MCU Decoupling Capacitor alternate function remapping option If the same alternate function is shown twice it indicates an exclusive choice not a duplication of the function Jo 69 fon 67 eo A 40 S 26 25 PF1 22 PF2 jS DAF Uu N Uu Bw un o o R1 R2 VDD 2 ai15471B 20 42 1 2 Vpp must be within the allowed supply voltage range of the STM8S microcontroller If pins 22 or 25 are required as GPIO R1 and R2 should be removed AN2752 Reference design 7 3 Pinouts STMBS devices have several package types including the LQFP 80 pin pinout shown in Figure 12 Please refer to the STM8S20xxx datasheet for more details Figure 12 LQFP 80 pin pinout Q o 9 x pr 9 To
12. fact that the supply loop acts as an antenna 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 pF pool capacitor Supplementary 100 nF capacitors must be placed as close as possible to the Vss Vpp pins of the micro in order 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 2 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 17 42 Recommendations AN2752 6 5 6 6 6 7 18 42 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 In addition to e Signals for which a temporary disturbance permanently affects operation of the ap
13. hens chan ER RARE te ebew ek yea Pd REESE 12 4 3 External ClOCK 22 i ic2icieg butte e p erisque Ped qe RE pei dE 12 5 Reset control 5a a y dcc caca a do a d Ra CC ORE a e C 14 5 1 Reset management overview lllleeeess 14 5 2 Hardware reset implantation llle 15 5 2 1 ROCCU ni ran gaa gebe be dba ta etd Boe Soe ee Ss 16 6 Recommendations seeeeeeeeeeeeeee 17 6 1 Printed circuit board aecuckeeemuecetRPURTAT T EReRE Eri noA ki PPAR AE 17 6 2 Component position naasa aaaea 17 6 3 Ground and power supply Vss Vpp sseee tee 17 6 4 Decolpling 45x ek y hex RRROR OE TR CAR o bed e cmm Eb ewe 17 6 5 Other SIQNAIS cia deed erar Rp dre ER RUN R Fer re gre ides aic 18 6 6 Unused I Os and features 0 00 e eee 18 6 7 User opti nS c PP eta tneean sagen RIPE 18 7 Reference design issus d wx da ARR eee dee ee OR ORE RR n 19 7 1 Components reference 00 c eee eren 19 7 2 Schematics s cccasneigesgedadeunace cee eens REA S teagan awe Kae 20 2 42 Ti AN2752 Contents 7 8 diner c T A ee ee ee ete ete 21 8 STM8 development tools 00 0c cece ee ee eee 22 8 1 Single wire interface module SWIM 0000 c eee eee 22 8 1 1 SWIM overview 0000 eee 22 8 1 2 SWIM connector pins 0 000 22 8 1 3 Hardware connection 0 000 eee eee 23 8 2 Emulator STice cou a ox eas Rene qoos kee eee bandi pes RC E RUD ee i GU 23 8 2 1 STice ove
14. mono ldc mono lcd h 4 37 42 Setting up the STM8 development environment AN2752 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 27 Figure 27 STVD Run the software x STMBAF51xx STM SWIM project stw Debug project elf main c DEE File Edit View Project Build Debug Debug instrument Tools Window Help j9 IE o PPARROD 3 snag etum m incti project stw Alt Num l6 nCount project r tOo A 3 Source Files 2 80 E mono_ted c Chip Reset Ctrl shift F5 neoun ioc X q B S ub l hnt 0 ttre eis E Library Restart 0000 0 Dc b so oor q y c N m 1 z2Rh 3008 2 Ctrl F5 stm exti c P Step Into Fil stm flash TR step over F10 stm8 gpio c m stm8 i2c c Step Into ASM AlteF11 i5 stmB itc c O Step Over ASM At F10 fypeDet GPIO Ini stm8_iwdg P Step Out are PeDet SPI miea 6 45 stm amp linuarl 4 Run to Cursor Ctrl F10 0x8902 lt Delay 10 gt 0x85 POPU X stmB rst c 0x8903 lt Delay 11 gt 0x81 RET stm8 spic amp Set pC 35g it main c 47 void main void stm8 timi c T 56 Ox8904 main Ox520A SUBY SP 0x0a pier ibd GPIO InitStructure GPIO Pi main c 56 GPIO InitStructure GPIO Mode GPIO MODE OUT PP LOW Fa m GPIO Init LEDS PORT amp GPIO stm amp tim4 c m Dx8908 lt main 4 gt Ox6B02 LD
15. project stw Open Files of type Project Workspace stw X Cancel a T T ei Build Tools Find in Files 1 FindinFiles 2 Debug A Console For Help press F1 Ln Cel MODIFIED READ CAP NUM SCRL OVA METTRE GES 7 31 42 Setting up the STM8 development environment AN2752 10 2 1 All project source files are visible and can be edited see Figure 21 Project editing Figure 21 STVD MCU edit mode 2 ST Visual Develop project stw main c C5 File Edit View Project Build Debug Debug instrument Tools Window Help at figs project stw gi E project Source Files E mono_led c E 3 Library E stm8 adc c L stm8 awu c Bfile main c Bbrief Th Q oUn5oNH OFTWARE WHICH IS FOR GUIDANCE NG INFORMATION REGARDING THEIR PRODUCT R LT MI ELECTRONI DIRECT INDIRECT OR JUENTIAL D s FROM THE CONTENT OF H FTWARE AND OR THE U CODING INFORMATION AINED COPYRIGHT 200 Includes include stm8_lib h include mono lcd h onfiguration GPIOH GPIO PIN 3 GPIO PIN 2 GPIO PIN 1 GPIO PIN O define LEDS PORT define LED1 PIN define LED2 PIN define LED3 PIN define LED4 PIN yj Include Files B mono Icd h E Library 8 stm8 conf h B stm8 it h External Dependencies E modso h Private function prototypes lii ee sm mee j sjleos t STMicroelectronics TATARTSUSSTAEESTERSAETAITETAESTARAAT4 A X
16. 0 20 pF The parasitic capacitance of the board layout also needs to be considered and typically adds a few pF to the component values 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 4 13 42 Reset control AN2752 5 5 1 14 42 Reset control Reset management overview The reset cell is a dedicated 5 V bidirectional I O Its output buffer driving capability is fixed to lolyiN 2 mA 0 4 V in the 3 V to 5 5 V range which includes a 40 k pull up Output buffer is reduced to the n channel MOSFET NMOS If a 40 k pull up is accepted this cell does not include an output buffer of 5 V capability The receiver includes a glitch filter whereas the output buffer includes a 20 us delay There are many reset sources including External reset through the NRST pin 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 the BOR starts to function Independent watchdog reset IWDG Window watchdog reset WWDG Software reset The application software can trigger reset SWIM reset An external device connected to the SWIM interface can request the SWIM block to generate a microcont
17. 42 STM8 development tools AN2752 8 STM8 development tools Development tools for STM8S microcontrollers include the STice emulation system supported by a complete software tool package including C compiler assembler and integrated development environment with high level language debugger 8 1 Single wire interface module SWIM 8 1 1 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 13 Debug system block diagram 100 kHz Osc v Peripheral SWIM entry DBG bo Comm cmp 9 DM STM8 RAM layer decode vere NVM Internal RC 8 1 2 SWIM connector pins The SWIM connector pins consist of 4 pins as described in Table 2
18. AGO RA OA ROUEN ER nn file contains the firmware main function YORK Y Y Ya e n IN ORDER FOR THEM T HALL NOT BE HELD LIABLE FOR ANY HEREIN IN CONNECTION WITH THEIR PRO center gt lt h2 gt MODIFIED READ CAP NUM SERE OVF MEM T 32 42 AN2752 Setting up the STM8 development environment 10 2 2 Online help An online help manual is available inside the firmware installation directory see Figure 22 to help the user understand the structure of the STM8 firmware library Figure 22 STM8 firmware library online help manual 0 HTML Help gm s gt 0 A amp e _ Hide Locate Back onward Stop Refresh Home Pint Options Contents Ind ch Favorit z J E ides Search Favorites Main Page Modules Data Structures Files Directories E STM Firmware Library cS Modules E decia STM8 Firmware Library and Examples E Data Fields a File List E Directories li a On line Help Manual STMicroelectronics ky 33 42 Setting up the STM8 development environment AN2752 10 3 10 3 1 34 42 Running the demonstration software 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 23 Figur
19. ctions 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 BY AN AUTHORIZED ST REPRESENTATIVE ST PRODUCTS ARE NOT RECOMMENDED AUTHORIZED
20. d 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 25 42 STM8 development tools AN2752 26 42 Figure 17 In circuit programming and debugging N ICD ICP flat cable connects STice to microcontroller via ICD ICP connector on application board SWIM connector linked to microcontroller 3 ST microcontroller on application board gt q AN2752 STM8 software toolchain 9 STMS software toolchain In order to write compile and run the first software on an STM8S device the following components of the software toolchain are required see Figure 18 e Integrated development environment e Compiler e Firmware library optional used to ease the start up Figure 18 STM8 software toolchain Le SV Oe 7 ei ER i BE a oa cat ree
21. e 23 STVD Building the project 1 ST Visual Develop project stw main c C5 File Edit View Project Build Debug Debug instrument Tools Window amp zx ul e Compile main c Ctrl F D E Workspace E Build zi Rebuild All e eines Batch Build ZIID project ag Source Files Clean i h Include Files pr External Depen C Bu Configurations 7 VES y dat 8 tttttt 9 1n THE AN2752 Setting up the STM8 development environment 10 3 2 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 24 Figure 24 STVD Selecting the debug instrument Debug Instrument Settings Target Debug Instrument Selection Select the Target you want es to use for debug session m Target Part Selection Select the connection port for usb dfusb the Target selected above Add Remove Show the selected target notification at start of debugging session Cancel Apply 35 42 Setting up the STM8 development environment AN2752 10 3 3 Connecting the hardware 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 connecti
22. fic socket for connection adapter and STM8S microcontroller 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 com AN2752 STM8 development tools Figure 16 STice in emulation configuration Free ST STM8 toolset STVD and STVP running on your PCdrive STice LM _ STice SYSxxx Includes all emulation resources MEB TEB and PEB if l p CF FPxxx Connection flex to connect to application board d i 2 P a P d M Oy 2 m wA Ad c Ww ae 3 LO AS xxxx Adapter socket on application WY y e Pd board to plug in emulator in place of ADixxxx Connection microcontroller il adapter to link connection P cable to microcontroller KRZY 8 2 3 In circuit programming an
23. l pulse of at least 30 ns is guaranteed Figure 9 Input characteristics A 27 5 ns 27 5 ns 450 ns I Ed p Pad 75 ns 75 ns 75 ns A EY gt 30 ns Negative train of glitch filtered Reset requested P Systemreset 5 2 Hardware reset implantation There are several reset implementation schemes to choose from such as power supply behavior based on the specific parameters of the application Whatever the solution chosen the idea is to keep the RESET pin at a low logic level until the supply has reached a safe operating voltage Therefore the external circuit should be designed in such a manner that there is enough delay to keep the RESET pin below the V value 15 42 Reset control AN2752 5 2 1 16 42 RC circuit The RC circuit concept is the simplest and most cost effective external reset solution where the supply waveform is monotonous and the maximum rise time is known The principle is to let the RESET pin rise with the microcontroller supply voltage after a delay The circuit is shown in Figure 10 The basic solution is to use an RC delay determined by the rise rate of the supply itself The component values must be chosen to create enough delay to keep the RESET pin below the Vi specification until Vcc reaches a safe operating voltage Normally a delay time constant corresponding to at least 30 of the total rise time is advised Figure 10 RC circuit VDD IO STM8 nes p Rp
24. ll the tools in the following order 1 C compiler 2 ST toolset 3 STMS firmware library The Rlink does not need any dedicated software installation in the STM8 development environment because the necessary drivers are delivered with the ST toolset These R link drivers must be launched separately as follows Start Programs STtoolset Setup Install Rlink driver AN2752 Setting up the STM8 development environment 10 2 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 recommended to open an existing project from the STM8 firmware library The STM8 firmware library includes several examples for each peripheral plus one workspace containing a project which is already configured for the dot matrix display of the STM8 evaluation board It is located in the firmware subdirectory Project Cosmic see Figure 20 Figure 20 STVD open example workspace 1 ST7 Visual Develop File Edit view Project Build Debug Debuginstrument Tools Window Help jas sjaja REJ Jeetmm msmjossm gmg js Workspace ies Mo Workspace Open Workspace Look in 3 15TMB8 Firmware Library Project Cosmic 4 mi EJ Debug E Workspace release project stw File name
25. n example workspace 0000 cette 31 STVD MCU edit mode traati uaa ae a a EE ah aaa E Ea tenes 32 STM8 firmware library online help manual sseelel eee 33 STVD Building the project 20 0 RI ee 34 STVD Selecting the debug instrument 0 0000 eee 35 Connecting the debug instrument to the STM8 evaluation board 05 36 STVD Starting the debug session 0 0000 eect eae 37 STVD Run the software hh 38 STM8 evaluation board 00 0 lh 39 5 42 Hardware requirements summary AN2752 1 6 42 Hardware requirements summary In order to build an application around an STM8S device the application board should at least provide the following features Power supply Clock management Reset management Debugging tool support Single wire interface module SWIM connector AN2752 Power supply 2 2 1 Note Note Power supply Power supply overview The device can be supplied through a 3 0 V to 5 5 V external source An on chip power management system provides the 1 8 V digital supply to the core logic both in normal and low power modes It is also capable of detecting voltage drops on both main external 3 3 V 5 V and internal 1 8 V supplies The device provides e One pair of pads Vpp Vss 3 3 V x 0 3 V to 5 V 0 5 V dedicated to the main regulator ballast transistor supply e Two pairs of pads dedicated for Vpp jo Vss j
26. nd STice emulator To program applications to an STMB8S 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 STMicroelectronics homepage see www st com Compiler STM8S 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 AN2752 STMB software toolchain 9 3 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 see Figure 19 All examples are delivered with workspace and project definition files for STVD and Cosmic C compiler which enables the user to load and compile them easily into the development environment The examples run on the STMicroelectronics STM8 evaluation board and can be tailored easily to other types of hardware For additional information on the STM8 firmware librar
27. o 3 3 V 0 3 V to 5 V 0 5 V which are used to power only the I O s On 32 pin packages only one pair is bonded For Vppid Vssio Next to Vpp Vss it is recommended to connect these two pairs together and to use only one decoupling capacitance The purpose is to ensure good noise immunity by reducing the connection length between both supplies and also between Vpp Vpp o and the capacitor e One pair of pads VppA VssA 3 3 V 0 3 V to 5 V 0 5 V dedicated to analog functions Refer to Section 3 Analog to digital converter ADC on page 10 for more details Figure 1 Power supply Analog signal Analog functions Vssa V CAP Vpp VDDIO1 Main Low power E S Vss Vs io1 regulator Logic Vppi02 V lOs B 3102 l Vopio Vssio OSCIN Vooo Vssio L l XTAL 9 Star connected OSCOUT ai15330 3 3V 5V NZ The capacitors must be connected as close as possible to the device supplies especially Vpp in case of dedicated ground plane 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 Vas 7 42 Power supply AN2752 2 2 2 3 8 42 Main operating voltages STM8S devices are processed in 0 13 um technology The STM8S core and I O peripherals need different power supplies In fact STM8S devices have an internal regulator with a
28. on to the STM8 evaluation board is made by the SWIM interface cable The STM8 evaluation board is powered by an external 5 V supply see Figure 25 Figure 25 Connecting the debug instrument to the STM8 evaluation board STM8 128 EVAL Caution On the Rlink ICC SWIM adapter board the SWIM jumper must be set If there is no pull up on the application SWIM line the ADAPT jumper is also set In any case PW 5V and 12MHz jumpers must not be set 36 42 r AN2752 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 26 Figure 26 STVD Starting the debug session 1 ST Visual Develop project stw main c S File Edit view Project Build Debug Debug instrument Tools Window Help asdue OMME AGI 05557 Workspace If project stw gt ee aces ENN One eur project z t P main c J Source Files B g A mong Icd e Pf This file contains the firn e Library hor STMicroelectronics A main c Bion VO 04 stm8 it c P amp stp interrupt v h Include Files z External Dependencie 3 PRESENT SOFTWARE WHICH IS FOR 1 mods0 h 12 DING INFORMATION REGARDING B 2 o CROELECTROK b AS A RESULT STMIC CT INDIRECT OR CONSEQUENTIAL THE CONTENT OF SUCH SOFTWARE NG INFORMATION CONTAINED HEREI COPYRIGHT 2007 fS Workspace main c
29. plication for example interrupts and handshaking strobe signals but not LED commands A surrounding Vgs 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 2 logical states Slow Schmitt triggers are recommended for eliminating parasitic states Unused l Os and features Microcontrollers are designed for a variety of applications where often a particular application does not use 100 96 of the microcontroller resources To increase EMC performance unused clocks counters or I Os should not be left free for example I Os should be set to 0 or 1 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 in order to keep them at a defined level but not to use external components User options STMB8S 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 datasheet AN2752 Reference design 7 7 1 Reference design Components reference Table 1 Component list ID Component name Reference Quantity Comments Refer to the Pinouts and pin description I mmr mes 1 ant Fas
30. roller reset Illegal opcode reset If a code to be executed does not correspond to any opcode or prebyte value a reset is generated Electromagnetic susceptibility EMS reset Generated if critical registers are corrupted or badly loaded Figure 7 Reset management STM8 Simplified functional I O reset schematic lt Filter se NRST Do System reset Illegal op code reset Pulse generator I IWDG WWDG seftware reset min 20 us SWIM reset EMS reset Delay POR BOR reset External reset v AN2752 Reset control Output characteristics e A valid pulse on the pin is guaranteed with a 20 ns pulse duration on the internal output buffer e Aftera 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 220ns gt A A lq 20 us pulse stretch min gt Pad Reset requested Input characteristics e All pulses with a duration less than 75 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 75 ns is always filtered when a 7 5 ns interval between spikes occurs ratio 1 10 e All pulses with duration more than 450 ns are recognized as valid pulses e Aftera valid pulse is recognized an interna
31. rview 0 0 rns 23 8 2 2 STice in emulation configuration llle 24 8 2 3 In circuit programming and debugging sels 25 9 STM8 software toolchain eeeeeeeeeeese 27 9 1 Integrated development environment llls eee eee eee 28 9 2 Sui diane aea n e E EEE E I E E REE 28 9 3 Firmware library use PEE SUE TERR ERRENDESEPepERY CEST PS RI EE 29 10 Setting up the STM8 development environment 30 10 1 Installing the tools 22a 3a RTERAERPERSERPEER RECEN SER PER ODEESE UE 30 10 2 Using the tools oss aana es EaSEE ERI IRURE RULES e E asas 31 10 2 1 Projectediting 0 0 cee eee 32 10 22 Onlinehelp 0 0 33 10 3 Running the demonstration software 0 0 00 eee 34 10 3 1 Compiling the project 0 34 10 3 2 Selecting the correct debug instrument 2000000s 35 10 3 8 Connecting the hardware liliis eese 36 10 3 4 Starting the debug session iiilillillells leise 37 10 3 5 Running the software 0 0 ees 38 10 3 6 FollOWUP wc ccc n RR ERR ae eee da eee Ron Rom ee hi 39 11 Documentation and online support 2 000 ee eee eens 40 12 Revision history iussus RR eae ee al ee DR me eo 41 ky 3 42 List of tables AN2752 List of tables Table 1 Component list 2 5 dares piura re beri Era TEE RM P Rb bec p RUD nae s 19 Table 2 SWIM connector pins 1 2 0 aaaea
32. tage chart tne the right package 2 Push button 1 1 3 Resistor 10 kOhm 1 4 Capacitor 100 nF 5 Ceramic capacitor decoupling capacitor 5 Capacitor 1 uF 1 Decoupling capacitor 6 Capacitor 470 nF 1 Main regulator stabilization 7 Capacitor 20 40 pF 2 Used for crystal 8 Crystal 1 24 MHz 1 9 SWIM connector 4 pins 1 19 42 Reference design AN2752 7 2 Figure 11 Schematics Reference design Ul STM8 Package LQFP 80 pin gt NRST PEO CLK CCO PAI OSCIN PE1 I2C_SCL PA2 OSCOUT PE2 12C SDA PA3 TIM2 CH3 TIM3 CH1 PE3 TIM1_BKIN PA4 UART1_RX PEA PAS UART1_TX PES SP _NSS PAG UARTI CK PE7 AIN8 VCAP PE6 AIN9 2g ZO pR eee gt PBO AINO TIM1_CHINI PFO AIN10 Clock HSE n Bd PBI AINTITIMT CH2N PFI VREF BM PB2 AIN2 TIM1_CH3N PF2 VREF 3i PBS AINSITIMI ETR PF3 AIN11 yr PBA AINA I2C SCL PFA AIN12 2 PBS AINSIIZC SDA PF5 AIN13 e PBG AING PF6 AIN14 27 PB7 AIN7 PF7 AIN15 PCO ADC_ETR PGO CAN_TX B PCTM CHI PG1 CAN_RX Hey PC2 TIMI_ CH2 PG2 2 PC3 TIM1_CH3 PG3 e PCATIMI CHA PG4 dM PCS SPI_SCK PGS 21 PC6 SPI_MOSI PG6 i 3 pCz sPI MISO PG7 3 J4 Z PDO TIM3 CH2 TIM1 BKINJICLK CCO PHO 2 EM i PDUSWM PHI 1 d PD2 TIM3_CH1 TIM2_CH3 PH2 SW M Eerdector PD3 TIM2_CH2 ADC_ETR PH3 Ze PDA TIM2 CHIIBEEPI PHA TI M1 ETR Debug Vno J PDS UART3 TX PH5 TIM1 CH3N Zor PD6 UART3 RX PH6 TIM1_CH2N yop 3 E
33. typically achieved with thick track widths and preferably dedicated power supply planes in multi layer printed circuit boards PCBs In addition each power supply pair should be decoupled with filtering ceramic capacitors C at 100 nF with one chemical C 1 2 uF in parallel on the STM8S 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 3 shows the typical layout of such a Vpp Vss pair AN2752 Power supply Figure 3 Typical layout of Vpp Vss pair STM8 ky 9 42 Analog to digital converter ADC AN2752 3 3 1 3 2 10 42 Analog to digital converter ADC Analog power The ADC unit has an independent analog supply reference voltage isolated on input pin VppA Which allows the ADC to accept a very clean voltage source This analog voltage supply range is the same as the digital voltage supply range on pin Vpp An isolated analog supply ground connection on pin VssA provides further ADC supply isolation Together the analog supply voltage and analog supply ground connection offer a separate external analog reference voltage input for the ADC unit on the Vper pin This gives better accuracy on low voltage input as follows Vpgrr input analog reference positive The higher positive reference
34. u NRSTIN gt gt Push button of C1__ 100nF Oo The RC circuit scheme requires a certain delay between a power down and the next power up because the delay generator has to be reinitialized In practice a pull down capacitor between RESET and Vgg needs to be discharged AN2752 Recommendations 6 6 1 6 2 6 3 6 4 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 which results in a good decoupling as well as a good shielding effect For many applications economical requirements 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 in order to reduce cross coupling on the PCB i e 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
35. voltage for the ADC should be between 250 mV VppA For more details about Vggpe values please refer to the STM8S20xxx datasheet This input is bonded to Vpp in devices that have no external Vper pin packages with 48 pins or less Vner input analog reference negative The lower negative reference voltage for the ADC should be higher than VssA For more details about Vref values please refer to the STM8S20xxx datasheet This input is bonded to Vgga in devices that have no external Vngr pin packages with 48 pins or less Analog input STM8S20xxx devices have 16 analog input channels which are converted by the ADC one at a time and each multiplexed with an I O The analog input interface of the ADC is shown in Figure 4 Figure 4 Analog input interface amp Outside ADC nside ADC Vin SWsamp Rexr a LL Cex CsAMP VIN_EXT AN2752 Analog to digital converter ADC Equation 1 Cyin Cgamp Cext where Cv is the total equivalent capacitor on the path of Vin Cgamp is the equivalent sampling capacitance Cexrt is the total external capacitance on the path of Viy to the macro pin This includes parasitic routing capacitance pad and pin capacitance and external capacitance To ensure proper and accurate sampling the following equation must be satisfied Equation 2 3 Rew Rext X Cgamp Cext lt 35 x Ts where e Rs
36. w 30 kOhm Rexr is the total external resistance on the path of Viy Csayp 3 PF Ts 0 5 us for 2 MHz input CLK Equation 2 is specific for Rext and Cgxr when designing an analog input interface for the ADC Please refer to the STM8S20xxx datasheet and or the corresponding family reference manual RM0016 for more details 11 42 Clock management AN2752 4 4 1 4 2 4 3 Note 12 42 Clock management Clock management overview STM8S20xxx devices offer a flexible way of selecting the core and peripheral clocks ADC memory digital peripherals The devices have internal and external clock source inputs and one output clock CCO Figure 5 System clock distribution internal clock 1 OSC er eec SUE T x 1to 24 MHz CCO pin crystal V and external gt ciu clock pea ock uni 0 0 19 External clock OSCout 16 MHz 128 kHz internal Re 9 Prescaler WDG AWU Timer Internal clock Clock distribution E E ee uenis dmm dmi uei meme emm dmm 4 For more details please refer to the section on clock management in the datasheet Internal clock The RC oscillator has an internal capacitor C and an internal resistor ladder R STM8S devices have two kinds of internal clock a high speed internal clock HSI running at
37. y please contact STMicroelectronics Figure 19 STM8 firmware library examples U STM8520x Firmware Library and Examples Usage B Known Bugs and Limitations B Peripheral drivers footprint ADC Examples 2 AWU Examples 1 x BEEP Examples 1 CLK Examples 4 x EXT Examples 1 FLASH Examples 4 GPIO Examples 2 e I2C Examples 5 e ITC Examples 1 e IWDG Examples 1 x LINUART Examples 4 e RST Examples 2 e SPI Examples 3 x TIMER1 Examples 5 x TIMER2 Examples 5 x TIMER3 Examples 5 x TIMER4 Examples 1 USART Examples 3 wwDG Examples 1 e Madules e Data Structures Data Fields File List e Directories Globals 29 42 Setting up the STM8 development environment AN2752 10 10 1 Note 30 42 Setting up the STM8 development environment The STM8 development environment setup looks different depending on the supplier of the software SW and hardware HW 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 e HW debug interface Rlink from Raisonance e STMS evaluation board from STMicroelectronics Installing the tools All software tools are delivered with a setup wizard which guides the user through the installation process It is recommended to insta
Download Pdf Manuals
Related Search
Related Contents
SM2M Users Manual MANUAL DE SEGURANÇA BIOLÓGICA EM LABORATÓRIO user manual 使用上の注意はカタログー取扱説明書をお読みください。 ※施工上の注意と EDP-X500 Whirlpool CHE-12RC User's Manual Severin FR 2431 Fellowes Mars A3 Copyright © All rights reserved.
Failed to retrieve file