Using the GPIOs and interrupt controller to drive LEDs on STM8 Nucleo-64 boards

Similar documents
AN5181. Building a thermometer using the STM8 Nucleo-64 boards. Application note. Introduction

AN3996 Application Note

AN5179. RS232 communications with a terminal using the STM8 Nucleo-64 boards. Application note. Introduction

AN3279 Application Note

P-NUCLEO-IKA02A1. STM32 Nucleo pack: electrochemical toxic gas sensor expansion board with CO sensor. Description. Features

P-NUCLEO-USB001. STM32 Nucleo pack for USB Type-C and Power Delivery. Features. Description

Bluetooth low energy profiles for the X-CUBE-BLE1 expansion for STM32Cube. Description

STSW-BLUENRG1-DK. BlueNRG-1, BlueNRG-2 DK SW package

AN3265 Application note

AN2667 Application note

NUCLEO-L496ZG. STM32 Nucleo-144 board. Features. Description

P-NUCLEO-USB001. STM32 Nucleo pack for USB Type-C and Power Delivery Data brief. Features. Description

NUCLEO-L433RC-P NUCLEO-L452RE-P

Getting started with the digital MEMS microphone expansion board based on MP34DT01-M for STM32 Nucleo

Getting started with MotionPM real-time pedometer library in X CUBE-MEMS1 expansion for STM32Cube

Getting started with the STM32 Nucleo pack for USB Type-C and Power Delivery with the Nucleo-F072RB board and the STUSB1602

USB Type-C and Power Delivery Nucleo pack with NUCLEO-F072RB expansion board based on the STUSB1602

USB Type-C and Power Delivery Nucleo pack with NUCLEO-F072RB expansion board based on STUSB1602. Description

UM2167 User manual. OrCAD PSpice model usage instructions

P-NUCLEO-6180X2. Proximity, gesture, ambient light sensor expansion board based on VL6180X for STM32L053R8. Description. Features

TN1235 Technical note

UM2051 User manual. Getting started with the STM32 Nucleo pack for USB Type-C and Power Delivery. Introduction

Getting started with X-NUCLEO-53L1A1 long distance ranging ToF sensor expansion board based on VL53L1X for STM32 Nucleo

Motor control power board based on the SLLIMM-nano 2 nd series

STSW-BNRG-Mesh. Mesh over Bluetooth low energy. Features. Description. Applications

AN3281 Application note

STSW-STWBCFWDT. STWBC firmware downloader tool. Description. Features

STSW-BNRGUI. BlueNRG GUI SW package. Data brief. Features. Description

ST25DV-DISCOVERY. Discovery kit for the ST25DV04K dynamic NFC/RFID tag. Features

AN2676 Application note

EVALKIT-VL6180X. VL6180X plug-in and STM32 F401RE Nucleo board explorer kit. Description. Features

Description. January 2019 DB2381 Rev 3 1/5

UM2255 User manual. SPC58NG-DISP user manual. Introduction

X-NUCLEO-53L0A1. Ranging and gesture detection sensor expansion board based on VL53L0X for STM32 Nucleo. Description. Features

X-NUCLEO-53L0A1 ranging and gesture detection sensor expansion board based on VL53L0X for STM32 Nucleo

How to upgrade the firmware on the STEVAL-USBC2DP USB Type-C to DisplayPort adapter

Sub-1 GHz RF expansion board based on the SPSGRF-868 module for STM32 Nucleo. Description

Getting started with MotionPM real-time pedometer library in X-CUBE-MEMS1 expansion for STM32Cube

AN4624 Application note

UM0792 User manual. Demonstration firmware for the DMX-512 communication protocol transmitter based on the STM32F103Zx.

STEVAL-IPMnM2N. Motor control power board based on the SLLIMM-nano 2 nd series. Description. Features. RoHS compliant

AN4311 Application note

STEVAL-SPBT4ATV3. USB dongle for the Bluetooth class 1 SPBT2632C1A.AT2 module. Features. Description

This manual provides information for the final user application developer on how to use SPC57S-Discovery microcontroller evaluation board.

AN4045 Application note

AN5224. STM32 DMAMUX: the DMA request router. Application note. Introduction

L9958 Evaluation board for high current (8.6A) DC and Stepper Motors. Description

STEVAL-CCM002V1. TFT-LCD panel demonstration board based on the STM32 as LCD controller. Features. Description

X-NUCLEO-53L1A1. Long distance ranging Time-of-Flight sensor expansion board based on VL53L1X for STM32 Nucleo. Description.

