AN3266
Application note
Using the STM8S-DISCOVERY GPIOs and
interrupt controller to drive LEDs
Application overview
This application is based on the STM8S-DISCOVERY. It demonstrates how to use the STM8S GPIOs and interrupt controller to drive a set of LEDs.
Once the STM8S105C6T6 is powered up through an USB cable connected to the host PC, LEDS LD2 and LD5 start blinking meaning that the programming operation has completed successfully.
Each time the pushbutton is pressed, the interrupt controller asserts an interrupt that is used to control the I/Os, and change the LED behavior.
Reference documents
■STM8S-DISCOVERY evaluation board user manual (UM0817).
■Developing and debugging your STM8S-DISCOVERY application code user manual (UM0834).
November 2010 |
Doc ID 17876 Rev 1 |
1/11 |
www.st.com
Contents |
AN3266 |
|
|
Contents
1 |
Application description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
5 |
|
|
1.1 |
Hardware requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
5 |
|
1.2 |
Application schematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
5 |
|
1.3 |
Application principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
6 |
2 |
Software description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
7 |
|
|
2.1 |
STM8S peripheral configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
7 |
2.1.1 GPIOs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.2 EXTI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Standard STM8S standard firmware library configuration . . . . . . . . . . . . . 7 2.3 Application software flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3.1 Main loop flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.3.2 Interrupt function flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3 |
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
10 |
2/11 |
Doc ID 17876 Rev 1 |
AN3266 |
List of tables |
|
|
List of tables
Table 1. List of external components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Table 2. LEDs configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Table 3. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Doc ID 17876 Rev 1 |
3/11 |
List of figures |
AN3266 |
|
|
List of figures
Figure 1. Application schematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Figure 2. Main loop flowchart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Figure 3. EXTI_PORTB_IRQhandler() function flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4/11 |
Doc ID 17876 Rev 1 |