AN3332 Application note

Similar documents
AN4014 Application Note Adjustable LED blinking frequency using a potentiometer and STM8SVLDISCOVERY Application overview

STEVAL-ISQ010V1. High-side current-sense amplifier demonstration board based on the TSC102. Features. Description

AN2581 Application note

EVAL-RHF310V1. EVAL-RHF310V1 evaluation board. Features. Description

AN279 Application note

BD235 BD237. Low voltage NPN power transistors. Features. Applications. Description. Low saturation voltage NPN transistors

STEVAL-CCA040V1. 4X10 Watt dual/quad power amplifier demonstration board based on the STA540SAN. Features. Description

D44H8 - D44H11 D45H8 - D45H11

UM0791 User manual. Demonstration firmware for the DMX-512 communication protocol receiver based on the STM32F103Zx. Introduction

R 1 typ. = 15 kω. Order codes Marking Polarity Package Packaging. 2N6036 2N6036 NPN SOT-32 Tube 2N6039 2N6039 PNP SOT-32 Tube

Order codes Marking Polarity Package Packaging. MJD44H11T4 MJD44H11 NPN DPAK Tape and reel MJD45H11T4 MJD45H11 PNP DPAK Tape and reel

BUX87. High voltage NPN power transistor. Features. Applications. Description

MJE182 Low voltage high speed switching NPN transistor Features Applications Description High speed switching NPN device

ST26025A. PNP power Darlington transistor. Features. Applications. Description

STEVAL-ISA005V1. 1.8W buck topology power supply evaluation board with VIPer12AS. Features. Description. ST Components

AN2333 Application note

R 1 typ. = 15 kω. Order codes Marking Polarity Package Packaging. STX112-AP X112 NPN TO92-AP Ammopack STX117-AP X117 PNP TO92-AP Ammopack

Obsolete Product(s) - Obsolete Product(s)

BD241A BD241C. NPN power transistors. Features. Applications. Description. NPN transistors. Audio, general purpose switching and amplifier transistors

BD533 BD535 BD537 BD534 BD536

Obsolete Product(s) - Obsolete Product(s)

Order codes Marking Package Packaging. STX0560 X0560 TO-92 Bag STX0560-AP X0560 TO-92AP Ammopack. December 2010 Doc ID Rev 1 1/9

2STA1695. High power PNP epitaxial planar bipolar transistor. Features. Applications. Description

BD243C BD244C. Complementary power transistors. Features. Applications. Description. Complementary NPN-PNP devices. Power linear and switching TO-220

3STL2540. Low voltage high performance PNP power transistor. Features. Applications. Description

TIP2955 TIP3055. Complementary power transistors. Features. Applications. Description

UM0890 User manual. 2-stage RF power amplifier with LPF based on the PD85006L-E and STAP85050 RF power transistors. Introduction

2N2219AHR. Hi-Rel NPN bipolar transistor 40 V A. Features. Description

2STD1665. Low voltage fast-switching NPN power transistor. Features. Applications. Description

AN2979 Application note

STEVAL-CCA011V1. Filter-free stereo 2x2.5 W Class-D audio power amplifier demonstration board based on the TS2012FC. Features.

SPV1001T40. Cool bypass switch for photovoltaic application. Features. Application. Description TO-220

STN9260. High voltage fast-switching PNP power transistor. Features. Applications. Description. High voltage capability Fast switching speed

2STR SOT-23 Tape and reel 2STR1230G 130G SOT-23 Tape and reel

Obsolete Product(s) - Obsolete Product(s)

2STC4468. High power NPN epitaxial planar bipolar transistor. Features. Application. Description

AN3134 Application note

ST13003D-K High voltage fast-switching NPN power transistor Features Applications Description

STN High voltage fast-switching PNP power transistor. Features. Application. Description. High voltage capability Very high switching speed

STB High voltage fast-switching NPN power transistor. Features. Applications. Description

MD2310FX. High voltage NPN power transistor for standard definition CRT display. Features. Application. Description

AN1441 Application note

STD840DN40. Dual NPN high voltage transistors in a single package. Features. Applications. Description

Obsolete Product(s) - Obsolete Product(s)

2STC4468. High power NPN epitaxial planar bipolar transistor. Features. Application. Description

Obsolete Product(s) - Obsolete Product(s)

2STR2215. Low voltage fast-switching PNP power transistor. Features. Applications. Description

2STD1360 2STF1360-2STN1360

