December 2010 Doc ID 18209 Rev 1 1/58
AN3311Application note
In-home display for ZigBee® smartplug
IntroductionThis application note describes the demonstration firmware running on the STM3210C-EVAL for the STM32F107VC to manage a smartplug network system.
An embedded graphical user interface (GUI) based on the “multi-input embedded GUI library 2.0 for STM32F10xxx” described in the AN3128 application note, and working on an LCD TFT 320 x 240 display and 5-position joystick, allows the user to interact with the smartplug system made up of one coordinator and two smartplugs connected.
Section 1 describes the document and library rules.
Section 2 highlights the features of the ZigBee smartplug and explains its hardware interface with a device microcontroller (STM32).
Section 3 describes briefly the “multi-input embedded GUI library”.
Section 4 describes the relevant blocks of the STM3210C-EVAL demonstration board.
Section 5 shows the demonstration firmware/board system setup.
Section 6 describes, in detail, how the “in-home display” firmware is structured, its architecture and its exported APIs.
Section 7 explains how to get started with the system, how to configure and use the IAR workspace, and contains an example application source code.
Section 8 illustrates how the “in-home display” GUI application works.
Section 9 illustrates the hardware schematics.
www.st.com
Contents AN3311
2/58 Doc ID 18209 Rev 1
Contents
1 Document and library rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1 Acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2 ZigBee smartplug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1 Smartplug description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 ZigBee module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3 Multi-input embedded GUI library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4 STM3210C-EVAL demonstration board . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2 STM32 peripherals mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.3 Power supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.4 Boot option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.5 Clock source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.6 Reset source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.7 Joystick . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.8 Pushbuttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.9 Storage memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.10 Development and debug support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.11 Display and input devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.12 JTAG debugging connector CN13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.13 Daughterboard extension connector CN8 and CN9 . . . . . . . . . . . . . . . . . 19
4.14 TFT LCD connector CN14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.15 Power connector CN18 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5 Demonstration firmware system setup . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.1 Hardware requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.2 STM3210C-EVAL demonstration board setup . . . . . . . . . . . . . . . . . . . . . 24
5.3 STM3210C-EVAL and ZigBee adapter with M24LR62-r memory . . . . . . 24
5.4 How to navigate the demo menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
AN3311 Contents
Doc ID 18209 Rev 1 3/58
6 In-home display firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.1 Firmware architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.2 main.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.2.1 vSmartPlugSamplingTask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.2.2 vGraphicLibraryTask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
6.2.3 prvApplicationTask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
6.2.4 prvSetupHardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
6.2.5 vBoardInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
7 Getting started with the system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
7.1 Configure IAR tool for building, debugging, and programming the application 31
7.2 Example application - main.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
8 In-home display GUI application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
9 Schematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
9.1 Smartplug board schematics and layout . . . . . . . . . . . . . . . . . . . . . . . . . 45
9.2 ZigBee/RF adapter for smartplug and dual interface memory . . . . . . . . . 46
9.3 STM3210C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
9.4 MCU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
9.5 LCD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
9.6 I/O expander . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
9.7 I/O peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
9.8 Extension connector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
9.9 JTAG and trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
9.10 Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
9.11 LCD 3.2" module with SPI and 16-bit interface 1 . . . . . . . . . . . . . . . . . . . 55
10 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
11 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
List of tables AN3311
4/58 Doc ID 18209 Rev 1
List of tables
Table 1. List of acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Table 2. Power related jumpers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Table 3. Boot related switches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Table 4. Reset related jumper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Table 5. LCD module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17Table 6. JTAG debugging connector CN13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Table 7. Daughterboard extension connector CN8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Table 8. Daughterboard extension connector CN9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Table 9. ZigBee adapter pin description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24Table 10. Function description format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26Table 11. vSmartPlugSamplingTask task. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27Table 12. vGraphicLibraryTask task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28Table 13. prvApplicationTask task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Table 14. prvSetupHardware function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Table 15. vBoardInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Table 16. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
AN3311 List of figures
Doc ID 18209 Rev 1 5/58
List of figures
Figure 1. STM3210C-EVAL block scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Figure 2. Block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Figure 3. I/O expander hardware configuration on the STM3210C-EVAL. . . . . . . . . . . . . . . . . . . . . 10Figure 4. STM3210C-EVAL demonstration board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Figure 5. Hardware block diagram - STM32 peripherals mapping. . . . . . . . . . . . . . . . . . . . . . . . . . . 13Figure 6. STM3210C-EVAL demonstration board layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Figure 7. JTAG debugging connector CN13 viewed from above the PCB . . . . . . . . . . . . . . . . . . . . 18Figure 8. Power supply connector CN18 viewed from the front. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23Figure 9. In-home display firmware architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26Figure 10. Application project files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31Figure 11. IAR embedded workbench main window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32Figure 12. IAR embedded workbench debugger options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32Figure 13. ZigBee dongle connection problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38Figure 14. Main menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38Figure 15. Searching plugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Figure 16. No plug detected. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40Figure 17. Plugs detected . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40Figure 18. Label changing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Figure 19. TRIAC smartplug management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Figure 20. Relay smartplug management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Figure 21. Smartplug statistics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Figure 22. Energy consumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43Figure 23. Global energy consumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43Figure 24. Power consumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Figure 25. Global power consumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Figure 26. ZigBee and dual interface EEPROM adapter schematic for STM3210C-EVAL . . . . . . . . . 45Figure 27. ZigBee and dual interface EEPROM adapter layout for STM3210C-EVAL . . . . . . . . . . . . 46Figure 28. STM3210C main schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47Figure 29. MCU schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48Figure 30. LCD schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49Figure 31. I/O expander schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50Figure 32. I/O peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Figure 33. Extension connector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52Figure 34. JTAG and trace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Figure 35. Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54Figure 36. LCD 3.2" module with SPI and 16-bit interface 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Document and library rules AN3311
6/58 Doc ID 18209 Rev 1
1 Document and library rules
This document uses the conventions described in the sections below.
1.1 AcronymsTable 1 lists the acronyms used in this document.
Table 1. List of acronyms
Acronym Meaning
API Application programming interface
HAL Hardware abstraction layer
MCU Microcontroller unit
I2C Inter-integrated circuit
SPI Serial to parallel interface
OOP Object oriented programming
AN3311 ZigBee smartplug
Doc ID 18209 Rev 1 7/58
2 ZigBee smartplug
2.1 Smartplug descriptionThe smartplug coordinator is connected via an SPI to the STM3210C-EVAL through an “Ad-Hoc” adapter.
In Figure 1 it is possible to take a quick look at the STM3210C-EVAL board and a smartplug node block diagram.
Figure 1. STM3210C-EVAL block scheme
An adapter is connected to the extended connectors CN8 and CN9 on the STM3210C-EVAL (for more detailed information please refer to the UM0600 user manual), it allows the connection of a ZigBee smartplug coordinator and the I2C/RF dual interface EEPROM M24LR64-r. The Gerber files of the adapter board are included in the setup package of this project.
The ZigBee smartplug board can be used as a guide to build a home/building automation subsystem for energy management. In a typical application, the board is plugged into an electrical wall socket and supplies an electrical load, monitoring the energy consumption; using several smartplugs it is possible to monitor and control the home/building energy consumption socket by socket. The board includes the following functions, shown in the block diagram of Figure 2:
● Energy measurement
● Load differential current
● Load driving by relay or TRIAC (dimming)
● ZigBee communication capability.
ZigBee smartplug AN3311
8/58 Doc ID 18209 Rev 1
Figure 2. Block diagram
The STEVAL-IHP001V3 is a smartplug board based on an STM32F10x microcontroller, a SPZB260 ZigBee module, and an STPM01 energy metering IC.
It implements a ZigBee metering node which allows the final user to monitor and manage energy consumption.
The board has been developed as a guide to build a home/building automation subsystem for energy management. In a typical home system implementation, the board is plugged into an electrical wall socket and supplies a home appliance or other generic electrical load.
The current, power, energy, and other information, related to the electrical load connected to the smartplug board, can be displayed locally on an LCD screen, and are sent to a ZigBee data concentrator through the home/building ZigBee network.
2.2 ZigBee moduleZigBee smartplug communication is based on the SPZB260 module with a DIL adapter. The module is FCC compliant (FCC ID:S9NZB260A). The module is based on the SN260 ZigBee network processor which integrates a 2.4 GHz, IEEE 802.15.4 compliant transceiver, as well as IEEE 802.15.4 PHY and MAC. The main features are:
● 0dBm nominal TX output power
● -92dBm RX sensitivity
● +2dBm TX output power in boost mode
● RX filtering for co-existence with IEEE 802.11g and Bluetooth® devices.
For further details please refer to the SPZB260 module and the SN260 network processor datasheet.
Note: For more information, see the UM0608 user manual, STEVAL-IHP001V3 schematics diagram, and AN2993 application note.
AN3311 Multi-input embedded GUI library
Doc ID 18209 Rev 1 9/58
3 Multi-input embedded GUI library
3.1 DescriptionThis solution enables users, comfortable with the use of standard microcontrollers, to create higher-end “look and feel” human interfaces by replacing conventional electromechanical switches with touch-sensing controls.
Users can combine touch-sensing functions using multiple configurations (touchscreen, joystick, and keys) with traditional MCU features (communication, beeper, LCD control, etc.).
The E-multi-input graphic library is part of the application firmware.
The graphic objects are a set of controls that can be printed on the screen and associated to an action when pressed.
The library has been developed and tested on an LCD panel of QWGA resolution (320x240) which is the default, but the library is independent of the LCD resolution, although it has not been tested with others.
The library supports touchscreen features and includes a low level driver which handles the analog input (for 12-bit ADC), and a function for the touchscreen calibration based on an algorithm that uses 5 points.
The multi-input embedded GUI firmware library is fully developed in 'ANSI-C' following an OOP approach. This means that the final application uses instances of page and graphic objects according to their public methods and properties. In the end, the PageObj is a structure containing public properties (data fields) and methods (functions pointers). The OOP encapsulation feature is assured. The library has been developed and tested on the “STM3210C” STMicroelectronics demonstration board.
The library can be included in the final application as a library file (multi-input embedded GUI library.a) and used as a black box through its exported public API, or can be included in the final application as source files (.c and .h), if the user wants to debug the library itself, or to change the HAL functions in order to port the library on a different LCD (in model and resolution) from the one attached to STM3210C-EVAL.
For more information on the graphic library see the AN3128, rev. 2, application note.
The calibration process is part of the post-processing layer. The touchscreen must be calibrated at first power-on and/or upon user request.
Once the calibration is done, final adjustments on future power-on of the board are not necessary because the calibration parameters are saved on the Flash memory.
The touchscreen and the joystick are controlled by the STMPE811 devices.
The STMPE811 has a simple 2-wire I2C digital serial interface which allows the user to access the data in the touchscreen controller register at any time. It communicates via the serial interface with a master controller.
Figure 3 shows how the STM32F10xxx microcontroller (master device) must be connected to the STMPE811 device.
Refer to the STMPE811 datasheet for more information on the register concerning the data of the touched points on the touchscreen.
Multi-input embedded GUI library AN3311
10/58 Doc ID 18209 Rev 1
Figure 3. I/O expander hardware configuration on the STM3210C-EVAL
AM08449v1
Y- 1
INT2
A0/DataA0/Data OutOut3
45
VCVCC6
DataData in7
IN0 8IN1 9
GNGND1010
IN2 1111IN3 1212X+ 1313
VioVio1414
Y+ 1515X- 1616
U7
STSTMPE81811
Y- 1
INT2
A0/DataA0/Data OutOut3
45
VCVCC6
DataData in7
IN0 8IN1 9
GNGND1010
IN2 1111IN3 1212X+ 1313
VioVio1414
Y+ 1515X- 1616
U8
STSTMPE81811R5R561010K
+3V+3V3
I2C devicdevice address:0x8 address:0x8 2
I2C devicdevice address:0x8address:0x88
+3V+3V3
+3V+3V3
R5R57100100K
R5R58100100K
TouchScreen_X+TouchScreen_X+
TouchScreen_X-TouchScreen_X-TouchScreen_Y+TouchScreen_Y+
TouchScreen_Y-TouchScreen_Y-
EXPEXP_I_IO2EXPEXP_I_IO3EXPEXP_I_IO4EXPEXP_I_IO5EXPEXP_I_IO6EXPEXP_I_IO7EXPEXP_I_IO8
EXPEXP_I_IO9EXPEXP_I_IO1O10EXPEXP_I_IO1O11EXPEXP_I_IO1O12
EXPEXP_I_IO1
R160R1601010K
R15R159 0
+3V+3V3
R3R371010K
R164R1641010K
+3V+3V3
C8C89100n100nF
C9C90100n100nF
PB6PB7PB1B14
IO_Expander_SCKIO_Expander_SDAIO_Expander_INT
SCLKSCLKSDATSDAT
SCLKSCLKSDATSDAT
AN3311 STM3210C-EVAL demonstration board
Doc ID 18209 Rev 1 11/58
4 STM3210C-EVAL demonstration board
Figure 4. STM3210C-EVAL demonstration board
STM3210C-EVAL demonstration board AN3311
12/58 Doc ID 18209 Rev 1
4.1 Features● Three 5 V power supply options: power jack, USB connector, or daughterboard
● Boot from user Flash, system memory or SRAM
● I2S audio DAC, stereo audio jack
● 512 MByte (or bigger) micro-SD cardTM
● Both type A and B smartcard support
● I2C compatible serial interface 64-Kbit EEPROM, MEMS and I/O expander
● RS-232 communication
● IrDA transceiver
● USB-OTG full speed, USB mini-AB connector
● IEEE-802.3-2002 compliant Ethernet connector
● Two channels of CAN2.0A/B compliant connection
● Inductor motor control connector
● JTAG and trace debug support
● 3.2" 240x320 TFT color LCD with touchscreen
● Joystick with 4-direction control and selector
● Reset, wake-up, tamper, and user button
● 4 color LEDs
● RTC with backup battery
● MCU consumption measurement circuit
● Extension connector for daughterboard or wrapping board.
4.2 STM32 peripherals mapping The STM3210C-EVAL demonstration board is designed around the STM32F107VC in a 100-pin TQFP package. The hardware block diagram, Figure 5, illustrates the connection between the STM32F107VC and peripherals (LCD, EEPROM, MEMS, USART, IrDA, USB-OTG, Ethernet, audio, CAN bus, smartcard, micro-SD card, and motor control) and these features can be located on the actual demonstration board in Figure 6.
AN3311 STM3210C-EVAL demonstration board
Doc ID 18209 Rev 1 13/58
Figure 5. Hardware block diagram - STM32 peripherals mapping
For more details of calibration parameters, refer to the STPM01 datasheet on www.st.com.
STM3210C-EVAL demonstration board AN3311
14/58 Doc ID 18209 Rev 1
Figure 6. STM3210C-EVAL demonstration board layout
4.3 Power supplyThe STM3210C-EVAL demonstration board is designed to be powered by a 5 V DC power supply and protected by PolyZen from a wrong power plug-in event. It is possible to configure the demonstration board to use any of the following three sources for the power supply:
● 5 V DC power adapter connected to CN18, the power jack on the board (PSU on silk screen for power supply unit)
● 5 V DC power with 500 mA limitation from CN2, the USB mini-AB connector (USB on silkscreen)
● 5 V DC power from both CN8 and CN9, the extension connector for the daughterboard (DTB for daughterboard on silkscreen).
AN3311 STM3210C-EVAL demonstration board
Doc ID 18209 Rev 1 15/58
The power supply is configured by setting the related jumpers JP24 and JP25, as described in Table 2.
4.4 Boot optionThe STM3210C-EVAL board is able to boot from:
● Embedded user Flash
● System memory with boot loader for ISP
● Embedded SRAM for debugging.
The boot option is configured by setting switches SW1 (BOOT1) and SW2 (BOOT0). The BOOT0 can be configured also via the RS-232 connector CN6.
Table 2. Power related jumpers
Jumper Description Configuration
JP25
JP25 selects one of the three possible power supply resources.For power supply jack (CN18) to the STM3210C-EVAL only, JP25 is set as shown: (Default)
For power supply from the daughterboard connectors (CN8 and CN9) to the STM3210C-EVAL only, JP25 is set as shown:
For power supply from USB (CN2) to the STM3210C-EVAL only, JP25 is set as shown:
For power supply from power supply jack (CN18) to both the STM3210CEVAL
and daughterboard connected on CN8 and CN9, JP25 is set as
shown to the right (the daughterboard must not have its own power supplyconnected):
JP24
Vbat is connected to 3.3 V power when JP24 is set as shown: (Default)
Vbat is connected to battery when JP24 is set as shown:
STM3210C-EVAL demonstration board AN3311
16/58 Doc ID 18209 Rev 1
4.5 Clock sourceTwo clock sources are available on the STM3210C-EVAL demonstration board for STM32F107VC, and RTC is embedded.
● X2, 32 kHz crystal for embedded RTC
● X3, 25 MHz crystal with socket for an STM32F107VC microcontroller, it can be removed from the socket when an internal RC clock is used.
4.6 Reset sourceThe reset signal of the STM3210C-EVAL board is low active and the reset sources include:
● Reset button, B1
● Debugging tools from JTAG connector CN13 and trace connector CN12
● Daughterboard from CN9
● RS-232 connector CN6 for ISP.
Table 3. Boot related switches
Switch Boot from Configuration
SW1 and SW2
STM3210C-EVAL boots from user Flash when SW2 is set as shown on the right. SW1 setting does not matter in this configuration. (Default)
STM3210C-EVAL boots from system memory when SW1 and SW2 are set as shown:
STM3210C-EVAL boots from embedded SRAM when SW1 and SW2 are set as shown:
Table 4. Reset related jumper
Jumper Description
JP20
Enables reset of the STM32F107VC embedded JTAG TAP controller each time a system reset occurs. JP20 connects the TRST signal from the JTAG
connection with the system reset signal RESET#.
Default setting: not fitted.
AN3311 STM3210C-EVAL demonstration board
Doc ID 18209 Rev 1 17/58
4.7 JoystickThe joystick is four-directional and includes a selection key.
4.8 PushbuttonsThe following pushbuttons are provided:
● Key: user pushbutton
● Tamper: user pushbutton
● Wake-up: pushbutton used to wake up the processor from low-power mode.
4.9 Storage memoryThe ZigBee adapter has a 64-Kbit I2C/RF dual interface memory (M24LR64-r) on board, and it is connected to the I2C1 peripheral of the MCU.
The I2C address of the memory can be set by using the jumpers JP1 and JP2 on the ZigBee adapter and must be different from the one already present on the STM3210C-EVAL (with address 0xA0).
4.10 Development and debug supportThe two debug connectors available on the STM3210C-EVAL demonstration board are:
1. CN13, standard 20-pin JTAG interface connector which is compliant with the debug tools of ARM7 and ARM9
2. CN12, SAMTEC 20-pin connector FTSH-110-01-L-DV for both SWD and trace which is compliant with ARM CoreSightTM debug tools
4.11 Display and input devicesThe 3.2" TFT color LCD connected to SPI3 and 4 general purpose color LED's (LED 1, 2, 3, 4) are available as display devices.
A touchscreen connected to an I/O expander (U7), a 4-direction joystick with selection key, a general purpose button (B3), a wake-up button (B2), and a tamper detection button (B4) are available as input devices.
Table 5. LCD module
3.2" TFT LCD with touchscreen
CN14 (default)
Pin on CN14 Description Pin connection
1 CS PB2
2 RS -
3 WR/SCL PC10
4 RD -
STM3210C-EVAL demonstration board AN3311
18/58 Doc ID 18209 Rev 1
4.12 JTAG debugging connector CN13
Figure 7. JTAG debugging connector CN13 viewed from above the PCB
5 RESET RESET#
22 BL_GND GND
23 BL_Control +5 V
24 VDD 3.3 V
25 VCI 3.3 V
26 GND GND
27 GND GND
28 BL_VDD +5 V
29 SDO PC11
30 SDI PC12
31 XL I/O Expander
32 XR I/O Expander
33 YD I/O Expander
34 YU I/O Expander
Table 5. LCD module (continued)
3.2" TFT LCD with touchscreen
CN14 (default)
Pin on CN14 Description Pin connection
Table 6. JTAG debugging connector CN13
Pin number Description Pin number Description
1 3.3 V power 2 3.3 V power
3 PB4 4 GND
5 PA15 6 GND
7 PA13 8 GND
9 PA14 10 GND
AN3311 STM3210C-EVAL demonstration board
Doc ID 18209 Rev 1 19/58
4.13 Daughterboard extension connector CN8 and CN9Two 50-pin male headers, CN8 and CN9, can be used to connect a daughterboard or standard wrapping board to the STM3210C-EVAL demonstration board. All 80 GPIOs are available on it. The space between these two connectors and the power position, GND and RESET pin are defined as a standard, which allows to develop common daughterboards for several demonstration boards. The standard width between CN8 pin1 and CN9 pin1 is 2700 mills (68.58mm). This standard was implemented on the majority of demonstration boards.
Each pin on CN8 and CN9 can be used by a daughterboard after disconnecting it from the corresponding function block on the STM3210C-EVAL demonstration board.
11 RTCK 12 GND
13 PB3 14 GND
15 RESET# 16 GND
17 DBGRQ 18 GND
19 DBGACK 20 GND
Table 6. JTAG debugging connector CN13 (continued)
Pin number Description Pin number Description
Table 7. Daughterboard extension connector CN8
Pin Description Alternate functionHow to disconnect with function block on STM3210C-
EVAL board
1 GND -
3 PC7 MC Disconnect STM3210C-EVAL board from motor power drive
board
5 PC9 USB power switch On Remove R36
7 PA9 USB VBUS Remove R78
9 PA0 MC/Ethernet/WKUPKeep JP14 open. Disconnect STM3210C-EVAL board from
motor power drive board.
11 PC14 via SB1 32 kHz oscillator Remove R161, close SB1
13 PA12 USB_DP Remove R43 or disconnect USB cable
15 PC15 via SB2 32 kHz oscillator Remove R59, close SB2
17 PC10 SPI1_CLK
19 GND -
21 PC12 SPI1_MOSI
23 PD1 CAN1_TX
25 PD3 LD3 Remove R96
27 PD5 USART2_TX
29 PD7 LD1 Remove R94
31
STM3210C-EVAL demonstration board AN3311
20/58 Doc ID 18209 Rev 1
33 PB3 TDO/SWO
35 PB5 CAN2_RX Remove R45
37 PB7 I2C1_SDA Remove R132
39 GND -
41 PE2 Trace_CK
43 PE4 Trace_D1
45 PB8 MCDisconnect STM3210C-EVAL board from motor power drive
board
47 PE6 Trace_D3
49 D5V
2 PC6 I2S_MCK/MC JP10 open
4 PC8 MCDisconnect STM3210C-EVAL board from motor power drive
board
6 PA8 MCO JP4 open
8 PA10 USB_ID Remove R38 or disconnect USB cable
10 GND
12 PA11 USB_DM Remove R42 or disconnect USB cable
14 PA13 TMS/SWDIO
16 PA14 TCK/SWCLK
18 PC11 SPI1_MISO Remove R135 and LCD
20 PA15 TDI
22 PD0 CAN1_RX Remove R44
24 PD2 MC Disconnect STM3210C-EVAL board from motor power drive
board.
26 PD4 LD4 Remove R97
28 PD6 USART2_RX Keep JP16 open
30 GND
32
34 PB4 TRST Keep JP20 open
36 PB6 CAN2_TX/ I2C1_SCK
Keep JP9 open
38 PE0MC/Micro-SD card
detectionRemove micro-SD card. Disconnect STM3210C-EVAL board
from motor power drive board.
40 PE1 USB_Overcurrent Remove R35
42 PE3 Trace_D0
44 PE5 Trace_D2
Table 7. Daughterboard extension connector CN8 (continued)
Pin Description Alternate functionHow to disconnect with function block on STM3210C-
EVAL board
AN3311 STM3210C-EVAL demonstration board
Doc ID 18209 Rev 1 21/58
46 PB9 User button Remove R104
48 3.3 V
50 GND
Table 7. Daughterboard extension connector CN8 (continued)
Pin Description Alternate functionHow to disconnect with function block on STM3210C-
EVAL board
Table 8. Daughterboard extension connector CN9
Pin Description Alternate functionHow to disconnect with function block on STM3210C-
EVAL board
1 GND -
3 PD14 MC Keep JP22 open. Disconnect STM3210C-EVAL board from
motor power drive board.
5 PD12 Ethernet Remove RS2
7 PD10 Ethernet/smartcard Keep JP11 open
9PC13 button
B3
IDD_CNT_EN /Anti-tamper button
B4Keep JP1 open
11 RESET# -
13 PB15 I2S_DIN
15 PB13 I2S_CK/Ethernet Remove RS3
17 PB11 Ethernet Remove RS3
19 D5V -
21 PE14 Smartcard_CMDVCC Remove R166
23
25 PE12 MCDisconnect STM3210C-EVAL board from motor power drive
board
27 PE10 MC
29 PE8 MC
31 PE7 Smartcard_OFF Remove R69
33 PB1 MC Remove R168
35 PC5 VBAT_voltage Remove R154
37 PA7 MC Remove R169
39 GND
41 PA4Micro-SD card/
Audio_DACKeep JP15 open
43 PA2 Ethernet Remove R162
45 PC3 Ethernet Remove RS1
STM3210C-EVAL demonstration board AN3311
22/58 Doc ID 18209 Rev 1
47 PC1 Ethernet
49 PC13IDD_CNT_EN /
Anti-tamper button B4
Keep JP1 open
2 PD15 MCDisconnect STM3210C-EVAL board from motor power drive
board
4 PD13 LD2 Remove R95
6 PD11 Ethernet Remove RS1
8 PD9 Ethernet/smartcard Keep JP12 open
10 GND
12 PD8 Ethernet/smartcard Keep JP13 open
14 PB14 IO_Expander_INT Remove R159
16 PB12 Ethernet/audio Remove RS3
18 PB10 Ethernet Remove RS2
20 PE15 MC Remove R139
22 PE13 MCDisconnect STM3210C-EVAL board from motor power drive
board
24
26 PE11 MCDisconnect STM3210C-EVAL board from motor power drive
board
28 PE9 MC
30 GND
32 PB2 MC Remove R168
34 PB0 MC Remove R167
36 PC4 Potentiometer Remove R103
38 PA6 IDD_Measurement Remove R79
40 PA5 MC Remove R84
42 PA3 MC/Ethernet Keep JP10 open
44 PA1 Ethernet Keep JP3 open
46 PC2 Ethernet Remove RS1
48 PC0 MC/smartcard Remove R165
50 GND
Table 8. Daughterboard extension connector CN9 (continued)
Pin Description Alternate functionHow to disconnect with function block on STM3210C-
EVAL board
AN3311 STM3210C-EVAL demonstration board
Doc ID 18209 Rev 1 23/58
4.14 TFT LCD connector CN14One 34-pin male header CN14 is available on the board to connect LCD module board MB785.
4.15 Power connector CN18The STM3210C-EVAL demonstration board can be powered from a DC 5 V power supply via the external power supply jack (CN18) shown in Figure 8. The central pin of CN18 must be positive.
Figure 8. Power supply connector CN18 viewed from the front
For more information on STM3210C-EVAL, please refer to the UM0600 user manual.
Demonstration firmware system setup AN3311
24/58 Doc ID 18209 Rev 1
5 Demonstration firmware system setup
5.1 Hardware requirementsa) ZigBee adapter board
b) ZigBee module SPZB260-PRO
c) VDC/2A isolated power supply is recommended
d) One JTAG programmer/debugger dongle (J-Link from SEGGER or IAR Systems™ is recommended). It is unnecessary if no modifications to the firmware code have been performed.
5.2 STM3210C-EVAL demonstration board setupSet up the STM3210C-EVAL board as follows:
● Close jumper JP19
● Keep JP15 open
● Remove R79, R84, and R169.
5.3 STM3210C-EVAL and ZigBee adapter with M24LR62-r memory
Table 9. ZigBee adapter pin description
STM32 pin no. Pin nameSTM3210C-EVAL I/O
assignmentExtension connector pin
no.ZigBee adapter I/O
assignment
- VDD 3.3 V CN8 - Pin 48 VCC_3V3
- VSS GND CN9 - Pin 50 GND
29 PA4 SPI1_NSS CN9 - Pin 41 ZIG_SS
30 PA5 SPI1_CLK CN9 - Pin 40 ZIG_SCLK
31 PA6 SPI1_MISO CN9 - Pin 38 ZIG_MISO
32 PA7 SPI1_MOSI CN9 - Pin 37 ZIG_MOSI
92 PB6 CAN2_TX/I2C1_SCK CN8 - Pin 36 I2C1_SCK
93 PB7 I2C1_SDA CN8 - Pin 37 I2C1_SDA
2 PE3 Trace_D0 CN8 - Pin 42 ZIG_HOST_INT
3 PE4 Trace_D1 CN8 - Pin 43VCC-GPIO (for M24LR64-
r)
4 PE5 Trace_D2 CN8 - Pin 44 ZIG_WAKE
5 PE6 Trace_D3 CN8 - Pin 47 ZIG_RSTB
AN3311 Demonstration firmware system setup
Doc ID 18209 Rev 1 25/58
5.4 How to navigate the demo menuFour basic elements constitute the hardware of the system user interface: a 320 x 240 TFT LCD display, a resistive touchscreen, a 5-way (left, right, up, down, selection) micro-joystick and a pushbutton “Key”.
The joystick is primarily used for navigating between the various menu screens, within a screen and between screen items. In addition, the joystick allows the selection and editing of item values.
In-home display firmware AN3311
26/58 Doc ID 18209 Rev 1
6 In-home display firmware
6.1 Firmware architecture
Figure 9. In-home display firmware architecture
This section describes the firmware implementation. The tasks/functions are described in the following format:
Table 10. Function description format
Function name The name of the function
Function prototype Prototype declaration of the function
Behavior description Brief explanation of how the function is executed
Input parameter {x} Description of the input parameters
Output parameter {x} Description of the output parameters
Return value Value returned by the function
Required preconditions Requirements before calling the function
Called functions Other library functions called
AM08462v1
on{
InHome Display Firmware Architecture
Fr p
licat
iL
ayer SmartPlug Coordinator{ Zi B St k
SPI{eeR
Ap
p { ZigBee Stack
ut ry
ZigBee Adapter and RF Antenna for I2C Dual {R
TO ti
-In
pu
Lib
rar
Multi-Input GUI Layer{ Interface Memory{ SPI
S
Mu
ltG
UI { LCD HAL
t
{d
war
een
den
t
LCD Libraries{
Har
dD
epe
STM32F10xx Libraries{I2C
AN3311 In-home display firmware
Doc ID 18209 Rev 1 27/58
6.2 main.c
6.2.1 vSmartPlugSamplingTask
Table 11 describes the vSmartPlugSamplingTask task:
Example: static void vSmartPlugSamplingTask( void *pvParameters){ CoordinatorType* pObjCoordinator = GetCoordinatorObj(); int i=0; sinkAdvertise(); pObjCoordinator = GetCoordinatorObj(); //Get the Smart-Plug list ppSmartPlugList = pObjCoordinator->GetSmartPlugList(pObjCoordinator); while(1) { if ( ppSmartPlugList[0] ) { smart_points1[i%N_SAMPLES] = ppSmartPlugList[0]->Energy; smart_points1B[i%N_SAMPLES] = ppSmartPlugList[0]->Power; } if ( ppSmartPlugList[1] ) { smart_points2[i%N_SAMPLES] = ppSmartPlugList[1]->Energy; smart_points2B[i%N_SAMPLES] = ppSmartPlugList[1]->Power; } i++; if(i == N_SAMPLES) { i=0; for(int j=0; j<N_SAMPLES; j++) { smart_points1[j] = 0; smart_points1B[j] = 0; smart_points2[j] = 0; smart_points2B[j] = 0; } } if( i%8 == 0 )
Table 11. vSmartPlugSamplingTask task
Function name vSmartPlugSamplingTask
Function prototype void vSmartPlugSamplingTask(void *pvParameters)
Behavior description Read and sample the plug consumption values
Input parameter {x} None
Output parameter {x} None
Return value None
Required preconditions None
Called functions No API/HAL layer functions;
In-home display firmware AN3311
28/58 Doc ID 18209 Rev 1
sinkAdvertise(); vTaskDelay(2000); //20 sec }}
The application simulates the behavior of the system in a 24 hour period considering an hour as equal to 20 seconds. After 24 hours (simulated), it resets the array values, so the GraphCharts and the histograms show a maximum value set to zero.
6.2.2 vGraphicLibraryTask
Table 12 describes the vGraphicLibraryTask task:
This function checks if an input device has been stimulated (touchscreen or joystick/button) and calls the graphic library relative function according to the object pressed.
Example: static void vGraphicLibraryTask( void *pvParameters ) { /* Menu Initialization*/ MENU_DeInit(); CursorShow(195, 50); /* Infinite main loop ------------------------------------------------------*/ while (1) { ProcessTouchScreenData(); /*Time out calculate for power saving mode*/ TimeOutCalculate(); #ifdef USE_STM3210C_EVAL if (restart_calibration==1) { TS_Calibration(); restart_calibration = 0; MENU_DeInit(); } CursorReadJoystick(IOEXP_MODE); TSC_Read(); #else
Table 12. vGraphicLibraryTask task
Function name vGraphicLibraryTask
Function prototype void vGraphicLibraryTask(void *pvParameters)
Behavior description Check if an input device has been stimulated (touchscreen or joystick/button)
Input parameter {x} None
Output parameter {x} None
Return value None
Required preconditions None
Called functions No API/HAL layer functions;
AN3311 In-home display firmware
Doc ID 18209 Rev 1 29/58
CursorReadJoystick(POLLING_MODE); #endif vTaskDelay(2); }}
6.2.3 prvApplicationTask
Table 13 describes the prvApplicationTask task:
This function starts the smartplug coordinator application routine.
Example:void prvApplicationTask( void * pvParameters ){ /* The parameters are not used in this task. */ ( void ) pvParameters; for( ;; ) { applicationTick(); /* Wait until it is time to move onto the next string. */ vTaskDelay(4); }}
6.2.4 prvSetupHardware
Table 14 describes the prvSetupHardware function:
Table 13. prvApplicationTask task
Function name prvApplicationTask
Function prototype void prvApplicationTask (void *pvParameters)
Behavior description Start the Smartplug Coordinator Application routine
Input parameter {x} None
Output parameter {x} None
Return value None
Required preconditions None
Called functions No API/HAL layer functions;
Table 14. prvSetupHardware function
Function name prvSetupHardware
Function prototype void prvSetupHardware (void)
Behavior description Initialize the hardware peripheral of the STM32 MCU, and ZigBee hardware configuration
Input parameter {x} None
Output parameter {x} None
Return value None
In-home display firmware AN3311
30/58 Doc ID 18209 Rev 1
This function is intended to initialize the hardware peripherals of the STM32 MCU, and the ZigBee hardware configuration.
Example:
static void prvSetupHardware( void ){ SystemInit();
/* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE and AFIO clocks */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE );
/* Set the Vector Table base address at 0x08000000 */ NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 );
NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );
/* Configure HCLK clock as SysTick clock source. */ SysTick_CLKSourceConfig( SysTick_CLKSource_HCLK ); /* Initialize the board */ vBoardInit(); EZSP_Init(); //init OBJ Coordinator }
6.2.5 vBoardInit
Table 15 describes the vBoardInit function:
This function is intended to initialize the hardware peripheral of the STM3210C-EVAL board and the graphic library hardware parameters.
Regarding the file menu.c, it just uses the API function of the graphic library and some others of the “ZigBee stack for smartplug”, for more information please refer to the AN3128, rev. 2, application note.
Required preconditions None
Called functions No API/HAL layer functions;
Table 14. prvSetupHardware function (continued)
Table 15. vBoardInit function
Function name vBoardInit
Function prototype void vBoardInit (void)
Behavior description Initialize the hardware peripheral of the STM3210C-EVAL board
Input parameter {x} None
Output parameter {x} None
Return value None
Required preconditions None
Called functions No API/HAL layer functions;
AN3311 Getting started with the system
Doc ID 18209 Rev 1 31/58
7 Getting started with the system
7.1 Configure IAR tool for building, debugging, and programming the applicationTogether with the firmware library package, an example application is delivered in order to provide the final user with a real example of “In-home display” application usage.
The delivered example application has been written and developed using IAR EWARM 5.40 IDE and can be built for both STM32F10xxx medium-density and high-density microcontroller families.
The workspace is created using the IAR embedded Workbench 5.40 IDE, using the ARM®-based 32-bit STM32F10xx firmware library (ver. 3.1.2) CMSIS compliant, and in C language.
The tree structure of the project is organized separating and grouping the source files with the header files, both for the project files and the library files, as shown in Figure 10.
Figure 10. Application project files
In order to load the project, click on File\Open\Workspace and in the window that appears select, in \project folder\EWARM, the file “Project.eww”.
Getting started with the system AN3311
32/58 Doc ID 18209 Rev 1
Figure 11. IAR embedded workbench main window
On the main node, where the program name located in the files window is shown, right click the mouse button and select options. In the window which appears, select the debugger item in the category list box, and select the proper debugging tool in the driver list box, then press the Ok button. In the proposed example the J-Link dongle is used (Figure 12).
Press the Make icon or click on Project\Rebuild All. No error or warning should appear once compiling has completed. Connect the J-Link tool to the USB port of the PC, and connect the flat cable with the programming adapter. Plug the adapter into the dongle connector. Press the debug icon, CTRL+D or click project\debug. The debugger starts to download the firmware to the dongle through the J-Link debugger\programmer. Press the Go button, F5 or click debug\go in order to execute the firmware in debug mode. To run the dongle in standalone mode, press the stop debugging icon, CTRL+SHIFT+D or click debug\stop debugging. Then remove the J-link adapter from the dongle and reset the board by unplugging and plugging the power cable back in.
Figure 12. IAR embedded workbench debugger options
AN3311 Getting started with the system
Doc ID 18209 Rev 1 33/58
In order to use the In-home display application project, it is necessary to:
● Include all the firmware delivered in the In-home display package containing the FreeRTOS core files. See Figure 10
● Create the desired menu application functions in the file menu.c
● Put inside “picture.c” the HEX dump of the pictures to be used with the application GUI
● Implement a main function as described in the following section.
7.2 Example application - main.cAn example of a main application is given below. The main function contains an example of the In-home display application initialization/configuration and implements the classic operations: /* Standard includes. */#include <stdio.h>
/* Scheduler includes. */#include "FreeRTOS.h"#include "task.h"#include "queue.h"#include "semphr.h"
/* Library includes. */#include "stm32f10x.h"#include "stm32f10x_it.h"#include "STM3210c_eval_lcd.h"#include "LcdHal.h" //SB
/* Demo app includes. */#include "flash.h"#include "partest.h"#include "common.h"#include "micro_clocks_irqs.h"#include "micro.h"
#include "menu.h"#include "graphicObject.h"#include "cursor.h"#include "stm32d-eval_io_expander.h"#include "LcdHal.h"#include "TscHal.h"#include "pictures.h" #include "stm32f10x.h"#include "stm32f10x_rcc.h"#include "misc.h"#include "SmartPlugObj.h"#include "CoordinatorObj.h"#include "COORDINATOR_Layer.h"#include "ZSP_Layer.h"
#ifdef USE_STM3210E_EVAL #include "stm3210e_eval_lcd.h"#elif USE_STM3210C_EVAL #include "stm3210c_eval_lcd.h" #include "touchscreen.h"#endif
/* Private define ------------------------------------------------------------*/
Getting started with the system AN3311
34/58 Doc ID 18209 Rev 1
/* Touchscreen Controller and Joystick DEFINES */#define TSC_GPIO_PORT_SOURCE GPIO_PortSourceGPIOB#define TSC_GPIO_PIN_SOURCE GPIO_PinSource14#define JOY_GPIO_PORT_SOURCE GPIO_PortSourceGPIOB#define JOY_GPIO_PIN_SOURCE GPIO_PinSource14#define JOY_GPIO_SELECT_PORT GPIOG#define JOY_GPIO_SELECT_PIN GPIO_Pin_7#define JOY_GPIO_RIGHT_PORT GPIOG#define JOY_GPIO_RIGHT_PIN GPIO_Pin_13#define JOY_GPIO_LEFT_PORT GPIOG#define JOY_GPIO_LEFT_PIN GPIO_Pin_14#define JOY_GPIO_UP_PORT GPIOG#define JOY_GPIO_UP_PIN GPIO_Pin_15#define JOY_GPIO_DOWN_PORT GPIOD#define JOY_GPIO_DOWN_PIN GPIO_Pin_3#define JOY_GPIO_RCC_APB_PERIPH1 RCC_APB2Periph_GPIOG#define JOY_GPIO_RCC_APB_PERIPH2 RCC_APB2Periph_GPIOG#define JOY_GPIO_RCC_APB_PERIPH3 RCC_APB2Periph_GPIOG#define JOY_GPIO_RCC_APB_PERIPH4 RCC_APB2Periph_GPIOG#define JOY_GPIO_RCC_APB_PERIPH5 RCC_APB2Periph_GPIOD#define TSC_EXTI_IRQ_CHANNEL EXTI15_10_IRQn#define JOY_EXTI_IRQ_CHANNEL EXTI15_10_IRQn#define TSC_EXTI_LINE EXTI_Line14#define JOY_EXTI_LINE EXTI_Line14#define TSC_GPIO_PORT GPIOA#define TSC_GPIO_PIN GPIO_Pin_14#define TSC_I2C_DEVICE_REGISTER 0x82#define JOY_I2C_DEVICE_REGISTER 0x88#define M24LR64_I2C_DEVICE_REGISTER 0x24#define TSC_I2C_PORT I2C1
/* User Button GPIO Port and Pin*/#ifdef USE_STM3210C_EVAL #define USER_BUTTON_PORT GPIOB #define USER_BUTTON_PIN GPIO_Pin_9#elif USE_STM3210E_EVAL #define USER_BUTTON_PORT GPIOG #define USER_BUTTON_PIN GPIO_Pin_8#endif
/* LCD Controller DEFINES */#define LCD_CTRL_PORT_NCS GPIOB#define LCD_GPIO_DATA_PORT GPIOC#define LCD_CTRL_PIN_NCS GPIO_Pin_2#define LCD_CTRL_PIN_NWR GPIO_Pin_15#define LCD_CTRL_PIN_RS GPIO_Pin_7#define LCD_GPIO_PIN_SCK GPIO_Pin_10#define LCD_GPIO_PIN_MISO GPIO_Pin_11#define LCD_GPIO_PIN_MOSI GPIO_Pin_12#define LCD_GPIO_RCC_APB_PERIPH RCC_APB2Periph_GPIOC#define LCD_GPIO_RCC_APB_PERIPH_NCS RCC_APB2Periph_GPIOB#define LCD_GPIO_REMAP_PORT GPIO_Remap_SPI3#define LCD_RCC_APB_PERIPH RCC_APB1Periph_SPI3#define LCD_RCC_AHB_PERIPH RCC_AHBPeriph_FSMC#define LCD_SPI_PORT SPI3
#ifdef USE_STM3210C_EVAL #define LCD_CONNECTION_MODE GL_SPI#elif USE_STM3210E_EVAL #define LCD_CONNECTION_MODE GL_FSMC#endif
#define RCC_AHBPeriph_FSMC ((uint32_t)0x00000100)
AN3311 Getting started with the system
Doc ID 18209 Rev 1 35/58
/* Exported variables--------------------------------------------------------*/LCD_HW_Parameters_TypeDef* pLcdParam;TSC_HW_Parameters_TypeDef* pTscParam;JOY_HW_Parameters_TypeDef* pJoyParam;BTN_HW_Parameters_TypeDef* pBtnParam;extern volatile GL_u8 touch_done;GL_s16 smart_points1[N_SAMPLES];GL_s16 smart_points1B[N_SAMPLES];GL_s16 smart_points2[N_SAMPLES];GL_s16 smart_points2B[N_SAMPLES];SmartPlugType** ppSmartPlugList;SmartPlugType* pCurrentSmartPlug;extern GL_Page_TypeDef pageS2B;extern GL_Page_TypeDef pageS2C;
/* Private macro -------------------------------------------------------------*//* Private variables ---------------------------------------------------------*/static volatile ErrorStatus HSEStartUpStatus /*= SUCCESS*/;volatile GL_u8 restart_calibration = 0;GPIO_InitTypeDef GPIO_InitStructure;static u32 TimingDelay;static xTaskHandle xEmberTaskHandle, xApplTaskHandle, xSmartSamplingTaskHandle, xGraphLibTaskHandle;
/* The time between cycles of the 'check' functionality (defined within the tick hook. */#define mainCHECK_DELAY ( ( portTickType ) 5000 / portTICK_RATE_MS )
/* Task priorities. */#define EMBER_Task ( tskIDLE_PRIORITY + 3 )#define APPLICATION_Tick_Task ( tskIDLE_PRIORITY + 2 )#define mainINIT_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
/* The period of the system clock in nano seconds. This is used to calculate the jitter time in nano seconds. */#define mainNS_PER_CLOCK ((unsigned portLONG)((1.0 / (double)configCPU_CLOCK_HZ)*1000000000.0))
/*-----------------------------------------------------------*/
/* Configure the hardware for the demo. */static void prvSetupHardware( void );static void vEmberTickTask( void *pvParameters );extern void EZSPInit(void);
static void prvApplicationTask( void * pvParameters );void vApplication_EXIT2_ISRFunc( void );void vApplication_USART0_ISRFunc( void );
/* Configure the hardware for the demo. */static void prvSetupHardware( void );
/* Configure the board, LCD, Joystick, Button, GPIO and other peripherals as required by the demo. */static void vBoardInit( void );
/* Check Touchscreen, Joystick, Button in polling mode as required by the demo. */static void vGraphicLibraryTask(void *pvParameters);
/* Check the SmartPlug Energy data as required by the demo. */static void vSmartPlugSamplingTask( void *pvParameters);
Getting started with the system AN3311
36/58 Doc ID 18209 Rev 1
/* * Configures the high frequency timers - those used to measure the timing * jitter while the real time kernel is executing. */extern void vSetupHighFrequencyTimer( void );
u16 ticksSinceLastHeard[APPLICATION_ADDRESS_TABLE_SIZE];EmberNetworkStatus networkState = EMBER_NO_NETWORK;
/* insert Start */xSemaphoreHandle xSemaphore_Ember = NULL;xSemaphoreHandle xSemaphore_Serial = NULL;extern void EZSP_Init(void);extern void emberTick(void);extern void processSerialInput(void);extern void applicationTick(void);/* insert End *//*-------------------------*/
int main( void ){#ifdef DEBUG debug();#endif pLcdParam = NewLcdHwParamObj (); pTscParam = NewTscHwParamObj (); pJoyParam = NewJoyHwParamObj (); pBtnParam = NewBtnHwParamObj ();
prvSetupHardware(); /* Start the tasks. FreeRTOS API. */ xTaskCreate( vEmberTickTask, "EMBER", configMINIMAL_STACK_SIZE, NULL, EMBER_Task, xEmberTaskHandle ); xTaskCreate( vSmartPlugSamplingTask, ( signed portCHAR * ) "SmartPlugSampling", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, xSmartSamplingTaskHandle ); xTaskCreate( vGraphicLibraryTask, ( signed portCHAR * ) "GraphicLibrary", configMINIMAL_STACK_SIZE*2, NULL, tskIDLE_PRIORITY+1, xGraphLibTaskHandle ); /* Start the scheduler. */ vTaskStartScheduler(); // emberLeaveNetwork(); /* Will only get here if there was insufficient memory to create the idle task. The idle task is created within vTaskStartScheduler(). */ for( ;; );}
The initialization process is charged with preparing the basic mechanism of the system:
● Hardware peripheral configuration and initialization
● ZigBee stack initialization
● FreeRTOS task creation
● Starting system.
AN3311 Getting started with the system
Doc ID 18209 Rev 1 37/58
The clock distribution and the interrupt settings are two components that are strongly dependent on the target project. An example of clock rate may be 72 MHz as the maximum speed of the current STM32 microcontroller. It can be decreased to reduce the power consumption. The clock rate assumptions are:
● System HCLK - 72 MHz
● Low speed peripheral PCLK1 - 72 MHz
● High speed peripheral PCLK2 - 36 MHz
● Analog to digital converter ADCCLK - 36 MHz
The interrupt setting situation is very similar to clock distribution. The library functions involved with interrupt managing do not take the priorities into account; they only perform very necessary and absolutely common settings to make them serviceable.
In-home display GUI application AN3311
38/58 Doc ID 18209 Rev 1
8 In-home display GUI application
If the ZigBee dongle is not connected or the resistors R79, R84, and R169 have not been removed from the STM3210C-EVAL, the following screen is shown:
Figure 13. ZigBee dongle connection problem
After a board reset, if the firmware is correctly loaded into the Flash memory and the board power is correctly supplied, the main screen is displayed as shown in Figure 14.
Figure 14. Main menu
AN3311 In-home display GUI application
Doc ID 18209 Rev 1 39/58
If Search Plugs is selected, the coordinator scans for smartplug devices for a certain length of time and the display shows the following screens in loop:
Figure 15. Searching plugs
After that, if some plugs are connected, it adds them to the smartplug list and then shows the home screen.
In-home display GUI application AN3311
40/58 Doc ID 18209 Rev 1
If you click on Management two situations are possible:
● If no plug is connected to the smartplug coordinator, the following screen is shown:
Figure 16. No plug detected
● Once more plugs are detected, the following screen is shown:
Figure 17. Plugs detected
There are three main buttons: identify, modify, and control. They allow to manage the smartplug device.
The Identify button is useful to activate the LED flashing on the relative plug, so this way the user can easily identify which plug they are going to manage through the GUI.
If Modify is clicked, the user can change the label of the selected plug, through the screen shown in Figure 18, choosing the new label from a list contained in a combobox.
AN3311 In-home display GUI application
Doc ID 18209 Rev 1 41/58
Figure 18. Label changing
The user should scroll the list of the labels and click on the Apply button in order to save the information and set the label also in the plug device via ZigBee protocol.
When Control is clicked, it is possible to switch ON/OFF the smartplug, in case of relay type, or regulate the output power, in case of TRIAC type. The following screens show both possibilities:
Figure 19. TRIAC smartplug management
In-home display GUI application AN3311
42/58 Doc ID 18209 Rev 1
Figure 20. Relay smartplug management
In the home screen, by clicking on Statistics, it is possible to see the electrical consumption of the single smartplug device or the total consumption related to all plugs connected to the smartplug coordinator. The following screen is shown:
Figure 21. Smartplug statistics
AN3311 In-home display GUI application
Doc ID 18209 Rev 1 43/58
When Energy is clicked, the following screen, representing the energy consumption of the selected smartplug device, is shown:
Figure 22. Energy consumption
When Global Energy is clicked, the following screen, representing the energy consumption of the whole smartplug network, is shown:
Figure 23. Global energy consumption
In-home display GUI application AN3311
44/58 Doc ID 18209 Rev 1
When Power is clicked, the following screen, representing the power consumption of the selected smartplug device, is shown:
Figure 24. Power consumption
When Global Power is clicked, the following screen, representing the power consumption of the whole smartplug network, is shown:
Figure 25. Global power consumption
When the Refresh button is clicked, it is possible to make a refresh of the graph chart in relation to the sampled points of the power consumption.
When the Home button is clicked, it returns to the home screen.
AN3311 Schematics
Doc ID 18209 Rev 1 45/58
9 Schematics
9.1 Smartplug board schematics and layout
Figure 26. ZigBee and dual interface EEPROM adapter schematic for STM3210C-EVAL
AM08515v1
GN
D
ZIG
_SC
LK
ZIG
_MO
SI
ZIG
_WA
KE
ZIG
_RS
TBG
ND
ZIG
_MIS
O
GN
D
3V3
ZIG
_MIS
O
SS_
GIZS
S_GIZ
ZIG
_MO
SI
ZIG
_SC
LK
VC
C-G
PIO
I2C
1_S
DA
I2C
1_S
DA
I2C
1_S
CK
I2C
1_S
CK
GN
DE0
E1
ZIG
_HO
ST_
INT G
ND
VC
C-G
PIO
GN
D
VC
C_3
V3
VC
C_3
V3
VC
C_3
V3
VC
C_3
V3
VC
C_3
V3
VC
C_3
V3
VBRD
VBRD
MOSI
MISO
SCLK
nSSE
L
HOST
_INT
WAKE
RSTB
ZIG
BE
E/S
PZ
B2
60
-PR
O
PA
6 (S
PI1
_MIS
O) -
Rem
ove
R79 48
R ev ome
R - )KL
C_1IP
S( 5A
P96 1
R e vome
R - )IS
OM_1I
PS( 7
AP P
A4
(SP
I1_N
SS
) - K
eep
JP15
ope
nP
E5
PE
3
PE
6
Prio
r to
usin
g th
is a
dapt
er, r
emov
e th
e re
quire
dre
sist
ance
from
the
STM
3210
C-E
val B
oard
PE
4
SM
D 7
.8m
m d
iam
eter
, 5.3
mm
hei
ght
R3
4k7
R3
4k7
J2
ZigB
ee -
CO
NN
1
J2
ZigB
ee -
CO
NN
1
1 2 3 4 5 6
R2
4k7
R2
4k7
JP2
Jum
per
JP2
Jum
per 2
31
JP1
Jum
per JP
1
Jum
per
231
R1
4k7
R1
4k7
CN
8
Hea
der 2
5x2
(Fem
ale-
Bot
tom
)
CN
8
Hea
der 2
5x2
(Fem
ale-
Bot
tom
)
12
34
56
78
910
1112
1314
1516
1718
1920
2122
2324
2526
2728
2930
3132
3334
3536
3738
3940
4142
4344
4546
4748
4950
L14.
7uH
L14.
7uH
U1
M24
LR64
U1
M24
LR64
E0
1
AC
02
AC
13
E1
7
SD
A5
SC
L6
VC
C8
VS
S4
J4
ZigB
ee -
CO
NN
2
J4
ZigB
ee -
CO
NN
2
1 2 3 4 5 6
CN
9
Hea
der 2
5x2
(Fem
ale-
Bot
tom
)
CN
9
Hea
der 2
5x2
(Fem
ale-
Bot
tom
)
12
34
56
78
910
1112
1314
1516
1718
1920
2122
2324
2526
2728
2930
3132
3334
3536
3738
3940
4142
4344
4546
4748
4950
Schematics AN3311
46/58 Doc ID 18209 Rev 1
9.2 ZigBee/RF adapter for smartplug and dual interface memory
Figure 27. ZigBee and dual interface EEPROM adapter layout for STM3210C-EVAL
AN3311 Schematics
Doc ID 18209 Rev 1 47/58
9.3 STM3210C
Figure 28. STM3210C main schematic
AM08494v1
I2S_
CMD
I2S_
DIN
I2S_
CKA
udio
_SCK
Aud
io_S
DA
Aud
io_R
ST
I2S_
MCK
Aud
io_D
AC_
OU
T
U_A
udio
Aud
io.S
chD
oc
CAN
1_TX
CAN
1_RX
CAN
2_TX
CAN
2_RX
U_C
AN
CAN
.Sch
Doc
MII_
TXD
0
MII_
TX_E
N
MII_
TX_C
LK
MII_
RXD
0
MII_
RX_E
RM
II_RX
_DV/
RMII_
CRSD
VM
II_RX
_CLK
/RM
II_RE
F_CL
K
MII_
COL
MII_
CRS
MII_
MD
CM
II_M
DIO
MCO
PHY_
RESE
T#
MII_
TXD
1M
II_TX
D2
MII_
TXD
3
MII_
RXD
1M
II_RX
D2
MII_
RXD
3
MII_
INT
U_E
ther
net
Ethe
rnet
.Sch
Doc
PA[0
..15]
PB[0
..15]
PC[0
..15]
PD[0
..15]
PE[0
..15]
RESE
T#
U_E
xten
sion
Conn
ecto
rEx
tens
ionC
onne
ctor
.Sch
Doc
BNC1
BNC2
LED
4LE
D3
LED
1LE
D2
Pote
ntio
met
er
JOY_
SEL
JOY_
DO
WN
JOY_
LEFT
JOY_
RIG
HT
JOY_
UP
Ant
i_Ta
mpe
rW
AKE
UP
Use
r_Bu
tton
EEPR
OM
_SCK
EEPR
OM
_SD
AM
EMS_
SCK
MEM
S_SD
AM
EMS_
INT1
MEM
S_IN
T2
U_I
O P
erip
hera
lsIO
Per
iphe
rals
.Sch
Doc
TDI
RESE
T#
TRA
CE_D
3TR
ACE
_D2
TRA
CE_D
1TR
ACE
_D0
TRA
CE_C
K
TRST
TMS/
SWD
IOTC
K/SW
CLK
TDO
/SW
O
U_J
TAG
&Tr
ace
JTA
G&
Trac
e.Sc
hDoc
LCD
_CS
LCD
_CLK
LCD
_DO
LCD
_DI
RESE
T#To
uchS
cree
n_X+
Touc
hScr
een_
X-To
uchS
cree
n_Y+
Touc
hScr
een_
Y-
U_L
CDLC
D.S
chD
oc
USB
_Pow
erSw
itchO
n
USB
_VBU
S
USB
_DM
USB
_DP
USB
_ID
MII_
TX_E
N
MII_
TX_C
LK
MII_
RX_E
RM
II_RX
_DV/
RMII_
CRSD
V
MII_
COL
MII_
CRS
MII_
MD
CM
II_M
DIO
IO_E
xpan
der_
INT
CAN
1_TX
CAN
1_RX
CAN
2_TX
CAN
2_RX
USA
RT2_
TXU
SART
2_RX
Smar
tCar
d_3/
5VSm
artC
ard_
IOSm
artC
ard_
RST
Smar
tCar
d_CL
K
Smar
tCar
d_O
FF
Smar
tCar
d_CM
DVC
C
I2S_
CMD
I2S_
DIN
I2S_
CK
I2C1
_SCK
I2C1
_SD
A
I2S_
MCK
MC_
WL
MC_
VHM
C_VL
MC_
UH
MC_
UL
MC_
WH
MC_
NTC
MC_
Dis
sipa
tiveB
rake
MC_
PFCp
wm
MC_
EnA
MC_
EnB
MC_
Hea
tsin
kTem
pera
ture
MC_
BusV
olta
geM
C_En
Inde
x
MC_
Emer
genc
ySTO
PM
C_Cu
rren
tAM
C_Cu
rren
tBM
C_Cu
rren
tC
MC_
PFCs
ync1
MC_
PFCs
ync2
LCD
_CS
RESE
T#
LED
4LE
D3
LED
1LE
D2
Pote
ntio
met
erA
nti_
Tam
per
WA
KEU
PU
ser_
Butt
on
TDI
TRA
CE_D
3TR
ACE
_D2
TRA
CE_D
1TR
ACE
_D0
TRA
CE_C
K
TRST
TMS/
SWD
IOTC
K/SW
CLK
TDO
/SW
O
IDD
_Mea
sure
men
t
IDD
_CN
T_EN
VBA
T_Vo
ltage
_OU
T
SPI3
_SCK
SPI3
_MIS
O
SPI3
_MO
SI
Mic
roSD
Card
_CS
USB
_Ove
rCur
rent
Mic
roSD
Card
_Det
ectio
n
PA[0
..15]
PB[0
..15]
PC[0
..15]
PD[0
..15]
PE[0
..15]
MII_
TXD
0
MII_
RXD
0
MII_
TXD
1M
II_TX
D2
MII_
TXD
3
MII_
RXD
1M
II_RX
D2
MII_
RXD
3
MII_
RX_C
LK/R
MII_
REF_
CLK
MCO
Boot
load
er_R
ESET
Boot
load
er_B
OO
T0
Aud
io_D
AC_
OU
T
U_M
CUM
CU.S
chD
oc
Mic
roSD
Card
_SCK
Mic
roSD
Card
_MIS
O
Mic
roSD
Card
_MO
SIM
icro
SDCa
rd_C
SM
icro
SDCa
rd_D
etec
tion
U_M
icro
SDCa
rdM
icro
SDCa
rd.S
chD
oc
MC_
Emer
genc
ySTO
PM
C_Cu
rren
tAM
C_Cu
rren
tBM
C_Cu
rren
tC
MC_
PFCs
ync1
MC_
PFCs
ync2
MC_
WL
MC_
VHM
C_VL
MC_
UH
MC_
UL
MC_
WH
MC_
NTC
MC_
Dis
sipa
tiveB
rake
MC_
PFCp
wm
MC_
EnA
MC_
EnB
MC_
Hea
tsin
kTem
pera
ture
MC_
BusV
olta
geM
C_En
Inde
x
BNC1
BNC2
U_M
otor
Cont
rol
Mot
orCo
ntro
l.Sch
Doc
IDD
_Mea
sure
men
t
IDD
_CN
T_EN
VBA
T_Vo
ltage
LP_W
AKE
UP
VBA
T_D
IVU
SB_V
BUS
U_P
ower
Pow
er.S
chD
oc
Smar
tCar
d_3/
5VSm
artC
ard_
IOSm
artC
ard_
RST
Smar
tCar
d_CL
K
Smar
tCar
d_O
FF
Smar
tCar
d_CM
DVC
C
U_S
mar
tCar
dSm
artC
ard.
SchD
oc
RS23
2/IrD
A_T
XRS
232/
IrDA
_RX
Boot
load
er_R
ESET
Boot
load
er_B
OO
T0
U_U
SART
&IrD
AU
SART
&IrD
A.S
chD
oc
USB
_Pow
erSw
itchO
n
USB
_Ove
rCur
rent
USB
_VBU
S
USB
_DM
USB
_DP
USB
_ID
U_U
SB_O
TG_F
SU
SB_O
TG_F
S.Sc
hDoc
IO_E
xpan
der_
SCK
IO_E
xpan
der_
SDA
IO_E
xpan
der_
INT To
uchS
cree
n_X+
Touc
hScr
een_
X-To
uchS
cree
n_Y+
Touc
hScr
een_
Y-
EXP_
IO2
EXP_
IO3
EXP_
IO4
EXP_
IO5
EXP_
IO6
EXP_
IO7
EXP_
IO8
EXP_
IO9
EXP_
IO10
EXP_
IO11
EXP_
IO12
EXP_
IO1
U_I
O_E
xpan
der
IO_E
xpan
dor.S
chD
oc
R132
0R1
310
R134
4K7
R133
4K7
+3V3
Schematics AN3311
48/58 Doc ID 18209 Rev 1
9.4 MCU
Figure 29. MCU schematic
AM08495v1
PE2
1PE
32
PE4
3PE
54
PE6
5
PC13
-AN
TI_T
AM
P7
PC14
-OSC
32_I
N8
PC15
-OSC
32_O
UT
9
OSC
_IN
12
OSC
_OU
T13
NRS
T14
PC0
15PC
116
PC2
17PC
318
PA0-
WKU
P23
PA1
24
PA2
25
PA3
26
PA4
29
PA5
30
PA6
31
PA7
32
PC4
33PC
534
PB0
35
PB1
36
PB2
37
PE7
38PE
839
PE9
40PE
1041
PE11
42PE
1243
PE13
44PE
1445
PE15
46
PB10
47
PB11
48
PB12
51
PB13
52
PB14
53
PB15
54
PD8
55PD
956
PD10
57PD
1158
PD12
59PD
1360
PD14
61PD
1562
PC6
63PC
764
PC8
65PC
966
PA8
67
PA9
68
PA10
69
PA11
70
PA12
71
PA13
72
NC
73
PA14
76
PA15
77
PC10
78PC
1179
PC12
80
PD0
81PD
182
PD2
83PD
384
PD4
85PD
586
PD6
87PD
788
PB3
89
PB4
90
PB5
91
PB6
92
PB7
93
BOO
T094
PB8
95
PB9
96
PE0
97PE
198
U9A
STM
32F1
07VC
T
USB
_Pow
erSw
itchO
n
USB
_VBU
S
USB
_DM
USB
_DP
USB
_ID
MII_
TX_E
N
MII_
TX_C
LK
MII_
RX_E
R
MII_
RX_D
V/RM
II_CR
SDV
MII_
COL
MII_
CRS
MII_
MD
C
MII_
MD
IO
IO_E
xpan
der_
INT
CAN
1_TX
CAN
1_RX
CAN
2_TX
CAN
2_RX
USA
RT2_
TXU
SART
2_RX
Smar
tCar
d_3/
5V
Smar
tCar
d_IO
Smar
tCar
d_RS
T
Smar
tCar
d_CL
K
Smar
tCar
d_O
FF
Smar
tCar
d_CM
DVC
C
I2S_
CMD
I2S_
DIN
I2S_
CK
I2C1
_SCK
I2C1
_SD
A
I2S_
MCK
MC_
WL
MC_
VHM
C_VL
MC_
UH
MC_
UL
MC_
WH
MC_
NTC
MC_
Dis
sipa
tiveB
rake
MC_
PFCp
wm
MC_
EnA
MC_
EnB
MC_
Hea
tsin
kTem
pera
ture
MC_
BusV
olta
ge
MC_
EnIn
dex
MC_
Emer
genc
ySTO
P
MC_
Curr
entA
MC_
Curr
entB
MC_
Curr
entC
MC_
PFCs
ync1
MC_
PFCs
ync2
LCD
_CS
LED
4LE
D3
LED
1
LED
2
Pote
ntio
met
er
Ant
i_Ta
mpe
r
WA
KEU
P
Use
r_Bu
tton
TDI
TRA
CE_D
3TR
ACE
_D2
TRA
CE_D
1TR
ACE
_D0
TRA
CE_C
K
TRST
TMS/
SWD
IOTC
K/SW
CLK
TDO
/SW
O
IDD
_CN
T_EN
VBA
T_Vo
ltage
_OU
T
SPI3
_SCK
SPI3
_MIS
OSP
I3_M
OSI
Mic
roSD
Card
_CS
PE0
PE1
PE2
PE3
PE4
PE5
PE6
PE7
PE8
PE9
PE10
PE11
PE12
PE13
PE14
PE15
PC0
PC1
PC2
PC3
PC4
PC5
PC6
PC7
PC8
PC9
PC10
PC11
PC12
PC13
USB
_Ove
rCur
rent
Mic
roSD
Card
_Det
ectio
n
PA[0
..15]
PA[0
..15]
PB[0
..15]
PB[0
..15]
PC[0
..15]
PC[0
..15]
PD[0
..15]
PD[0
..15]
PE[0
..15]
PE[0
..15]
MII_
TXD
0M
II_RX
D0
MII_
TXD
1
MII_
TXD
2
MII_
TXD
3
MII_
RXD
1M
II_RX
D2
MII_
RXD
3
MII_
RX_C
LK/R
MII_
REF_
CLK M
CO
1 432
B1 RESE
T
R62
[N/A
]+3V3
C15
100n
F
C19
20pFC1
820
pF
X3 25M
Hz
(with
soc
ket)
R63
220
R61
10K
+3V3
23
1
SW2
09.0
3290
.01
RESE
T#
R60
10K
+3V3
231
SW1
09.0
3290
.01
32
1
JP14
41
32
X2 MC3
06-G
-06Q
-32.
768
(man
ufac
ture
r JFV
NY)
C17
10pF
C16
10pF
R59
0
PC14
PC15
Jum
per c
onfig
urat
ion:
def
ault
set/
feat
ure e
nabl
ed
a
noth
er se
t/ fe
atur
e ena
bled
====
====
====
====
====
====
====
====
====
====
====
====
==JP
1:
2
<->3
/ A
nti_
Tem
per
1
<->2
/ M
CU c
urre
nt m
easu
rem
ent
JP9:
clo
se /
I2C
dev
ice
op
en /
CAN
2JP
10:
1<
->2
/ I2S
Aud
io
2<-
>3 /
MC
JP11
:
2<->
3 / E
ther
net
1
<->2
/ Sm
artc
ard
JP12
:
2<->
3 / E
ther
net
1
<->2
/ Sm
artc
ard
JP13
:
2<->
3 / E
ther
net
1
<->2
/ Sm
artc
ard
JP14
:
1<->
2 / E
ther
net
2
<->3
/ W
KUP
& M
CJP
15:
cl
ose
/ SD
card
CS
o
pen /
out
put fo
r aud
io D
AC
JP18
:
open
/ BL_
Boot
0 d
isab
led
c
lose
/ BL
_Boo
t0JP
19:
op
en/ B
L_Re
set
disa
bled
clo
se /
BL_R
eset
PA0
PA1
PA2
PA3
PA4
PA5
PA6
PA7
PA8
PA9
PA10
PA11
PA12
PA13
PA14
PA15
PB0
PB1
PB2
PB3
PB4
PB5
PB6
PB7
PB8
PB9
PB10
PB11
PB12
PB13
PB14
0DP
51BP
PD1
PD2
PD3
PD4
PD5
PD6
PD7
PD8
PD9
PD10
PD11
PD12
PD13
PD14
PD15
32
1
JP1
R161
0
TP4
PTP_
PPS
R165
0
IDD
_Mea
sure
men
t
Boot
load
er_B
OO
T0
Boot
load
er_R
ESET
D1
1N41
48
D2
1N41
48
32
1
JP10
32
1
JP11 3
21
JP12 3
21
JP13
JP9
R78
0
JP15
Aud
io_D
AC_
OU
T
JP18
JP19
JP26
TP6
MCO
AN3311 Schematics
Doc ID 18209 Rev 1 49/58
9.5 LCD
Figure 30. LCD schematic
AM08496v1
LCD_CS
LCD_CLK
LCD_DOLCD_DI
RESET#
TouchScreen_X+TouchScreen_X-
TouchScreen_Y+TouchScreen_Y-
CS1
RS2
WR/SCL3
RD4
RESET5
VDD24
VCI25
GND26
GND27
BL_VDD28
BL_Control23 BL_GND22
PD1 6
PD2 7
PD3 8
PD4 9
PD5 10
PD6 11
PD7 12
PD8 13
PD10 14
PD11 15
PD12 16
PD13 17
PD14 18
PD15 19
PD16 20
PD17 21
SDO29
SDI30 XL 31
XR 32
YD 33
YU 34
CN14
3.2" LCD_connector (MB785 with AM-240320D4TOQW-T00H(R))
CS1
SCL2
SDI3
RS4
WR5
RD6
RESET8
VDD9
VCI10
SDO7
GND11
GND12
BL_VDD13
BL_Control14
BL_GND15
BL_GND16
CN15
2.4" LCD connector (MB542 with AM240320L8TNQW-00H)
+3V3
+3V3
+5V
+3V3+5V
PB2
PC10
PC11PC12
To IO expandor
Schematics AN3311
50/58 Doc ID 18209 Rev 1
9.6 I/O expander
Figure 31. I/O expander schematic
AM08497v1
Y- 1
INT2
A0/Data Out3
SCLK4
SDAT5
VCC6
Data in7
IN0 8IN1 9
GND10
IN2 11IN3 12X+ 13
Vio14
Y+ 15X- 16
U7
STMPE811
Y- 1
INT2
A0/Data Out3
SCLK4
SDAT5
VCC6
Data in7
IN0 8IN1 9
GND10
IN2 11IN3 12X+ 13
Vio14
Y+ 15X- 16
U8
STMPE811R5610K
+3V3
I2C device address:0x82
I2C device address:0x88
+3V3
+3V3
R57100K
R58100K
IO_Expander_SCKIO_Expander_SDAIO_Expander_INT
TouchScreen_X+
TouchScreen_X-TouchScreen_Y+
TouchScreen_Y-
EXP_IO2EXP_IO3EXP_IO4EXP_IO5EXP_IO6EXP_IO7EXP_IO8
EXP_IO9EXP_IO10EXP_IO11EXP_IO12
EXP_IO1
R16010K
R159 0
+3V3
R3710K
R16410K
+3V3
C89100nF
C90100nF
PB6PB7PB14
AN
3311S
chem
atics
Doc ID
18209 Rev 1
51/58
9.7 I/O peripherals
Figure 32. I/O peripherals
AM08516v1
R90
10K
R91
10K
R92
10K
R93
10K
R89
10K
+3V3
C56
100n
F
C55
100n
F
C54
100n
F
C53
100n
F
C52
100n
F
R108
100COMMON5
Selection2
DWON3
LEFT1
RIGHT4
UP6
U15
MT008-A
R102 0R101 0R100 0R99 0R98 0JOY_SEL
JOY_DOWNJOY_LEFTJOY_RIGHTJOY_UP
To IO expander
1 2
LD3Red
1 2
LD2Orange
1 2
LD4Blue
1 2
LD1Green
R94
330
R95
680
R96
680
R97
680LED4
LED3
LED1
LED2
PD7
PD13
PD3
PD4
12345
CN10VB334
BNC1
12345
CN11VB334
BNC2
SB4
R112 50
R113 50
SB3
PA7PB0
EEPROM_SCKEEPROM_SDA
E01
E12
E23
VSS4 SDA 5SCL 6WC 7VCC 8U17
M24C64-WMN6
+3V3
R10710K
JP17
C91
100nF
PB6PB7
MEMS_SCKMEMS_SDA
MEMS_INT1MEMS_INT2
VDD_IO1
GND 2Reserved3
GND 4GND 5
VDD6 CS 7
INT18
INT29
GND 10
Reserved 11
SDO 12
SDA13
SCL14
U16
LIS302DL
+3V3R10610K
+3V3
C92
100nFPB7PB6
To IO expander
R117220K
143 2
B2WKUPC59
[N/A]
+3V3
R109
100R1144K7
1 432
B3USER C57
100nF
+3V3
R110
100
R1154K7
1 432
B4Tamper C58
100nF
+3V3
R111
100
R116
330
R104
0R1050Anti_Tamper
WAKEUP
User_Button 31CP9BP
PA0
13
2 RV110K
R103
0
+3V3
Potentiometer
C6010nF
PC4 R86
1K
Joystick
LEDs
BNC
EEPROM
MEMS
Button
Potentiometer
Schematics AN3311
52/58 Doc ID 18209 Rev 1
9.8 Extension connector
Figure 33. Extension connector
AM08505v1
R88820R87820
1 23 45 67 89 1011 1213 1415 1617 1819 2021 2223 2425 2627 2829 3031 3233 3435 3637 3839 4041 4243 4445 4647 4849 50
CN8
Header 25X2
1 23 45 67 89 1011 1213 1415 1617 1819 2021 2223 2425 2627 2829 3031 3233 3435 3637 3839 4041 4243 4445 4647 4849 50
CN9
Header 25X2
+3V3D5V
D5V
PA[0..15] PA[0..15]
PB[0..15] PB[0..15]
PC[0..15] PC[0..15]
PD[0..15] PD[0..15]
PE[0..15] PE[0..15]
RESET# RESET#
thgiRtfeL
PA0
PA1PA2PA3PA4PA5PA6PA7
PA801AP9AP
PA1131AP21AP
PA14
PA15
PB0PB1PB2
4BP3BP6BP5BP
PB7
9BP8BP
PB10PB11PB12PB13PB14PB15
PE0PE1
3EP2EP5EP4EP
PE6
PE7PE8
PE9PE10PE11PE12
PE13PE14PE15
PC0PC1PC2PC3
PC4PC5
PC68CP7CP
PC9
11CP01CP
PC12
PC13PC14
PC15
PD02DP1DP4DP3DP6DP5DP
PD7
PD8
PD9PD10PD11PD12PD13PD14PD15
PC13
RESET#
Pin assignment niPdexif assignment fixed
SB1
SB2
Pin assignment niPdexif assignment fixed
Open by default
AN3311 Schematics
Doc ID 18209 Rev 1 53/58
9.9 JTAG and trace
Figure 34. JTAG and trace
AM08506v1
1234567891011121314151617181920
CN12FTSH-110-01-L-DV
+3V3
R12110K
R12510K
R12210K
R12310K
R118[N/A]
+3V3
1234567891011121314151617181920
CN13JTAG +3V3
+3V3
R127 10K
R128 10K
R12610K
JP20
R12410K
R1290R119[N/A]R1300R120[N/A]
TDI
RESET#
TRACE_D3TRACE_D2TRACE_D1TRACE_D0TRACE_CK
TRST
TMS/SWDIOTCK/SWCLKTDO/SWO
Trace connector
JTAG connector
KEY
PA13PA14PB3PA15PB4
PE6PE5PE4PE3PE2
Schematics AN3311
54/58 Doc ID 18209 Rev 1
9.10 Power
Figure 35. Power
AM08517v1
IDD
_Mea
sure
men
t
IDD
_CN
T_EN
LP_W
AKE
UP
2
3
4
5
U23
74LX
1G04
CTR
I/O1
O/I
2
GN
D3
C4
VCC
5
U22
74H
1G66
STR
+3V3
R156
1(1%
)R1
571K
(1%
)
3
4
5
G
SD
126 T2 ST
T5PF
20V
3
4 5
G
S D
1 2 6
T1 STT5
PF20
V
+3V3 Q
121
Q13
2
Q14
3
Q6
4
Q5
5
Q7
6
Q4
7
GN
D8
CO9
CO10
CI11
CLR
12Q
913
Q8
14Q
1015
VCC
16U
24
M74
HC4
060T
TR
+3V3
+3V3
R152
10K
R149
4K7
C78
0.47
uF+3
V3
VDD
_MCU
12
3
JP23
C88
1nF
R158
15K
R153
30K
Osc
illat
or fr
eque
ncy 3
0KH
z
+3V3
R79
0PA
6
PA0
PC13
C48
100n
F
45
2
3
1
U21
MA
X993
8FEU
K+
VBA
T_Vo
ltage
Vin
3
GND 1
Vout
2
U19
LD10
86D
2M33
C79
220u
FC7
510
uFC8
010
0nF
+5V
TP10
3V3
SV1
SG2
CV3
CG1
4
CG2
5
CG3
6
U20
BNX0
02-0
1
C74
10uF
E5V
TP11
5V+5
V
R148
1K5
12LD
7
red
TP12
Gro
und
1 32
CN18
DC-
10B
Z1 SMA
J5.0
A-T
RC7
710
0nF
1
2
3
U18
ZEN
056V
130A
24LS
+3V3
D5V
E5V
VBA
T6
VSS_
510
VDD
_511
VSSA
19VR
EF-
20VR
EF+
21
VDD
A22
VSS_
427
VDD
_428
VSS_
149
VDD
_150
VSS_
274
VDD
_275
VSS_
399
VDD
_310
0
U9B
BARR
ACU
DA
_256
K
BT1
CR12
20 h
olde
r
L1 BEA
DC7
61u
FC8
710
0nF
R155
47
R147
0
VDD
A
VDD
_MCU
VREF
+
VREF
-
C86
100n
F
TP13
VREF
32
1
JP24
+3V3VD
D_M
CU
R150
10K(
1%)
R151
20K(
1%)
VBA
T_D
IV
C81
100n
FC8
210
0nF
C83
100n
FC8
410
0nF
C85
100n
F
VDD
_MCU
R154
0
USB
_VBU
S1
23
45
6
JP25
R163
0
PC5
Vin
3Vo
ut2
1
U27
LD11
17S2
5TR
+5V
C51
10uF
+2V5
TP5
2V5
From
IO e
xpan
der
C79_
122
0uF
C27
1uF
AN3311 Schematics
Doc ID 18209 Rev 1 55/58
9.11 LCD 3.2" module with SPI and 16-bit interface 1
Figure 36. LCD 3.2" module with SPI and 16-bit interface 1
AM08509v1
EnableDotClkHSYNCVSYNC
CS
RS
WRRD
#RESET
SDOSDI
VDD
PD0PD1PD2PD3PD4PD5PD6PD7PD8PD9PD10PD11PD12PD13PD14PD15PD16PD17
YUYDXRXL
VSS1
XL 2XR 3YD 4YU 5
VSS6
IM0/ID 7
IM1 8
IM3 9
SDO10
NC11
SDI12
D17 13D16 14D15 15D14 16D13 17D12 18D11 19D10 20D9 21D8 22D7 23D6 24D5 25D4 26D3 27D2 28D1 29D0 30CS31
RESET32
RS33
WR/SCL34
RD35
VSYNC36
HSYNC37
DOTCLK38
ENABLE39
VCC40
VCC41
VSS42
LED_K43 LED_A44
VSS45
CN2
FF0245SS1
R4 0
R1 10K VDD
RP1
10KRP2
10K
RP4
10K
PD0
PD2PD4PD6PD8
PD9
PD10
PD11
PD12
PD13
PD14
PD15
PD16
PD17
Enable
DotClk
HSYNC
VSYNC
VDD
C31uF/50V
R3 4K7R2 4K7
SDISDO
RDRS
Soldered for Serial interface only
Soldered for i80-system 16-bit interface
The 34-pin connector to mother board for both serial and 16- bit interface. Compatible with MB694 with touch screen signals added on pin 31-34.
CSRSWRRD#RESET
VDD
BLGND
BLVDD
BL_Control
PD1PD2PD3PD4PD5PD6PD7PD8
PD10PD11PD12PD13PD14PD15PD16PD17
SDOSDI
AK
Z1
STPS1L40M C14.7uF/50V
L1
4.7uH(1A)
R710
BLGND
BLVDD
R6100K
C22.2uF
R5
0
R8do not fit
BLVDD
BL_Control
BLGND
BLGND
BLGND
AM-240320D4TOQW-T00H(R)
Vi1
Rset 2GND3 FB 4
NC 5Vo 6
EN7
SW8
PGND9
U1
STLD40DPMR
CS1
RS2
WR/SCL3
RD4
RESET5
VDD24
VCI25
GND26
GND27
BL_VDD28
BL_Control23 BL_GND22
PD1 6
PD2 7
PD3 8
PD4 9
PD5 10
PD6 11
PD7 12
PD8 13
PD10 14
PD11 15
PD12 16
PD13 17
PD14 18
PD15 19
PD16 20
PD17 21
SDO29
SDI30 XL 31
XR 32
YD 33
YU 34
CN1
3.2LCD_connector
YUYDXRXL
LCD board connector to mother board
RP3
10K
RP6
10K
RP5
10K
PD1PD3PD5PD7
References AN3311
56/58 Doc ID 18209 Rev 1
10 References
1. AN3128 application note
2. RM0008 reference manual
3. STM32F10xFWLib 3.2.1 help file
4. STM811 datasheet
5. TN0074 technical note
6. UM0608 user manual
7. STEVAL-IHP001V3 schematics diagram
8. AN2993 application note
9. M24LR64-r datasheet
10. AN2972 application note.
AN3311 Revision history
Doc ID 18209 Rev 1 57/58
11 Revision history
Table 16. Document revision history
Date Revision Changes
14-Dec-2010 1 Initial release.
AN3311
58/58 Doc ID 18209 Rev 1
Please Read Carefully:
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve theright to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at anytime, 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 noliability 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 thisdocument 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 productsor services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of suchthird 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 IMPLIEDWARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIEDWARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWSOF 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 NOTRECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAININGAPPLICATIONS, 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 "AUTOMOTIVEGRADE" 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 voidany warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, anyliability 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.
© 2010 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
Top Related