ST AN3280 Application note

ST AN3280 Application note

AN3280

Application Note

Displaying variable voltage on a bar of LEDs using STM8S-DISCOVERY

Application overview

This application note provides a short description of how to use the ADC, Timer and GPIO peripherals.

Once the STM8S105C6T6 has been powered-up through a USB cable connected to the host PC, the Timer triggers the ADC according to a user-defined period to convert the analog voltage provided by variable resistor RV1. The resulting average voltage measurement is represented on the LED bar.

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 your STM8S-DISCOVERY application code user manual (UM0834).

October 2010

Doc ID 17983 Rev 1

1/13

www.st.com

Contents

AN3280

 

 

Contents

1

Application description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5

 

1.1

Hardware requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5

 

1.2

Application schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5

 

1.3

Application principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6

2

Software description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7

 

2.1

Application software flowcharts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

9

2.1.1 Main loop flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.1.2 ADC1 interrupt routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.1.3 TIM1 capture/compare interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3

Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

12

2/13

Doc ID 17983 Rev 1

AN3280

List of tables

 

 

List of tables

Table 1. Voltage and LED correspondence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Table 2. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Doc ID 17983 Rev 1

3/13

List of figures

AN3280

 

 

List of figures

Figure 1. Application schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Figure 2. ADC1 acquisition principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Figure 3. Main loop flowchart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Figure 4. ADC1 EOC interrupt flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Figure 5. TIM1 capture/compare flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

4/13

Doc ID 17983 Rev 1

Loading...
+ 9 hidden pages