UM2350. Getting started with MotionPW real-time pedometer for wrist library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

ST Payment Secure Solution Java Card platform with up to 100 Kbytes of user NVM for AMEX payment applications

RN0084 Release note. ST-LINK/V2 firmware upgrade. About this release note

P-NUCLEO-53L1A1. VL53L1X nucleo pack with X-NUCLEO-53L1A1 expansion board and STM32F401RE nucleo board. Description. Features

Getting started with the X-CUBE-IKA02A1 multifunctional software expansion for STM32Cube

UM2495. High performance HF reader / NFC initiator IC software expansion for NUCLEO-8S208RB. User manual. Introduction

UM2216 User manual. Getting started with MotionFA fitness activity library in X CUBE MEMS1 expansion for STM32Cube. Introduction

Dynamic Electro-Thermal simulator for VIPower products. Description

Description. July 2016 DocID Rev 2 1/6

AN2672 Application note

UM2092 User manual. Basic metrology firmware for the STM32F103RD and the STPM32 devices. Introduction

UM2276. Getting started with MotionSD standing vs sitting desk detection library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

P-NUCLEO-53L0A1. VL53L0X Nucleo pack with ranging, gesture detection sensor expansion board and STM32F401RE. Description. Features

DT0095 Design tip. Datalogging the SensorTile through a PC. Purpose and benefits. Description

Getting started with X-CUBE-LED channel LED driver software expansion based on LED1642GW for STM32Cube

AN5123 Application note

32L476GDISCOVERY. Discovery kit with STM32L476VG MCU. Features. Description

UM0401 User manual. User manual for eight bit port expander STMPE801 demonstration board. Introduction

UM2361. Getting started with the ST BlueNRG-Mesh ios application. User manual. Introduction

AN4515 Application note

UM2194. Getting started with MotionAW activity recognition for wrist library in X-CUBE-MEMS1 expansion for STM32Cube. User manual.

UM1844 User manual. EVAL-L9958 Graphical user interface (GUI) Introduction

EVALKITSTKNX. Miniature transceiver STKNX evaluation and development kit. Features

UM1727 User manual. Getting started with STM32 Nucleo board software development tools. Introduction

EVLKSTCOMET10-1. STCOMET smart meter system-on-chip development kit. Features

Wi-Fi expansion board based on SPWF01SA module for STM32 Nucleo. Description

AN4782 Application note

Power line communication expansion board based on ST7580 for STM32 Nucleo. Description

SPC58EHx,SPC58NHx. A scalable approach for high-end body, networking and security platforms for Automotive. Description. Features

STM32SnippetsL0. STM32L0xx Snippets firmware package. Features. Description

Description SPC564A-DISP. March 2014 DocID Rev 3 1/5

Getting started with MotionAR activity recognition library in X-CUBE-MEMS1 expansion for STM32Cube

AN4491 Application note

Getting started with STEVAL-IDB007V1 and STEVAL-IDB008V1 evaluation boards

STOD32W. 100 ma triple DC-DC converter for powering AMOLED displays. Applications. Features. Description

UM0693 User manual. 1 Introduction. STM8L101-EVAL demonstration firmware

External memory code execution on STM32F7x0 Value line and STM32H750 Value line MCUs

Getting started with X-NUCLEO-IHM06A1 low voltage stepper motor driver expansion board based on STSPIN220 for STM32 Nucleo

AN4872 Application note

A scalable approach to your body, networking and security platforms. Description

Getting started with osxmotiongc gyroscope calibration library for X-CUBE-MEMS1 expansion for STM32Cube

ST Payment Secure Solution - Java Card platform with up to 90 Kbytes of user NVM for Visa, MasterCard, AMEX, Discover and Interac applications

AN4777 Application note

TN1234 Technical note

Running a simple 6LowPAN network consisting of one receiver node and one or more sensor nodes in a Sub-1GHz RF band

300 ma triple DC-DC converter for powering AMOLED displays. Description. Table 1: Device summary Negative voltage. Auxiliary positive voltage

Getting started with the FP-SNS-ALLMEMS1 Bluetooth low energy and sensors software expansion for STM32Cube

STEVAL-STLKT01V1. SensorTile development kit. Description. Features

UM1978 User manual. Multi-sensor RF platform sensor board. Introduction

STM32H7x3I-EVAL. Evaluation board with STM32H7x3XI MCUs. Data brief. Features

Getting started with MotionAR activity recognition library in X-CUBE-MEMS1 expansion for STM32Cube

