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

Similar documents
AN3332 Application note

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

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

AN2979 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

AN279 Application note

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

D44H8 - D44H11 D45H8 - D45H11

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

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

Obsolete Product(s) - Obsolete Product(s)

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

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

AN3134 Application note

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

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

AN1441 Application note

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

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

BD533 BD535 BD537 BD534 BD536

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

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

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

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

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

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

AN2333 Application note

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

2STD1360 2STF1360-2STN1360

Obsolete Product(s) - Obsolete Product(s)

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

AN1756 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

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

AN4112 Application note

Obsolete Product(s) - Obsolete Product(s)

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

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

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

AN2581 Application note

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

Obsolete Product(s) - Obsolete Product(s)

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

Obsolete Product(s) - Obsolete Product(s)

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

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

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

Obsolete Product(s) - Obsolete Product(s)

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

AN2837 Application note

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

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

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

STN2580. High voltage fast switching NPN 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

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

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

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

KF25B, KF33B KF50B, KF80B

CPL-WB-02D3. Wide-band, directional coupler with integrated 50 ohm loaded isolated port. Features. Applications. Description.

Obsolete Product(s) - Obsolete Product(s)

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

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

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

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

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

AN1229 Application note

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

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

STPSC V power Schottky silicon carbide diode. Features. Description

Obsolete Product(s) - Obsolete Product(s)

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

AN2167 Application note

LM723CN. High precision voltage regulator. Features. Description

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

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

Obsolete Product(s) - Obsolete Product(s)

MJD122 MJD127 Complementary power Darlington transistors Features Applications Description

AN4233 Application note

BDX53B - BDX53C BDX54B - BDX54C

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

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

AN440 Application note

AN3218 Application note

AN3116 Application note

AN3252 Application note

EMIF03-SIM05F3. EMI filter with SWP protection for SIM interface. Features. Application. Description. Complies with the following standards:

DCPL-WB-02D3. Wide-band, dual-path directional coupler with integrated 50 ohm loaded isolated port. Features. Applications. Description.

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

Order codes Marking Package Packaging

ST1510FX. High voltage fast-switching NPN Power transistor. General features. Applications. Internal schematic diagram. Description.

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

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

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

Gate. Order codes Package Packaging

Transcription:

Application Note Adjustable LED blinking frequency using a potentiometer and STM8SVLDISCOVERY Application overview Note: This document introduces a very simple application example which is ideal for beginners to learn about the STM8SVLDISCOVERY and its programming environment. This application adjusts the blinking frequency of a string of 4 LEDs using a potentiometer. The ADC measures the analog voltage present at the potentiometer bridge, and the blinking frequency of the LEDs is adjusted accordingly. This application automatically starts as soon as the STM8SVLDISCOVERY is powered-up through a standard USB cable connected to the host PC, and the LEDs start blinking at a speed dependant on the potentiometer position. Additional hardware is required to run this application. Built around the STM8S003K3T6, the STM8SVLDISCOVERY allows evaluation of the main features of all the STM8S Value line MCUs. Reference documents STM8SVLDISCOVERY user manual (UM1482) STM8SVLDISCOVERY getting started (UM1480) Developing and debugging your STM8S application code user manual (UM0834) STM8S003 datasheet STM8S reference manual (RM0016) November 2011 Doc ID 022506 Rev 1 1/10 www.st.com

Contents AN4014 Contents 1 Application description...................................... 5 1.1 Hardware required........................................... 5 1.2 Application schematics........................................ 5 1.3 Application principle.......................................... 6 2 Software description......................................... 7 2.1 Touch sensing library configuration.............................. 7 2.2 Standard STM8S standard firmware library configuration............. 8 2.3 Application software flowcharts................................. 9 2.3.1 Main loop flowchart......................................... 9 2.3.2 ExtraCode_StateMachine flowchart........................... 10 3 Revision history........................................... 12 2/10 Doc ID 022506 Rev 1