Part numbers Order codes Packages Temperature range. LM137 LM137K TO-3-55 C to 150 C LM337 LM337K TO-3 0 C to 125 C LM337 LM337SP TO C to 125 C

LET9060C. RF power transistor from the LdmoST family of n-channel enhancement-mode lateral MOSFETs. Features. Description

Obsolete Product(s) - Obsolete Product(s)

LM323. Three-terminal 3 A adjustable voltage regulators. Features. Description

AN2837 Application note

MD2009DFX. High voltage NPN power transistor for CRT TV. Features. Application. Description

BUL38D. High voltage fast-switching NPN power transistor. Features. Applications. Description

KF25B, KF33B KF50B, KF80B

BDX53B - BDX53C BDX54B - BDX54C

2STA1943. High power PNP epitaxial planar bipolar transistor. Features. Application. Description

BUL39D. High voltage fast-switching NPN power transistor. Features. Application. Description

STD1802T4-A. Low voltage fast-switching NPN power transistor. Features. Description. Applications

2ST2121. High power PNP epitaxial planar bipolar transistor. Features. Applications. Description 1 2 TO-3

1. Drain 2. Gate. Order code Marking Package Packaging. STAC4932F STAC4932F STAC244F Plastic tray. September 2010 Doc ID Rev 3 1/12

TR136. High voltage fast-switching NPN power transistor. Features. Applications. Description

LM723CN. High precision voltage regulator. Features. Description

STN2580. High voltage fast switching NPN power transistor. Features. Applications. Description. High voltage capability Fast switching speed

STN9360. High voltage fast-switching PNP power transistor. Features. Applications. Description. High voltage capability Fast switching speed

Order codes Marking Package Packaging 2STF SOT-89 2STN2550 N2550 SOT-223. November 2008 Rev 1 1/8

BUL743. High voltage fast-switching NPN power transistor. Features. Applications. Description

AN4112 Application note

AN1756 Application note

2STN2540. Low voltage fast-switching PNP power bipolar transistor. Features. Applications. Description

MJD122 MJD127 Complementary power Darlington transistors Features Applications Description

ESDALCL6-4P6A. Multi-line low capacitance and low leakage current ESD protection. Features. Applications. Description

Obsolete Product(s) - Obsolete Product(s)

Obsolete Product(s) - Obsolete Product(s)

2STC5242. High power NPN epitaxial planar bipolar transistor. Features. Application. Description

STPS140Z-Y. Automotive power Schottky rectifier. Features. Description

STC04IE170HV. Monolithic emitter switched bipolar transistor ESBT 1700 V - 4 A Ω. Features. Application. Description

Part Number Marking Package Packing. MD1802FX MD1802FX ISOWATT218FX Tube. August 2006 Rev 1 1/8

Obsolete Product(s) - Obsolete Product(s) Obsolete Product(s) - Obsolete Product(s)

AN4379 Application note

STPSC V power Schottky silicon carbide diode. Features. Description

MD1802FX. High voltage NPN power transistor for standard definition CRT display. Features. Applications. Description

PD54003L-E. RF power transistor, LdmoST plastic family N-channel enhancement-mode, lateral MOSFETs. Features. Description

Obsolete Product(s) - Obsolete Product(s)

2STX2220. High Gain Low Voltage PNP Power Transistor. General features. Description. Internal schematic diagram. Applications.

STX13005G-AP. High voltage fast-switching NPN power transistor. Features. Applications. Description

Order codes Marking Package Packaging

SD1728 (TH430) RF & Microwave transistors HF SSB application. Features. Description. Pin connection

STL128D. High voltage fast-switching NPN power transistor. Features. Applications. Description

Order code Temperature range Package Packaging Marking

Order codes Marking Package Packaging. STD2805T4 D2805 DPAK Tape & reel STD D2805 IPAK Tube. June 2007 Rev 1 1/9

STTH1210-Y. Automotive ultrafast recovery - high voltage diode. Features. Description

Gate. Order codes Package Packaging

AN3218 Application note

Order codes Packages Lead finish Marking Type EPPL Packaging. 2N5153SHR SMD.5 Gold ESCC Flight Yes Strip pack

Obsolete Product(s) - Obsolete Product(s)

Low noise low drop voltage regulator with shutdown function. Part numbers

High voltage NPN Power transistor for standard definition CRT display. R BE =60Ω typ. Order code Marking Package Packing

Obsolete Product(s) - Obsolete Product(s)

Transcription:

Application note Generating PWM signals using STM8S-DISCOVERY Application overview This application user manual provides a short description of how to use the Timer 2 peripheral (TIM2) to generate three PWM signals. Even though the STM8S-DISCOVERY is built around an STM8S105C6T6, it allows evaluation of the main features of all the STM8S MCUs. Reference documents STM8S-DISCOVERY evaluation board user manual (UM0817). Developing and debugging STM8S-DISCOVERY application user manual (UM0834). January 2011 Doc ID 18399 Rev 1 1/7 www.st.com

Application description AN3332 1 Application description 1.1 Hardware requirement No additional hardware is required on the STM8S-DISCOVERY board. An oscilloscope is needed as an external resource. 1.2 Application schematics Figure 1. Application schematics 1.3 Application principle This application is based on the use of the STM8S TIM2 in PWM (pulse width modulation) mode to generate 3 PWM signals. The generation process is presented in Figure 2. 2/7 Doc ID 18399 Rev 1

Application description Figure 2. PWM generation principle Note: Table 1. TIM2 counts up from 0 to the Auto-reload register value (TIM2_ARR) according to the TIM2 counter clock. When the counter value equals the Compare/Capture register (TIM2_CCRxx) value channel x signal is set to 0. When the counter value reaches the TIM2_ARR value the counter is reset and channel x signal is set to 1. By configuring the TIM2_CCRxx and TIM2_ARR registers you can easily modify the duty cycle and frequency of the PWM signals generated (see Section 2: Software description). By default the application provides the 3 PWM signals as specified in Table 1. It is possible to configure the AFR option byte to get channel 3 on PD2 also. Default PWM signals Signal Duty cycle Frequency I/O pin Header connector Channel 1 PWM 50% 2 KHz PD4 CN4.9 Channel 2 PWM 25% 2 KHz PD3 CN4.8 Channel 3 PWM 75% 2 KHz PA3 CN1.9 Doc ID 18399 Rev 1 3/7

Software description AN3332 2 Software description This example uses the STM8S standard firmware library to control the general purpose functions. To generate the PWM signals the TIM2 peripheral must be configured as follows: Output state enabled for each channel Output compare active low for each channel Preload register enabled for each channel PWM output signal frequency = 2 KHz: The timer source clock frequency is 2 MHz (f CPU by default) and the prescaler is set to 1 to obtain a TIM2 counter clock of 2 MHz. PWM output signal frequency can be set according to the following equation: PWM output signal frequency = TIM2 counter clock/(tim2_arr + 1) (in our case TIM2_ARR = 999, so PWM output signal frequency is 2 KHz) PWM mode for each channel. To obtain a different PWM duty cycle value on each channel the TIM2_CCRxx register must be set according to this equation: Channel x duty cycle = [TIM2_CCRxx/(TIM2_ARR + 1)] * 100 By default we have: Channel 1: TIM2_CCR1x register value is 500, so channel 1 of TIM2 generates a PWM signal with a frequency of 2 KHz and a duty cycle of 50%. Channel 2: TIM2_CCR2x register value is 750, so channel 2 of TIM2 generates a PWM signal with a frequency of 2 KHz and a duty cycle of 75%. Channel 3: TIM2_CCR3x register value is 250, so channel 3 of TIM2 generates a PWM signal with a frequency of 2 KHz and a duty cycle of 25%. 2.1 STM8S standard firmware library configuration The stm8s_conf.h file of the STM8S standard firmware library is used to configure the library by enabling the peripheral functions used by the application. The following define statements must be present: #define _GPIO 1 enables the GPIOs #define _TIM2 1 enables the TIM2 4/7 Doc ID 18399 Rev 1

Software description 2.2 Application software flowcharts 2.2.1 Main loop flowchart Figure 3. Main loop flowchart Doc ID 18399 Rev 1 5/7

Revision history AN3332 3 Revision history Table 2. Document revision history Date Revision Changes 15-Jan-2011 1 Initial release. This document replaces UM0856. 6/7 Doc ID 18399 Rev 1

Please Read Carefully: Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries ( ST ) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice. All ST products are sold pursuant to ST s terms and 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 OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY, DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK. Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any liability of ST. ST and the ST logo are trademarks or registered trademarks of ST in various countries. Information in this document supersedes and replaces all information previously supplied. The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners. 2011 STMicroelectronics - All rights reserved STMicroelectronics group of companies Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan - Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America www.st.com Doc ID 18399 Rev 1 7/7