Transcription:

Application note Using the GPIOs and interrupt controller to drive LEDs on STM8 Nucleo-64 boards Introduction The NUCLEO-8S208RB (built around the STM8S208RBT6 device) and the NUCLEO-8L152R8 (built around the STM8L152R8T6 device) are boards that allow the evaluation of the main features of all the STM8S Series and STM8L Series microcontrollers. This application note provides a short description on how to use the GPIOs and the interrupt controllers on the NUCLEO-8S208RB and on the NUCLEO-8L152R8 to drive a set of LEDs. Once the microcontroller (STM8S208RBT6 or STM8L152R8T6 in this example) has been powered-up through a USB cable connected to the host PC, the LD2 and LD5 LEDs (not on-board LEDs) start blinking. Each time that the "push" button is pressed, the interrupt controller assets an interrupt that is used to control the I/Os, and changes the LED behavior. Table 1. Applicable products Type Evaluation boards Part number NUCLEO-8S208RB NUCLEO-8L152R8 Reference documents STM8 Nucleo-64 boards data brief (DB3591) STM8L152R8T6 Nucleo-64 board user manual (UM2351) STM8S208RBT6 Nucleo-64 board user manual (UM2364) - Rev 1 - June 2018 For further information contact your local STMicroelectronics sales office. www.st.com

Application description 1 Application description This section describes the hardward requirements, the application's schematics and the application's principle to use the GPIOs and the interrupt controller to drive a set of LEDs on the NUCLEO-8S208RB or the NUCLEO-8L152R8 boards. 1.1 Hardware requirements No on-board resources are required other than the user push-button. The external components required by the application are listed on the table below. Table 2. External hardware components required External components Value Comments LD2, LD3, LD4, LD5 - Standards LEDs R2, R3, R4, R5 510 Ω Protective resistors 1.2 Application schematics The figure below shows how to interface the LEDs and the push button with the NUCLEO-8S208RB or the NUCLEO-8L152R8 boards. For details on NUCLEO-8S208RB or NUCLEO-8L152R8 boards implementation, refer to the board schematics provided in the corresponding user manual (UM2351 or UM2364). Protective resistors, R2, R3, R4, and R5, are mandatory to limit the current to a value that does not harm the LEDs. The push button requires a debounce filter (RC) and a pull-up resistor (R1) to avoid triggering several interrupts due to the mechanical bouncing of the button. Figure 1. STM8S Series application schematic V DD STM8S208RBT6 R1 PE4 C PB2 PB3 PB4 PB5 R User s push button R5 R4 R3 R2 LD5 LD4 LD3 LD2 - Rev 1 page 2/11

Application principle Figure 2. STM8L Series application schematic V DD STM8L152R8T6 R1 PG4 C PB4 PB6 PB7 PB5 R User s push button R5 R4 R3 R2 LD5 LD4 LD3 LD2 1.3 Application principle At startup, LD2 and LD5 start blinking meaning that the Flash memory of the STM8S208RBT6 or STM8L152R8T6 device has been successfully programmed. Pressing the push button generates an interrupt which is handled by the application software to drive the LEDs. Only one of the two pairs of LEDs, LD2/LD5 and LD3/LD4 blink at a time. A button event triggers the blinking of the other pair while switching off the first one. The LEDs blinking conditions are described in the table below. Table 3. LEDs configuration Application At startup On button event LED state LD2 and LD5 blink The blinking LED pairs are swapped - Rev 1 page 3/11