List of figures List of figures Figure 1. Application schematics..................................................... 5 Figure 2. Main application loop flowchar............................................... 9 Figure 3. ExtraCode_StateMachine flowchart.......................................... 11 Doc ID 022506 Rev 1 3/10

List of tables AN4014 List of tables Table 1. LED LD1 configuration..................................................... 6 Table 2. Touch Sensing library configuration........................................... 7 Table 3. Document revision history................................................. 12 4/10 Doc ID 022506 Rev 1

Application description 1 Application description 1.1 Hardware required No STM8SVLDISCOVERY on-board resources are used. Additional hardware is required to make this application software run on the STM8SVLDISCOVERY: A potentiometer: 10 K 4 LEDs (LD2, LD3, LD4, LD5) 4 resistors (510 ohms) 1.2 Application schematics Refer to UM1482 STM8SVLDISCOVERY for implementation details. 1.3 Application principle This application uses the ADC (Analog-to-Digital Converter) to convert the analog output voltage delivered by the potentiometer (0V to VDD) into a 10-bit digital value in the range of 0x0 to 0x3FF. The application switches the 4 LEDs on and off sequentially in a circular way, making use of this digital value to adjust the time during which each LED is left switched on before switching it off and driving the next one. Doc ID 022506 Rev 1 5/10

Application description AN4014 As a consequence, the blinking frequency of the LED string is controlled by the potentiometer: the higher the resistance selected by the potentiometer, the higher the voltage output of the potentiometer wiper, the higher the 10-bit digital value converted by ADC, the lower the blinking frequency of the LED string. The 10-bit ADC conversion result which is used to modulate the LEDs temporization has been scaled to get a sufficiently long delay so that the blinking can be seen distinctly whatever the position selected by the potentiometer. Table 1. LED string blinking speed parameters Vpot (volts) ADC value Vdd=5 V Vdd=3 V Cycle (4 LEDs) period 0 0 0 68 ms 2.5 1.5 511 952 ms 5 3 1023 1800 ms 6/10 Doc ID 022506 Rev 1

Getting started 2 Getting started This application automatically starts as soon as the STM8SVLDISCOVERY is powered-up through a standard USB cable connected to the host PC. The LEDs start blinking at a speed dependant on the potentiometer position. 2.1 Updating firmware Before running this application, the STM8S program memory must be updated with the firmware associated to this application note. Read STM8SVLDISCOVERY getting started (UM1480) to see how to proceed. 2.2 Hardware settings The power supply is provided by the USB connector and controlled by JP1 (5 V or regulated 3.3 V). In this application example you can use either source, the only impact is a variation in LED luminosity. For details about STM8SVLDISCOVERY refer to UM1482 STM8SVLDISCOVERY. Doc ID 022506 Rev 1 7/10

Software description AN4014 3 Software description The application software does not use the STM8S standard firmware library to control general purpose functions, but directly programs peripheral registers. The peripherals used are the following: Clock (CLK) The clock control enables and delivers the correct clock frequency to the CPU and peripherals. At power-on, the master clock source is automatically selected as HSI clock with prescaler division factor equal to 8. Here we change the division factor to 0. So, f MASTER = 16 MHz GPIOs The GPIOs drive the MCU I/Os to interface with external hardware. They configure port PB3, PB4, PB5 and PB6 as output push-pull low to drive the LEDs LD2, LD3, LD4 and LD5. Other ports are configured by default input floating. ADC The 10-bit Analog-to-Digital Converter is used to convert the analog voltage delivered from the potentiometer. It is configured as: Single conversion mode Channel 2 (AIN2) f ADC = f MASTER /8 => f ADC =2 MHz Right alignment results A simple software loop implements the delays that control the LEDs switch-on time. Use of a timer configured as a time-base generator allows better control of the delay accuracy. See STM8S standard library for examples of a time-base generator. 8/10 Doc ID 022506 Rev 1

Revision history 4 Revision history Table 2. Document revision history Date Revision Changes 25-Nov-2011 1 Initial release. Doc ID 022506 Rev 1 9/10

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 TWO 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 10/10 Doc ID 022506 Rev 1