UM0784 User manual STM8L1526-EVAL demonstration firmware 1 Introduction This document describes the demonstration firmware running on the STM8L1526-EVAL evaluation board. You can use it to evaluate the capabilities of the microcontroller and the on-board peripherals. The evaluation board is delivered with the demonstration firmware stored in the Flash program memory of the microcontroller. The firmware is based on the STM8L15x firmware library, and provides an example of how to use this library. It is divided into various smaller demonstration applications (demos). In case the STM8L1526-EVAL evaluation board is not factory-programmed or the demonstration application has been erased, you can reprogram the demonstration firmware into the STM8L15x Flash memory by following the instructions provided in Section 4. For more information about the evaluation board itself, please read the evaluation board user manual. September 2009 Doc ID 16215 Rev 1 1/25 www.st.com Contents UM0784 Contents 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 User interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3 2.1 Menu structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2 Documentation conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.3 Navigating menus and submenus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Demonstration applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.1 Menu overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.2 Welcome screen and main menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.3 Help mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.4 Calendar demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.4.1 Setting the time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.4.2 Setting the date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.4.3 Setting the alarm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.5 Thermometer demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.6 IDD measurement demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.7 Low power demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.8 3.9 3.7.1 Run mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.7.2 Wait for interrupt mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.7.3 Wait for event mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.7.4 Active-Halt mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.7.5 Halt mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Audio demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.8.1 Voice recorder demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.8.2 Voice player demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 About menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 4 Upgrading the demonstration firmware . . . . . . . . . . . . . . . . . . . . . . . . 22 5 STM8L15x peripherals used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 6 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2/25 Doc ID 16215 Rev 1 UM0784 List of tables List of tables Table 1. Table 2. Table 3. Documentation conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Peripherals used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Doc ID 16215 Rev 1 3/25 List of figures UM0784 List of figures Figure 1. Figure 2. Figure 3. Figure 4. Figure 5. Figure 6. Figure 7. Figure 8. Figure 9. Figure 10. Figure 11. Figure 12. Figure 13. Figure 14. Figure 15. Figure 16. Figure 17. Figure 18. Figure 19. Figure 20. Figure 21. Figure 22. Figure 23. Figure 24. Figure 25. Figure 26. Figure 27. Figure 28. Figure 29. Figure 30. Figure 31. Figure 32. Figure 33. Figure 34. Figure 35. Figure 36. Figure 37. Figure 38. Figure 39. Figure 40. Figure 41. Figure 42. 4/25 Menu structure and navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Menu overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Welcome message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Main menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Help mode submenus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Time adjust message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Time show message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Date Adjust message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Date Adjust message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Alarm Adjust message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Alarm show message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Temperature in degrees Celsius message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Temperature in degrees Fahrenheit message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Temperature sensor error message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 IDD measurement message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 IDD Run mode message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Run mode frequency message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 WFI wait for EXTI message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Exit from WFI with EXTI message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 WFI wait for alarm message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Exit from WFI with alarm message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 WFE wait for EXTI message. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Exit from WFE with EXTI message. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 WFE wait for comparator interrupt message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Exit from WFE with comparator interrupt message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Active Halt wait for EXTI message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Exit from Active-halt with EXTI message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Active Halt wait for alarm message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Exit from Active-halt with alarm message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Halt wait for EXTI message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Exit from Halt with EXTI message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Halt wait for comparator interrupt message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Exit from Halt with comparator interrupt message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Start voice recorder message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Erase Flash message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Voice recorder message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Stop voice recorder message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 End voice recorder message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Voice Player menu message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Play voice recorded message. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Stop recorded wave message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Displaying the demonstration firmware version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Doc ID 16215 Rev 1 UM0784 User interface 2 User interface 2.1 Menu structure The demonstration firmware user interface is based on a circular navigation menu, with submenus, item selection and back capability. Figure 1 shows the menu system of the demonstration. The top row of items represents the main menu. Figure 1. Menu structure and navigation SEL WELCOME MESSAGE Left / Right Left / Right ... ... ITEM 2.2 ... Up ... ... SEL ITEM n ... ... ITEM 2.n SEL ITEM 2.1 SEL ITEM 1.n Up Up SEL SEL ITEM 3 SEL Up ... SEL SEL Up ITEM 1.2 SEL Up ITEM 1.1 ... 2.2 Left/Right ITEM 2 SEL ITEM 1 ... ... Documentation conventions In this document, the keywords in bold indicate user actions on the joystick (5-way switch) and the RV2 potentiometer. The present document follows the conventions shown in Table 1. Table 1. Documentation conventions Keyword User action LEFT Press joystick to the left RIGHT Press joystick to the right UP Press joystick up DOWN Press joystick down SEL Press joystick center RV2 Rotate RV2 potentiometer Doc ID 16215 Rev 1 5/25 User interface 2.3 UM0784 Navigating menus and submenus To navigate the menus and submenus, perform the following actions as required: RIGHT: Navigates to the next menu or submenu items on the right. LEFT: Navigates to the next menu or submenu items on the left. SEL: Enters submenu. UP: Exits from a submenu. 6/25 Doc ID 16215 Rev 1 UM0784 Demonstration applications 3 Demonstration applications 3.1 Menu overview The Figure 2 shows all the menu and submenus of the demonstration applications. Figure 2. Menu overview WELCOME MESSAGE MAIN MENU HELP CALENDAR THERMOMETER IDD MEASUREMENT LOW POWER AUDIO Voice Recorder TIME DATE ABOUT Voice player ALARM The following sections provides a detailed description of each part of the demonstration firmware. 3.2 Welcome screen and main menu After a board reset, a welcome message is displayed on the first line of the LCD screen, the ST logo is displayed moving on the second line (see Figure 3). Figure 3. Welcome message STM8L15x Demo ST The main menu is then activated and the message shown in Figure 4 is displayed: Figure 4. Main menu ** MENU ** HELP - push SEL Doc ID 16215 Rev 1 7/25 Demonstration applications 3.3 UM0784 Help mode Pressing SEL from the main menu enters the Help mode. The following messages are displayed sequentially on the LCD screen with a few-second delay: Figure 5. Help mode submenus LEFT or RIGHT to scroll menu Press SEL to enter submenu Move UP to exit submenu To exit this demo, press the joystick UP. 3.4 Calendar demo The STM8L15x features a real-time clock (RTC) including an independent BCD timer/counter, time-of-day clock /calendar, a software programmable alarm, and a periodic programmable wakeup flag with interrupt capabilities that can be used to exit the device from Low power modes. The calendar submenus allow to configure the system time, date and alarm. 3.4.1 Setting the time The TIME submenu offers two options allowing to adjust and display the current time. Once set, the time is used to configure the RTC time. Time adjust Use the Time adjust option either to modify the current time, or to change the time to the current time after the STM8L1526-EVAL evaluation board is powered up. 8/25 Doc ID 16215 Rev 1 UM0784 Demonstration applications 1. To set the time, select the Time adjust option. The Time adjust submenu is then displayed to show the current time value. (see Figure 6). 2. Enter the first digit of the hour field: - Pressing the joystick UP displays the current value plus one. - Pressing the joystick DOWN displays the value of the previous digit. The digit value is limited to a range depending on the time field (hours, minutes or seconds). 3. After selecting the digit value press SEL. The cursor then jumps automatically to the next digit. 4. When all the time digits are set, the Time adjust submenu is displayed again to show the current time. (see Figure 6). Figure 6. Time adjust message Time adjust HH:MM:SS Time show Select Time show to display the current time. The time start counter from (00:00:00) after the first run for the demo the time is cleared if the STM8L1526-EVAL evaluation board is powered down. The Time adjust option is used to enter the current time. When this option is selected, the following message is displayed on the LCD screen: Figure 7. Time show message Time show HH:MM:SS To exit from the Time show submenu press the joystick UP. 3.4.2 Setting the date The DATE submenu offers two options allowing to adjust and display the current date. Once set, the time is used to configure the RTC date. Date Adjust Use the Date adjust option to modify the current date, or to change the default date (09/14/2009) to the current date after the STM8L1526-EVAL evaluation board is powered up. Doc ID 16215 Rev 1 9/25 Demonstration applications UM0784 1. To set the current date, select the Date adjust option. The date then displayed on 8 digits: MM/DD/YYYY (see Figure 8). 2. Enter the first digit of the month field: - Pressing the joystick UP displays the current value plus one - Pressing the joystick DOWN displays the previous value. The digit value is limited to a range depending on the date field (month, day or year). 3. After selecting the digit value press SEL. The cursor then jumps automatically to the next digit. 4. When all the date digits are set, the Date adjust submenu is displayed again to show the current date. (see Figure 8). Figure 8. Date Adjust message Date Adjust 09/14/2009 Date show Select Date show to display the current date. After power-up, the default date (09/14/209) is displayed till the Date adjust option is used to enter the current date. The following message is displayed on the LCD screen when this submenu is selected: Figure 9. Date Adjust message Date Show MON SEP 09 2009 To exit from this sub menu press the joystick UP push. 10/25 Doc ID 16215 Rev 1 UM0784 3.4.3 Demonstration applications Setting the alarm Use the ALARM submenu to configure the alarm seconds, minutes and hours. This submenu offers two options allowing to display or adjust the current alarm. Alarm adjust The Alarm adjust option is similar to Time adjust. After selecting Alarm adjust, or after setting the alarm, the message shown in Figure 10 is displayed. Figure 10. Alarm Adjust message Alarm Adjust HH:MM:SS Alarm show Select the Alarm show option to display the current alarm. After power-up, the default alarm time (00:00:00) is displayed till the Alarm adjust option is used to enter a new alarm time. The following message is displayed on the LCD screen when this submenu is selected: Figure 11. Alarm show message Alarm Show HH:MM:SS To exit from this sub menu press the joystick UP. Note: 1 When an alarm occurs, the alarm wave is played and can be stopped only by pushing the joystick UP. 2 The alarm can be used also to wake up the system from WFI or Active-halt. Doc ID 16215 Rev 1 11/25 Demonstration applications 3.5 UM0784 Thermometer demo The STM8L15x microcontroller features an I2C interface that can be connected to any device supporting the I2C protocol including the system management bus (SMBus) mode. An STLM75 I2C temperature sensor (or any compatible device) is mounted on the STM8L1526-EVAL board. It is used to get the instantaneous external temperature. 1. To enter the THERMOMETER menu, press SEL from the main menu. The message shown in Figure 12 is then displayed on the LCD screen. Figure 12. Temperature in degrees Celsius message Temperature +xx.x C 2. Keep the joystick pressed RIGHT to display the temperature in degrees Fahrenheit as shown in Figure 13. Release the joystick to display back the temperature in degrees Celsius. Figure 13. Temperature in degrees Fahrenheit message Temperature +xxx.x F 3. To exit the Temperature demo, press the joystick UP. When a temperature sensor failure occurs, the message shown in Figure 14 is displayed. Figure 14. Temperature sensor error message ERR: Set JP7 in I2C pos. & try Note: To run this demonstration, the JP7 jumper must be installed in the I2C position. 12/25 Doc ID 16215 Rev 1 UM0784 3.6 Demonstration applications IDD measurement demo The STM8L15x microcontroller features an ADC peripheral. It measures the IDD current in Run mode by using the IDD measurement circuit available on the STM8L1526-EVAL board. 1. Select the IDD MEASUREMENT menu by pressing SEL from the main menu. The message shown in Figure 15 is then displayed on the LCD screen. Figure 15. IDD measurement message IDD MEASUREMENT Run Mode 2. Press SEL to display the current value of IDD in Run mode on the LCD screen (see Figure 16). IDD value is periodically refreshed. Figure 16. IDD Run mode message IDD Run mode x.xxx mA Note: Make sure that the JP11 jumper is installed in the IDD position before running the IDD measurement demo. 3.7 Low power demo The STM8L15x features five low power modes to achieve the best compromise between low power consumption, short startup time and available wakeup sources. The objective of the LOW POWER menu is to demonstrate how to enter the device in these low power modes and exit with different wakeup sources. Power consumption and startup time optimization are not targeted by this application. 3.7.1 Run mode The RUN mode submenu demonstrates the behavior of an application running at different clock frequencies. The demo controls on-board LEDs that blink at the clock frequency. The current value of the clock frequency in Run mode is also displayed on the LCD screen (see Figure 17). Figure 17. Run mode frequency message Run mode 16 MHz Doc ID 16215 Rev 1 13/25 Demonstration applications UM0784 The Run mode submenu contains four submenu items: 16 MHz: the application runs at 16 MHz. 8 MHz: the application runs at 8 MHz. 4 MHz: the application runs at 4 MHz. 2 MHz: the application runs at 2 MHz. Press SEL to select one of the listed Run mode clock frequency. Press UP to exit from the selected mode and return to the 16 MHz default clock frequency. 3.7.2 Wait for interrupt mode This menu allows to put the STM8L15x in Wait for interrupt mode (WFI). The software executes the specific sequence of instructions required to enter WFI mode: the CPU clock is stopped, and selected peripherals go on running. In this demonstration, there are two ways to exit from WFI mode: An external interrupt (EXTI) generated by pressing SEL on the joystick exits the STM8L15x from WFI mode: The LEDs blink until SEL is pressed from the WFI menu (see Figure 18). The system then enters WFI mode and the following message is displayed on the LCD: Figure 18. WFI wait for EXTI message Exit: EXTI Press SEL The STM8L15x remains in WFI mode unless SEL is pressed on the joystick. The MCU then exits from WFI mode, the system clock frequency is set to 16 MHz, and the application execution resumes. The following message is displayed on the LCD screen: Figure 19. Exit from WFI with EXTI message WFI mode Exit: EXTI Note: 14/25 If an alarm occurs when the system is in WFI mode, it is served and a sound is played continuously until the joystick is pressed UP. The application execution then resumes. Doc ID 16215 Rev 1 UM0784 Demonstration applications The RTC alarm is used to wake up the STM8L15x from WFI mode: The LEDs blink until SEL is pressed from the WFI menu (see Figure 20). The system then enters WFI mode and the following message is displayed on the LCD: Figure 20. WFI wait for alarm message WFI mode Wait for Alarm When the alarm time is reached, the system exits from WFI mode, the system clock frequency is set to 16 MHz, and the application execution resumes. The message shown in Figure 21 is then displayed on the LCD screen: Figure 21. Exit from WFI with alarm message WFI mode Exit: Alarm 3.7.3 Wait for event mode This menu allows to put the STM8L15x in Wait for event mode (WFE). The software executes the specific sequence of instructions required to enter WFE mode: the CPU clock is stopped, and selected peripherals go on running. In this demonstration, there are two ways to exit from WFE mode: An external interrupt (EXTI) generated by pressing SEL on the joystick exits the STM8L15x from WFI mode: The LEDs blink until SEL is pressed from the WFE menu (see Figure 22). The system then enters WFE mode and the following message is displayed on the LCD: Figure 22. WFE wait for EXTI message Exit: EXTI Press SEL The STM8L15x remains in WFE mode unless the SEL button is pressed. The MCU then exits from WFE mode, the system clock frequency is set to 16 MHz, and the application execution resumes. The following message is displayed on the LCD screen: Doc ID 16215 Rev 1 15/25 Demonstration applications UM0784 Figure 23. Exit from WFE with EXTI message WFE mode Exit:EXT Event A Comparator 1 interrupt can also exit the STM8L15x from WFE mode This interrupt is generated when the comparator non inverting input (connected to RV2) exceeds the internal reference voltage which is set to 1.22 V. The LEDs blink until SEL is pressed from WFE menu (see Figure 24). The system then enters WFE mode and the following message is displayed on the LCD: Figure 24. WFE wait for comparator interrupt message Exit:COMP Event Rotate RV2 When Comparator 1 non inverting input exceeds the internal reference voltage, the system exits from WFE mode, and the application execution resumes. The message shown in Figure 25 is then displayed on the LCD screen: Figure 25. Exit from WFE with comparator interrupt message WFE mode Exit: COMP Event Note: If an alarm occurs when the system is in WFE mode, it is served and a sound is played continuously until the joystick is pressed UP. The CPU then returns to WFE mode. 3.7.4 Active-Halt mode This menu allows to put the STM8L15x in Active-halt mode. The software executes the specific sequence of instructions required to enter Active-halt mode: the CPU clock is stopped except for the RTC. In this demonstration, there are two ways to exit from Active-halt mode: An external interrupt (EXTI) generated by pressing SEL on the joystick exits the STM8L15x from Active-halt mode: The LEDs continue blinking until SEL is pressed from the Active-halt menu (see Figure 26). The system then enters Active-halt mode and the following message is displayed on the LCD: 16/25 Doc ID 16215 Rev 1 UM0784 Demonstration applications Figure 26. Active Halt wait for EXTI message Active-halt mode Exit: Press SEL The MCU remains in Active-halt mode unless the SEL button is pressed. When SEL is pressed, the MCU exits from Active-halt mode, the system clock frequency is set to 16 MHz, and the application execution resumes. The following message is displayed on the LCD screen: Figure 27. Exit from Active-halt with EXTI message Active-halt mode Exit: EXTI The RTC alarm wakes up the MCU from Active-halt mode: The LEDs blink until SEL is pressed from the Active-halt menu (see Figure 28). The system then enters Active-halt mode and the following message is displayed on the LCD. Figure 28. Active Halt wait for alarm message Active-halt mode Wait for Alarm When the alarm time is reached, the system exits from Active-halt mode, the system clock frequency is set to 16 MHz, and the application execution resumes. The message shown in Figure 29 is displayed: Figure 29. Exit from Active-halt with alarm message Active-halt mode Exit: RTC Alarm Doc ID 16215 Rev 1 17/25 Demonstration applications 3.7.5 UM0784 Halt mode This menu allows to put the STM8L15x in Halt mode. The software performs the specific sequence of instructions required to enter Halt mode: the CPU and peripheral clocks are stopped, and the device remains powered on. In this demonstration, there are two ways to exit from halt mode: An external interrupt (EXTI) generated by pressing SEL on the joystick exits the STM8L15x from halt mode: The LEDs blink until SEL is pressed from Halt menu. The system then enters halt mode and the following message is displayed on the LCD: Figure 30. Halt wait for EXTI message Exit: EXTI Press SEL The STM8L15x remains in Halt mode unless the SEL button is pressed. The MCU then exits from Halt mode, the system clock is set to 16 MHz, and the application execution resumes. The following message is displayed on the LCD: Figure 31. Exit from Halt with EXTI message Halt mode Exit: EXTI A Comparator 1 interrupt can also exit the STM8L15x from Halt mode This interrupt is generated when the non inverting input exceeds the internal reference voltage. The LEDs blink until SEL is pressed from the Halt menu (see Figure 32). The system then enters Halt mode and the following message is displayed on the LCD: Figure 32. Halt wait for comparator interrupt message Exit:COMP Int. Rotate RV2 18/25 Doc ID 16215 Rev 1 UM0784 Demonstration applications When Comparator 1 non inverting input exceeds the internal reference voltage, the system exits from Halt mode, and the application execution resumes. The message shown in Figure 33 is then displayed on the LCD screen: Figure 33. Exit from Halt with comparator interrupt message HALT mode Exit: COMP Int. 3.8 Audio demo 3.8.1 Voice recorder demo The STM8L15x microcontroller features timers and an ADC which can be used for timing and signal acquisition, respectively. In this demo, Timer 1 (TIM1) is used to generate an update interrupt every 45.35 s (22.05 kHz), which corresponds to the voice sampling period. This update event triggers the ADC voice acquisition. Voice data is saved on the on-board SPI Flash memory. When the Voice Recorder is selected from the AUDIO menu by pressing SEL on the joystick, the following message is displayed on the LCD screen: Figure 34. Start voice recorder message Voice Recorder Voice REC Start This message remains displayed until SEL is pressed. The STM8L15x then starts erasing the voice data previously stored on the on-board Flash memory. The message shown in Figure 35 remains displayed until the erase operation is complete. Figure 35. Erase Flash message Voice Recorder SPI Flash Erase When the erase operation is complete, the message shown in Figure 36 is displayed: Doc ID 16215 Rev 1 19/25 Demonstration applications UM0784 Figure 36. Voice recorder message Voice Recorder Record:PressSEL When SEL is pressed, the STM8L15x starts recording voice and the displays the message shown in Figure 37: Figure 37. Stop voice recorder message Voice Recorder Stop:In 30s/UP To stop recording, press the joystick UP, otherwise the STM8L15x will stop recording automatically after 30 s and the message shown in Figure 38 will be displayed: Figure 38. End voice recorder message AUDIO Voice Recorder 3.8.2 Voice player demo The STM8L15x microcontroller features an embedded DAC which can is used to generate output signals. In this demo, the DAC regenerates the voice signal recorded in the SPI Flash memory. Timer 4 (TIM4) triggers the DAC to generate the voice signal every 45.35 s (22.05 kHz) which corresponds to the voice sampling period. When the Voice Player is selected from the AUDIO menu by pressing the SEL on the joystick, The following message remains displayed unless SEL is pressed.: Figure 39. Voice Player menu message Voice Player Recorded Voice When SEL is pressed, the STM8L15x starts playing the voice, and the message shown in Figure 40 is displayed. 20/25 Doc ID 16215 Rev 1 UM0784 Demonstration applications Figure 40. Play voice recorded message Recorded Voice Play To stop the voice player demo, press the joystick UP. The message shown on Figure 41 is then displayed. Otherwise, the STM8L15x will stop automatically at the end of the wave. Figure 41. Stop recorded wave message AUDIO Voice Player 3.9 About menu This menu shows the firmware version. When this submenu is selected the message shown in Figure 42 is displayed on the LCD screen: Figure 42. Displaying the demonstration firmware version STM8L1526-EVAL FW Version x.y.z Press the joystick UP to exit this menu. Doc ID 16215 Rev 1 21/25 Upgrading the demonstration firmware 4 UM0784 Upgrading the demonstration firmware To upgrade the demonstration firmware running on your board, go through the following steps: 1. Download the latest version of STM8L1526-EVAL demonstration firmware and related user manual from www.st.com/mcu. 2. Extract the content of the downloaded zip file to the directory of your choice. 3. Power on the STM8L1526-EVAL board and connect it to the debug instrument. 4. Open STVD toolchain and proceed as follows: a) Open a demo.stw project by selecting File>Open Workspace and browsing the demo project under: \STM8L1526-EVAL_FW\Demo\project\STVD\Cosmic\ b) Configure the debug instrument: Click Debug Instrument>Target Settings in the Debug Instrument Setting window Select the target debug instrument used for the debug session (SWIM STICE, SWIM RLink or STLink) Click OK. 5. Note: 22/25 c) Click Build>Rebuild All to rebuild all files d) Click Debug>Start Debugging to load the demonstration image Select Debug>Run to run the demonstration. The demonstration firmware is now programmed and you can close the debugging session. You can also load a binary file of the demonstration firmware (.s19) by using the STVP toolchain (refer to the STVP online help for details). The binary file is available under \STM8L1526-EVAL_FW\Utilities\Binary. Doc ID 16215 Rev 1 UM0784 5 STM8L15x peripherals used STM8L15x peripherals used The following table lists the STM8L15x peripherals used in each demo: Table 2. Peripherals used Peripheral Demo ADC1 IDD measurement, Voice recorder DAC Voice player COMP 1 Low power External interrupts (EXTI) Low Power GPIO All demo Clock controller All demo I2C1 Thermometer TIM1 Voice recorder TIM2 All demos (time base) TIM4 Voice player SPI1 All demos + Voice player +Voice recorder RTC Calendar Doc ID 16215 Rev 1 23/25 Revision history 6 UM0784 Revision history Table 3. 24/25 Document revision history Date Revision 11-Sep-2009 1 Changes Initial release. Doc ID 16215 Rev 1 UM0784 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. (c) 2009 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 16215 Rev 1 25/25