Software description 2 Software description The application software uses STM8S Series and STM8L Series standard firmware libraries to control the general purpose features described in the peripheral configuration section of this application note. 2.1 STM8S Series and STM8L Series peripherals configuration 2.1.1 GPIOs configuration The application drives the MCU I/Os to interface the microcontroller with external hardware components. The GPIO_Init() function configures the button (PE4 for STM8S208RBT6 or PG4 for STM8L152R8T6) as floating input with interrupt to detect push button events, and PB2/PB3/PB4/PB5 for STM8S Series or PB4/PB5/PB6/PB7 for STM8L Series as output push-pull to control the LEDs. 2.1.2 EXTI configuration The external interrupt controller is configured through the EXTI_SetExtIntSensitivity() function to handle the external interrupts on the push button (PE4 for STM8S208RBT6 or PG4 for STM8L152R8T6). The external interrupt sensitivity is configured to trigger an interrupt each time a falling edge, and only a falling edge, is detected on the push button (PE4 for STM8S208RBT6 or PG4 for STM8L152R8T6). 2.2 STM8 standard firmware library configuration 2.2.1 STM8S Series standard firmware library The stm8s_conf.h file of the STM8S Series 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 _EXTI 1 /* enables the EXTI */ 2.2.2 STM8L Series standard firmware library The stm8l15x_conf.h file of the STM8S Series 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: #include "stm8l15x_gpio.h" #include "stm8l15x_exti.h" 2.3 Application software flowcharts This section contains the main loop flowchart and the interrupt function flowchart. 2.3.1 Main loop flowchart The code main loop implements the algorithm that controls the LEDs according to push button events. The blinking LED pair is selected by setting the ButtonState flag. Each time the push button is pressed, an interrupt is triggered and ButtonState is complemented (see Section 2.3.2 Interrupt function flowchart. The main loop code tests ButtonState and selects the blinking LED pair according to its value (see Section 1.3 Application principle ). The Delay() function generates a delay between the LED on and off states so that we can see them blink. The figure below shows the flowchart of the application software main loop. - Rev 1 page 4/11

Application software flowcharts Figure 3. Main loop flowchart Start GPIO_configuration Configures PB2/PB3/PB4/PB5 for STM8 Series or PB4/PB5/PB6/PB7 for STM8L Series as output push-pull low to drive LD2, LD3, LD4 and LD5. Configures PE4 for STM8S Series and PG4 for STM8L Series as floating input with interrupts to handle the push button. EXTI_configuration Configures the external interrupt sensitivity to «falling edge only» on PE4 for STM8S Series and PG4 for STM8L Series. enableinterrupts() This function call enables all the STM8 interrupts. ButtonState =0? No Yes Select LEDs LD2, LD5 Select LEDs LD3, LD4 The selected LED pair starts blinking until the button is pressed again. Switch LEDs on Delay() Switch LEDs off 2.3.2 Interrupt function flowchart Each time an interrupt is asserted, a sepcific function complements the ButtonState flag and the main loop behaves accordingly (see Section 1.3 Application principle ). This function is: EXTI_PORTE_IRQhandler() for STM8S Series EXTI_PORTG_IRQhandler() for STM8L Series The figures below shows the flowchart of the EXTI_PORTE_IRQhandler() and the EXTI_PORTG_IRQhandler() interrupt function. - Rev 1 page 5/11

Application software flowcharts Figure 4. EXTI_PORTE_IRQhandler() function flowchart for STM8S Series GPIO port E interrupt ButtonState flag complemented Back to main() Figure 5. EXTI_PORTG_IRQhandler() function flowchart for STM8L Series GPIO port G interrupt ButtonState flag complemented Back to main() - Rev 1 page 6/11

Revision history Date Version Changes 29-Jun-2018 1 Initial release. Table 4. Document revision history - Rev 1 page 7/11

Contents Contents 1 Application description...2 1.1 Hardware requirements...2 1.2 Application schematics...2 1.3 Application principle...3 2 Software description...4 2.1 STM8S Series and STM8L Series peripherals configuration...4 2.1.1 GPIOs configuration...4 2.1.2 EXTI configuration...4 2.2 STM8 standard firmware library configuration...4 2.2.1 STM8S Series standard firmware library...4 2.2.2 STM8L Series standard firmware library...4 2.3 Application software flowcharts...4 2.3.1 Main loop flowchart...4 2.3.2 Interrupt function flowchart...5 Revision history...7 - Rev 1 page 8/11

List of tables List of tables Table 1. Applicable products...1 Table 2. External hardware components required...2 Table 3. LEDs configuration....3 Table 4. Document revision history...7 - Rev 1 page 9/11

List of figures List of figures Figure 1. STM8S Series application schematic....2 Figure 2. STM8L Series application schematic...3 Figure 3. Main loop flowchart...5 Figure 4. EXTI_PORTE_IRQhandler() function flowchart for STM8S Series... 6 Figure 5. EXTI_PORTG_IRQhandler() function flowchart for STM8L Series... 6 - Rev 1 page 10/11

IMPORTANT NOTICE PLEASE READ CAREFULLY STMicroelectronics NV and its subsidiaries ( ST ) reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST products are sold pursuant to ST s terms and conditions of sale in place at the time of order acknowledgement. Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of Purchasers products. No license, express or implied, to any intellectual property right is granted by ST herein. Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product. ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners. Information in this document supersedes and replaces information previously supplied in any prior versions of this document. 2018 STMicroelectronics All rights reserved - Rev 1 page 11/11