STMicroelectronics AN3311 This application note describe Datasheet

AN3311
Application note
In-home display for ZigBee® smartplug
Introduction
This application note describes the demonstration firmware running on the STM3210CEVAL 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.
December 2010
Doc ID 18209 Rev 1
1/58
www.st.com
Contents
AN3311
Contents
1
Document and library rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1
2
3
ZigBee smartplug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1
Smartplug description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2
ZigBee module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Multi-input embedded GUI library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1
4
5
2/58
Acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
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
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
Doc ID 18209 Rev 1
AN3311
6
7
Contents
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
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
Doc ID 18209 Rev 1
3/58
List of tables
AN3311
List of tables
Table 1.
Table 2.
Table 3.
Table 4.
Table 5.
Table 6.
Table 7.
Table 8.
Table 9.
Table 10.
Table 11.
Table 12.
Table 13.
Table 14.
Table 15.
Table 16.
4/58
List of acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Power related jumpers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Boot related switches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Reset related jumper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
LCD module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
JTAG debugging connector CN13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Daughterboard extension connector CN8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Daughterboard extension connector CN9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
ZigBee adapter pin description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Function description format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
vSmartPlugSamplingTask task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
vGraphicLibraryTask task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
prvApplicationTask task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
prvSetupHardware function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
vBoardInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Doc ID 18209 Rev 1
AN3311
List of figures
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.
STM3210C-EVAL block scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
I/O expander hardware configuration on the STM3210C-EVAL . . . . . . . . . . . . . . . . . . . . . 10
STM3210C-EVAL demonstration board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Hardware block diagram - STM32 peripherals mapping. . . . . . . . . . . . . . . . . . . . . . . . . . . 13
STM3210C-EVAL demonstration board layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
JTAG debugging connector CN13 viewed from above the PCB . . . . . . . . . . . . . . . . . . . . 18
Power supply connector CN18 viewed from the front. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
In-home display firmware architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Application project files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
IAR embedded workbench main window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
IAR embedded workbench debugger options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
ZigBee dongle connection problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Main menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Searching plugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
No plug detected. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Plugs detected . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Label changing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
TRIAC smartplug management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Relay smartplug management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Smartplug statistics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Energy consumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Global energy consumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Power consumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Global power consumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
ZigBee and dual interface EEPROM adapter schematic for STM3210C-EVAL . . . . . . . . . 45
ZigBee and dual interface EEPROM adapter layout for STM3210C-EVAL . . . . . . . . . . . . 46
STM3210C main schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
MCU schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
LCD schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
I/O expander schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
I/O peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Extension connector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
JTAG and trace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
LCD 3.2" module with SPI and 16-bit interface 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Doc ID 18209 Rev 1
5/58
Document and library rules
1
AN3311
Document and library rules
This document uses the conventions described in the sections below.
1.1
Acronyms
Table 1 lists the acronyms used in this document.
Table 1.
6/58
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
Doc ID 18209 Rev 1
AN3311
ZigBee smartplug
2
ZigBee smartplug
2.1
Smartplug description
The smartplug coordinator is connected via an SPI to the STM3210C-EVAL through an “AdHoc” 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 STM3210CEVAL (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.
Doc ID 18209 Rev 1
7/58
ZigBee smartplug
Figure 2.
AN3311
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 module
ZigBee 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:
8/58
For more information, see the UM0608 user manual, STEVAL-IHP001V3 schematics
diagram, and AN2993 application note.
Doc ID 18209 Rev 1
AN3311
Multi-input embedded GUI library
3
Multi-input embedded GUI library
3.1
Description
This 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.
Doc ID 18209 Rev 1
9/58
Multi-input embedded GUI library
Figure 3.
AN3311
I/O expander hardware configuration on the STM3210C-EVAL
+3V3
+3V
C8
C89
100nF
100n
IO_Expander_SCK
IO_Expander_SDA
IO_Expander_INT
PB6
PB7
PB1
B14
R159
R15
U7
6
14
10
4
5
2
7
3
0
R3
R37
10K
10
VC
VCC
Vio
GND
GN
SCLK
SDAT
INT
Data in
A0/Data Out
YXY+
X+
IN3
IN2
IN1
IN0
1
16
15
13
12
11
9
8
STMPE81
ST
811
I2C devic
device address:0x8 2
TouchScreen_YTouchScreen_XTouchScreen_Y+
TouchScreen_X+
EXP_I
EXP
_IO9
EXP_I
EXP
_IO1
O10
EXP_I
EXP
_IO1
O11
EXP_I
EXP
_IO1
O12
R5
R57
100K
100
+3V3
+3V
+3V3
+3V
C9
C90
100nF
100n
U8
6
14
10
4
5
2
7
3
R160
10K
10
R164
10K
10
R5
R56
10K
10
VC
VCC
Vio
GND
GN
SCLK
SDAT
INT
Data in
A0/Data Out
YXY+
X+
IN3
IN2
IN1
IN0
1
16
15
13
12
11
9
8
STMPE81
ST
811
I2C devic
device address:0x8
address:0x88
+3V3
+3V
EXP_IO1
EXP_I
EXP_I
EXP
_IO2
EXP_I
EXP
_IO3
EXP_I
EXP
_IO4
EXP_I
EXP
_IO5
EXP_I
EXP
_IO6
EXP_I
EXP
_IO7
EXP_I
EXP
_IO8
R5
R58
100K
100
+3V3
+3V
AM08449v1
10/58
Doc ID 18209 Rev 1
AN3311
4
STM3210C-EVAL demonstration board
STM3210C-EVAL demonstration board
Figure 4.
STM3210C-EVAL demonstration board
Doc ID 18209 Rev 1
11/58
STM3210C-EVAL demonstration board
4.1
4.2
AN3311
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.
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, USBOTG, 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.
12/58
Doc ID 18209 Rev 1
AN3311
STM3210C-EVAL demonstration board
Figure 5.
Hardware block diagram - STM32 peripherals mapping
)3
6 REGULATOR
-#5
CONSUMPTION
MEASUREMENT
,%$S KEY
)#
!UDIO $!#
-%-3
%%02/-
'0)/
*OYSTICK
%XTENSION
CONNECTOR FOR
'0)/S
)/ EXPANDER
4OUCHSCREEN
4&4 ,#$
53" -INI!"
CONNECTOR
/4'
-ICRO3$
CARD
30)
-# CONTROL
CONNECTOR
-#
53" POWER
SWITCH
34-&6#4
-))2-)
*4!'
".# CONNECTOR
#!.
TRANSCEIVER
#!.
$" CONNECTOR
#!.
#!.
TRANSCEIVER
#!.
$" CONNECTOR
23
TRANSCEIVER
53!24 $" CONNECTOR
!$#
53!24
)R$!
TRANSCEIVER
0OTENTIOMETER
"ATTERY VOLTAGE
MEASUREMENT
)NTEGRATED 2*
CONNECTOR
#!.
$EBUG
4RACE
0(9
53!24
3MART CARD
INTERFACE
3MART CARD
INTERFACE
!-V
For more details of calibration parameters, refer to the STPM01 datasheet on www.st.com.
Doc ID 18209 Rev 1
13/58
STM3210C-EVAL demonstration board
Figure 6.
AN3311
STM3210C-EVAL demonstration board layout
&1&1%1&
&10RWRUFRQWURO
&1&1([WHQVLRQKHDGHU
&1
5-
FRQQHFWRU
&1
&$1
&1
56
8
670)9&7
&1
&$1
&1
86%0LFUR$%
FRQQHFWRU
&1
7UDFH
&1
9SRZHU
&1
-7$*
&1
$XGLRMDFN
&1
&RORU/&'
&1
0LFUR6'FDUG
8
,U'$
&1
6PDUWFDUG
59
3RWHQWLRPHWHU
%
5HVHW
%
8VHUNH\
%:DNHXS
4.3
%7DPSHU
8-R\VWLFN
!-V
Power supply
The 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:
14/58
●
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).
Doc ID 18209 Rev 1
AN3311
STM3210C-EVAL demonstration board
The power supply is configured by setting the related jumpers JP24 and JP25, as described
in Table 2.
Table 2.
Power related jumpers
Jumper
Description
Configuration
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:
JP25
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 supply
connected):
Vbat is connected to 3.3 V power when JP24 is set as shown: (Default)
JP24
Vbat is connected to battery when JP24 is set as shown:
4.4
Boot option
The 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.
Doc ID 18209 Rev 1
15/58
STM3210C-EVAL demonstration board
Table 3.
AN3311
Boot related switches
Switch
Boot from
Configuration
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
SW1 and SW2 set as shown:
STM3210C-EVAL boots from embedded SRAM when SW1 and SW2
are set as shown:
4.5
Clock source
Two clock sources are available on the STM3210C-EVAL demonstration board for
STM32F107VC, and RTC is embedded.
4.6
●
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.
Reset source
The 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 4.
16/58
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.
Doc ID 18209 Rev 1
AN3311
4.7
STM3210C-EVAL demonstration board
Joystick
The joystick is four-directional and includes a selection key.
4.8
Pushbuttons
The following pushbuttons are provided:
4.9
●
Key: user pushbutton
●
Tamper: user pushbutton
●
Wake-up: pushbutton used to wake up the processor from low-power mode.
Storage memory
The 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 support
The two debug connectors available on the STM3210C-EVAL demonstration board are:
4.11
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
Display and input devices
The 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
-
Doc ID 18209 Rev 1
17/58
STM3210C-EVAL demonstration board
Table 5.
AN3311
LCD module (continued)
3.2" TFT LCD with touchscreen
CN14 (default)
4.12
Pin on CN14
Description
Pin connection
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
JTAG debugging connector CN13
Figure 7.
JTAG debugging connector CN13 viewed from above the PCB
!-V
Table 6.
18/58
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
Doc ID 18209 Rev 1
AN3311
STM3210C-EVAL demonstration board
Table 6.
4.13
JTAG debugging connector CN13 (continued)
Pin number
Description
Pin number
Description
11
RTCK
12
GND
13
PB3
14
GND
15
RESET#
16
GND
17
DBGRQ
18
GND
19
DBGACK
20
GND
Daughterboard extension connector CN8 and CN9
Two 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.
Table 7.
Daughterboard extension connector CN8
How to disconnect with function block on STM3210CEVAL board
Pin
Description
Alternate function
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/WKUP
Keep 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
27
PD5
USART2_TX
29
PD7
LD1
Remove R96
Remove R94
31
Doc ID 18209 Rev 1
19/58
STM3210C-EVAL demonstration board
Table 7.
AN3311
Daughterboard extension connector CN8 (continued)
How to disconnect with function block on STM3210CEVAL board
Pin
Description
Alternate function
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
MC
47
PE6
Trace_D3
49
D5V
2
PC6
I2S_MCK/MC
JP10 open
4
PC8
MC
Disconnect 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
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
Disconnect STM3210C-EVAL board from motor power drive
board
Remove R135 and LCD
32
34
PB4
TRST
Keep JP20 open
36
PB6
CAN2_TX/
I2C1_SCK
Keep JP9 open
38
PE0
MC/Micro-SD card
detection
Remove 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
20/58
Doc ID 18209 Rev 1
AN3311
Table 7.
STM3210C-EVAL demonstration board
Daughterboard extension connector CN8 (continued)
Pin
Description
Alternate function
How to disconnect with function block on STM3210CEVAL board
46
PB9
User button
Remove R104
48
3.3 V
50
GND
Table 8.
Daughterboard extension connector CN9
How to disconnect with function block on STM3210CEVAL board
Pin
Description
Alternate function
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
9
PC13 button
B3
IDD_CNT_EN /
Anti-tamper button
B4
Keep 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
25
PE12
MC
Disconnect 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
PA4
Micro-SD card/
Audio_DAC
Keep JP15 open
43
PA2
Ethernet
Remove R162
45
PC3
Ethernet
Remove RS1
23
Doc ID 18209 Rev 1
21/58
STM3210C-EVAL demonstration board
Table 8.
AN3311
Daughterboard extension connector CN9 (continued)
How to disconnect with function block on STM3210CEVAL board
Pin
Description
Alternate function
47
PC1
Ethernet
49
PC13
IDD_CNT_EN /
Anti-tamper button
B4
Keep JP1 open
2
PD15
MC
Disconnect 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
MC
Disconnect STM3210C-EVAL board from motor power drive
board
26
PE11
MC
Disconnect 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
24
22/58
Doc ID 18209 Rev 1
AN3311
4.14
STM3210C-EVAL demonstration board
TFT LCD connector CN14
One 34-pin male header CN14 is available on the board to connect LCD module board
MB785.
4.15
Power connector CN18
The 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
'&9
*1'
!-V
For more information on STM3210C-EVAL, please refer to the UM0600 user manual.
Doc ID 18209 Rev 1
23/58
Demonstration firmware system setup
AN3311
5
Demonstration firmware system setup
5.1
Hardware requirements
5.2
a)
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.
STM3210C-EVAL demonstration board setup
Set 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 name
24/58
STM3210C-EVAL I/O
assignment
Extension 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 43
VCC-GPIO (for M24LR64r)
4
PE5
Trace_D2
CN8 - Pin 44
ZIG_WAKE
5
PE6
Trace_D3
CN8 - Pin 47
ZIG_RSTB
Doc ID 18209 Rev 1
AN3311
5.4
Demonstration firmware system setup
How to navigate the demo menu
Four 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.
Doc ID 18209 Rev 1
25/58
In-home display firmware
AN3311
6
In-home display firmware
6.1
Firmware architecture
{
In-home display firmware architecture
F
r
e
e
R
T
O
S
InHome Display Firmware Architecture
{
{
{
Hard
dware Multti-Inpu
ut App
plication
Depe
endentt GUI Librarry
Layer
Figure 9.
SmartPlug Coordinator
Zi B St
ZigBee
Stack
k
SPI
ZigBee Adapter and RF
Antenna for I2C Dual
Interface Memory
Multi-Input GUI Layer
SPI
LCD HAL
LCD Libraries
STM32F10xx Libraries
I2C
AM08462v1
This section describes the firmware implementation. The tasks/functions are described in
the following format:
Table 10.
Function description format
Function name
Function prototype
The name of the function
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
26/58
Other library functions called
Doc ID 18209 Rev 1
AN3311
In-home display firmware
6.2
main.c
6.2.1
vSmartPlugSamplingTask
Table 11 describes the vSmartPlugSamplingTask task:
Table 11.
vSmartPlugSamplingTask task
Function name
Function prototype
vSmartPlugSamplingTask
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;
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 )
Doc ID 18209 Rev 1
27/58
In-home display firmware
AN3311
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:
Table 12.
vGraphicLibraryTask task
Function name
Function prototype
vGraphicLibraryTask
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;
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
28/58
Doc ID 18209 Rev 1
AN3311
In-home display firmware
CursorReadJoystick(POLLING_MODE);
#endif
vTaskDelay(2);
}
}
6.2.3
prvApplicationTask
Table 13 describes the prvApplicationTask task:
Table 13.
prvApplicationTask task
Function name
Function prototype
prvApplicationTask
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;
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 14.
prvSetupHardware function
Function name
Function prototype
prvSetupHardware
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
Doc ID 18209 Rev 1
29/58
In-home display firmware
Table 14.
AN3311
prvSetupHardware function (continued)
Required preconditions None
Called functions
No API/HAL layer functions;
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
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA
RCC_APB2Periph_GPIOC
RCC_APB2Periph_GPIOE
and AFIO clocks */
| RCC_APB2Periph_GPIOB |
| RCC_APB2Periph_GPIOD |
| 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:
Table 15.
vBoardInit function
Function name
Function prototype
vBoardInit
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;
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.
30/58
Doc ID 18209 Rev 1
AN3311
Getting started with the system
7
Getting started with the system
7.1
Configure IAR tool for building, debugging, and
programming the application
Together 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”.
Doc ID 18209 Rev 1
31/58
Getting started with the system
AN3311
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
32/58
Doc ID 18209 Rev 1
AN3311
Getting started with the system
In order to use the In-home display application project, it is necessary to:
7.2
●
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.
Example application - main.c
An 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
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
"menu.h"
"graphicObject.h"
"cursor.h"
"stm32d-eval_io_expander.h"
"LcdHal.h"
"TscHal.h"
"pictures.h"
"stm32f10x.h"
"stm32f10x_rcc.h"
"misc.h"
"SmartPlugObj.h"
"CoordinatorObj.h"
"COORDINATOR_Layer.h"
"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 ------------------------------------------------------------*/
Doc ID 18209 Rev 1
33/58
Getting started with the system
AN3311
/* 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
#define USER_BUTTON_PIN
#elif USE_STM3210E_EVAL
#define USER_BUTTON_PORT
#define USER_BUTTON_PIN
#endif
/* LCD Controller DEFINES */
#define LCD_CTRL_PORT_NCS
#define LCD_GPIO_DATA_PORT
#define LCD_CTRL_PIN_NCS
#define LCD_CTRL_PIN_NWR
#define LCD_CTRL_PIN_RS
#define LCD_GPIO_PIN_SCK
#define LCD_GPIO_PIN_MISO
#define LCD_GPIO_PIN_MOSI
#define LCD_GPIO_RCC_APB_PERIPH
#define LCD_GPIO_RCC_APB_PERIPH_NCS
#define LCD_GPIO_REMAP_PORT
#define LCD_RCC_APB_PERIPH
#define LCD_RCC_AHB_PERIPH
#define LCD_SPI_PORT
#ifdef USE_STM3210C_EVAL
#define LCD_CONNECTION_MODE
#elif USE_STM3210E_EVAL
#define LCD_CONNECTION_MODE
#endif
#define RCC_AHBPeriph_FSMC
34/58
GPIOB
GPIO_Pin_9
GPIOG
GPIO_Pin_8
GPIOB
GPIOC
GPIO_Pin_2
GPIO_Pin_15
GPIO_Pin_7
GPIO_Pin_10
GPIO_Pin_11
GPIO_Pin_12
RCC_APB2Periph_GPIOC
RCC_APB2Periph_GPIOB
GPIO_Remap_SPI3
RCC_APB1Periph_SPI3
RCC_AHBPeriph_FSMC
SPI3
GL_SPI
GL_FSMC
((uint32_t)0x00000100)
Doc ID 18209 Rev 1
AN3311
Getting started with the system
/* 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
#define
#define
#define
priorities. */
EMBER_Task
APPLICATION_Tick_Task
mainINIT_TASK_PRIORITY
( tskIDLE_PRIORITY + 3 )
( tskIDLE_PRIORITY + 2 )
( 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);
Doc ID 18209 Rev 1
35/58
Getting started with the system
AN3311
/*
* 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
pTscParam
pJoyParam
pBtnParam
=
=
=
=
NewLcdHwParamObj
NewTscHwParamObj
NewJoyHwParamObj
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:
36/58
●
Hardware peripheral configuration and initialization
●
ZigBee stack initialization
●
FreeRTOS task creation
●
Starting system.
Doc ID 18209 Rev 1
AN3311
Getting started with the system
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.
Doc ID 18209 Rev 1
37/58
In-home display GUI application
8
AN3311
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
38/58
Doc ID 18209 Rev 1
AN3311
In-home display GUI application
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.
Doc ID 18209 Rev 1
39/58
In-home display GUI application
AN3311
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.
40/58
Doc ID 18209 Rev 1
AN3311
In-home display GUI application
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
Doc ID 18209 Rev 1
41/58
In-home display GUI application
AN3311
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
42/58
Doc ID 18209 Rev 1
AN3311
In-home display GUI application
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
Doc ID 18209 Rev 1
43/58
In-home display GUI application
AN3311
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.
44/58
Doc ID 18209 Rev 1
PE6
VCC-GPIO PE4
I2C1_SDA
Doc ID 18209 Rev 1
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
Header 25x2 (Female-Bottom)
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
CN8
3V3
PE3
PE5
I2C1_SCK
4k7
R3
JP2
L1
4.7uH
1 Jumper
2
3
1
2
3
4
5
6
J4
U1
SDA
SCL
E1
VCC
J2
1
2
3
4
5
6
5
VBRD
MOSI
MISO
SCLK
nSSEL
GND
ZIGBEE/SPZB260-PRO
3
1
4k7
R2
ZIG_MOSI
PA7 (SPI1_MOSI) - Remove R169
ZIG_SS
PA4 (SPI1_NSS) - Keep JP15 open
JP1
Jumper
2
ZIG_MOSI
ZIG_MISO
ZIG_SCLK
ZIG_SS
VCC_3V3
I2C1_SDA
I2C1_SCK
E1
7
6
VCC-GPIO
8
ZigBee - CONN1
M24LR64
VSS
AC1
AC0
E0
ZigBee - CONN2
VBRD
ZIG_HOST_INT HOST_INT
WAKE
ZIG_WAKE
RSTB
ZIG_RSTB
GND
GND
VCC_3V3
GND 4
3
2
E0 1
VCC_3V3
CN9
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
GND
ZIG_MISO PA6 (SPI1_MISO) - Remove R79
ZIG_SCLK PA5 (SPI1_CLK) - Remove R84
Header 25x2 (Female-Bottom)
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
9
Schematics
9.1
Smartplug board schematics and layout
Prior to using this adapter, remove the required
resistance from the STM3210C-Eval Board
VCC_3V3
4k7
R1
VCC_3V3
SMD 7.8mm diameter, 5.3mm height
GND
VCC_3V3
AN3311
Schematics
Figure 26. ZigBee and dual interface EEPROM adapter schematic for STM3210C-EVAL
AM08515v1
45/58
Schematics
9.2
AN3311
ZigBee/RF adapter for smartplug and dual interface memory
Figure 27. ZigBee and dual interface EEPROM adapter layout for STM3210C-EVAL
46/58
Doc ID 18209 Rev 1
TDI
RESET#
TRST
TMS/SWDIO
TCK/SWCLK
TDO/SWO
TRACE_CK
TRACE_D0
TRACE_D1
TRACE_D2
TRACE_D3
Doc ID 18209 Rev 1
IDD_Measurement
VBAT_Voltage
LP_WAKEUP
VBAT_DIV
IDD_CNT_EN
RS232/IrDA_RX
RS232/IrDA_TX
Bootloader_RESET
Bootloader_BOOT0
U_USART&IrDA
USART&IrDA.SchDoc
USB_VBUS
U_Power
Power.SchDoc
SmartCard_CMDVCC
SmartCard_CLK
SmartCard_RST
SmartCard_IO
SmartCard_3/5V
SmartCard_OFF
U_SmartCard
SmartCard.SchDoc
MCO
PHY_RESET#
MII_TX_CLK
MII_TXD0
MII_TXD1
MII_TXD2
MII_TXD3
MII_INT
MII_TX_EN
MII_RX_ER
MII_RX_DV/RMII_CRSDV
MII_RX_CLK/RMII_REF_CLK
MII_RXD0
MII_RXD1
MII_RXD2
MII_RXD3
MII_COL
MII_CRS
MII_MDIO
MII_MDC
U_Ethernet
Ethernet.SchDoc
U_JTAG&Trace
JTAG&Trace.SchDoc
MicroSDCard_MISO
MicroSDCard_Detection
MicroSDCard_CS
MicroSDCard_MOSI
MicroSDCard_SCK
U_MicroSDCard
MicroSDCard.SchDoc
CAN1_RX
CAN1_TX
CAN2_RX
CAN2_TX
Audio_RST
Audio_DAC_OUT
Audio_SDA
Audio_SCK
I2S_CK
I2S_DIN
I2S_CMD
I2S_MCK
USART2_RX
USART2_TX
Bootloader_RESET
Bootloader_BOOT0
IDD_CNT_EN
IDD_Measurement
VBAT_Voltage_OUT
SmartCard_CMDVCC
SmartCard_CLK
SmartCard_RST
SmartCard_IO
SmartCard_3/5V
SmartCard_OFF
MCO
MII_TX_EN
MII_RX_ER
MII_RX_DV/RMII_CRSDV
MII_RX_CLK/RMII_REF_CLK
MII_RXD0
MII_RXD1
MII_RXD2
MII_RXD3
MII_COL
MII_CRS
MII_MDIO
MII_MDC
MII_TX_CLK
MII_TXD0
MII_TXD1
MII_TXD2
MII_TXD3
TDI
RESET#
TRST
TMS/SWDIO
TCK/SWCLK
TDO/SWO
TRACE_CK
TRACE_D0
TRACE_D1
TRACE_D2
TRACE_D3
MicroSDCard_Detection
MicroSDCard_CS
CAN1_RX
CAN1_TX
CAN2_RX
CAN2_TX
I2S_CK
I2S_DIN
I2S_CMD
I2S_MCK
Audio_DAC_OUT
U_MCU
MCU.SchDoc
USB_P owerSwitchOn
USB_DM
USB_DP
USB_ID
USB_VBUS
USB_OverCurrent
PA[0..15]
PB[0..15]
PC[0..15]
PD[0..15]
PE[0..15]
SPI3_MISO
LCD_CS
SPI3_SCK
SPI3_MOSI
I2C1_SCK
I2C1_SDA
IO_Expander_INT
Potentiometer
Anti_Tamper
WAKEUP
User_Button
LED4
LED3
LED2
LED1
MC_PFCsync1
MC_PFCsync2
MC_WL
MC_VH
MC_VL
MC_UH
MC_UL
MC_WH
MC_NTC
MC_DissipativeBrake
MC_PFCpwm
MC_EnIndex
MC_BusVoltage
MC_HeatsinkTemperature
MC_EnB
MC_EnA
MC_CurrentC
MC_CurrentB
MC_CurrentA
MC_EmergencySTOP
R131
R132
R133 R134
4K7 4K7
+3V3
0
0
TouchScreen_YTouchScreen_Y+
TouchScreen_XTouchScreen_X+
USB_P owerSwitchOn
USB_DM
USB_DP
USB_ID
USB_VBUS
USB_OverCurrent
U_USB_OTG_FS
USB_OTG_FS.SchDoc
PA[0..15]
PB[0..15]
PC[0..15]
PD[0..15]
PE[0..15]
RESET#
U_ExtensionConnector
ExtensionConnector.SchDoc
LCD_CS
LCD_CLK
LCD_DI
RESET#
LCD_DO
U_LCD
LCD.SchDoc
BNC1
BNC2
JOY_SEL
JOY_DOWN
JOY_LEFT
JOY_RIGHT
JOY_UP
MEMS_INT1
MEMS_INT2
EXP_IO12
EXP_IO11
EXP_IO10
EXP_IO9
EXP_IO8
EXP_IO7
EXP_IO6
EXP_IO5
EXP_IO4
EXP_IO3
EXP_IO2
EXP_IO1
TouchScreen_YTouchScreen_Y+
TouchScreen_XTouchScreen_X+
IO_Expander_SCK
IO_Expander_SDA
IO_Expander_INT
U_IO_Expander
IO_Expandor.SchDoc
LED4
LED3
LED2
LED1
EEPROM_SCK
EEPROM_SDA
MEMS_SCK
MEMS_SDA
Potentiometer
Anti_Tamper
WAKEUP
User_Button
U_IO Peripherals
IO Peripherals.SchDoc
MC_PFCsync1
MC_PFCsync2
BNC2
MC_WL
BNC1
MC_VH
MC_VL
MC_UH
MC_UL
MC_WH
MC_NTC
MC_DissipativeBrake
MC_PFCpwm
MC_EnIndex
MC_BusVoltage
MC_HeatsinkTemperature
MC_EnB
MC_EnA
MC_CurrentC
MC_CurrentB
MC_CurrentA
MC_EmergencySTOP
U_MotorControl
MotorControl.SchDoc
9.3
U_CAN
CAN.SchDoc
U_Audio
Audio.SchDoc
AN3311
Schematics
STM3210C
Figure 28. STM3210C main schematic
AM08494v1
47/58
Doc ID 18209 Rev 1
MicroSDCard_CS
Audio_DAC_OUT
2
JP14
RESET#
3
100nF
C15
2
4
RESET
0
R78
[N/A]
R62
+3V3
220
R63
1N4148
D2
+3V3
35
36
37
89
90
91
92
93
95
96
47
48
51
52
53
54
PB0
PB1
PB2
PB3
PB4
PB5
PB6
PB7
PB8
PB9
PB10
PB11
PB12
PB13
PB14
P B 15
D1
1N4148
JP19
STM32F107VCT
OSC_IN
OSC_OUT
NRST
NC
BOOT0
PB0
PB1
PB2
PB3
PB4
PB5
PB6
PB7
PB8
PB9
PB10
PB11
PB12
PB13
PB14
PB15
PA0-WKUP
PA1
PA2
PA3
PA4
PA5
PA6
PA7
PA8
PA9
PA10
PA11
PA12
PA13
PA14
PA15
U9A
Bootloader_RESET
Bootloader_BOOT0
12
13
14
73
94
23
24
25
26
29
30
31
32
67
68
69
70
71
72
76
77
PA0
PA1
PA2
PA3
PA4
PA5
PA6
PA7
PA8
PA9
PA10
PA11
PA12
PA13
PA14
PA15
TP4
PTP_PPS
TP6
MCO
SW2
JP18
09.03290.01
R61
10K
IO_Expander_INT
I2S_DIN
I2C1_SDA
MII_TXD3
User_Button
MII_RX_ER
MII_TX_EN
TDO/SWO
TRST
CAN2_RX
MC_CurrentB
MC_CurrentC
USB_ID
USB_DM
USB_DP
TMS/SWDIO
TCK/SWCLK
TDI
MC_BusVoltage
IDD_Measurement
MC_CurrentA
MCO
MII_RX_CLK/RMII_REF_CLK
MII_MDIO
X3
25MHz (with socket)
1
B1
20pF
C19
C18
20pF
10K
CAN2_TX
JP9
MII_TXD0
I2S_CMD
I2S_CK
MII_TXD1
LCD_CS
R60
09.03290.01
I2C1_SCK
3
1
2
USB_VBUS
MII_COL
+3V3
1 SW1
JP15
MII_CRS
WAKEUP
3
2
48/58
1
PD15
PD14
PD13
PD12
PD11
PD10
PD9
PD8
PD7
PD6
PD5
PD4
PD3
PD2
PD1
PD 0
PE15
PE14
PE13
PE12
PE11
PE10
PE9
PE8
PE7
PE6
PE5
PE4
PE3
PE2
PE1
PE0
46
45
44
43
42
41
40
39
38
5
4
3
2
1
98
97
PC15
PC14
PC13
PC12
PC11
PC10
PC9
PC8
PC7
PC6
PC5
PC4
PC3
PC2
PC1
PC0
62
61
60
59
58
57
56
55
88
87
86
85
84
83
82
81
9
8
7
80
79
78
66
65
64
63
34
33
18
17
16
15
MicroSDCard_Detection
PE15
PE14
PE13
PE12
PE11
PE10
PE9
PE8
PE7
PE6
PE5
PE4
PE3
PE2
PE1
PE0
PD15
PD14
PD13
PD12
PD11
PD10
PD9
PD8
PD7
PD6
PD5
PD4
PD3
PD2
PD1
PD0
PC15-OSC32_OUT
PC14-OSC32_IN
PC13-ANTI_TAMP
PC12
PC11
PC10
PC9
PC8
PC7
PC6
PC5
PC4
PC3
PC2
PC1
PC0
4
3
1
2
MC_EmergencySTOP
SmartCard_CMDVCC
MC_WH
MC_WL
MC_VH
MC_VL
MC_UH
MC_UL
SmartCard_OFF
TRACE_D3
TRACE_D2
TRACE_D1
TRACE_D0
TRACE_CK
USB_OverCurrent
MC_PF Csync2
LED1
USART2_RX
USART2_TX
LED4
LED3
MC_NTC
CAN1_TX
CAN1_RX
MC_PFCpwm
MC_PF Csync1
LED2
MII_RXD3
MII_RXD2
VBAT_Voltage_OUT
Potentiometer
MII_TX_CLK
MII_TXD2
MII_MDC
SPI3_MOSI
SPI3_MISO
SPI3_SCK
USB_P owerSwitchOn
MC_EnIndex
MC_EnB
R59
0
JP26
C17
10pF
0
R165
R161
0
C16
10pF
MC_EnA
I2S_MCK
Anti_Tamper
IDD_CNT_EN
JP13
3
JP12
1
3
JP11
1
3
1
PE[0..15]
PD[0..15]
PC[0..15]
PB[0..15]
MII_RX_DV/RMII_CRSDV
SmartCard_IO
MII_RXD0
SmartCard_RST
MII_RXD1
SmartCard_CLK
PE[0..15]
PD[0..15]
PC[0..15]
PA[0..15]
default set/ feature enabled anotherset/ feature enabled
==================================================
JP1:
2<->3 / Anti_Temper
1<->2 / MCU current measurement
JP9:
close / I2C device
open/ CAN2
JP10:
1<->2 / I2S Audio
2<->3 / MC
JP11:
2<->3 / Ethernet
1<->2 / Smartcard
JP12:
2<->3 / Ethernet
1<->2 / Smartcard
JP13:
2<->3 / Ethernet
1<->2 / Smartcard
JP14:
1<->2 / Ethernet
2<->3 / WKUP & MC
JP15:
close / SDcard CS
open/ outputfor audio DAC
JP18:
open/BL_Boot0 disabled close / BL_Boot0
JP19:
open/BL_Reset disabled
close / BL_Reset
2
2
2
MC_HeatsinkTemperature
SmartCard_3/5V
JP10
3
1
JP1
3
Jumper configuration:
2
2
1
X2
MC306-G-06Q-32.768 (manufacturerJFVNY)
PA[0..15]
PB[0..15]
9.4
3
MC_DissipativeBrake
Schematics
AN3311
MCU
Figure 29. MCU schematic
AM08495v1
AN3311
9.5
Schematics
LCD
Figure 30. LCD schematic
CN14
PB2
LCD_CS
1
2
3
4
5
PC10
LCD_CLK
RESET#
+5V
+3V3
LCD_DO
LCD_DI
PC11
PC12
+5V
22
23
24
25
26
27
28
29
30
CS
RS
WR/SCL
RD
RESET
BL_GND
BL_Control
VDD
VCI
GND
GND
BL_VDD
SDO
SDI
PD1
PD2
PD3
PD4
PD5
PD6
PD7
PD8
PD10
PD11
PD12
PD13
PD14
PD15
PD16
PD17
XL
XR
YD
YU
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
31
32
33
34
To IO expandor
TouchScreen_XTouchScreen_X+
TouchScreen_YTouchScreen_Y+
3.2" LCD_connector (MB785 with AM-240320D4TOQW-T00H(R))
CN15
1
2
3
4
5
6
7
8
+3V3
+3V3
9
10
11
12
13
14
15
16
CS
SCL
SDI
RS
WR
RD
SDO
RESET
VDD
VCI
GND
GND
BL_VDD
BL_Control
BL_GND
BL_GND
2.4" LCD connector(MB542 with AM240320L8TNQW-00H)
AM08496v1
Doc ID 18209 Rev 1
49/58
Schematics
9.6
AN3311
I/O expander
Figure 31. I/O expander schematic
+3V3
C89
100nF
IO_Expander_SCK
IO_Expander_SDA
IO_Expander_INT
PB6
PB7
PB14
R159
U7
6
14
10
4
5
2
7
3
0
R37
10K
VCC
Vio
GND
SCLK
SDAT
INT
Data in
A0/Data Out
YXY+
X+
IN3
IN2
IN1
IN0
1
16
15
13
12
11
9
8
STMPE811
I2C device address:0x82
TouchScreen_YTouchScreen_XTouchScreen_Y+
TouchScreen_X+
EXP_IO9
EXP_IO10
EXP_IO11
EXP_IO12
R57
100K
+3V3
+3V3
C90
100nF
U8
6
14
10
4
5
2
7
3
R160
10K
R164
10K
R56
10K
+3V3
VCC
Vio
GND
SCLK
SDAT
INT
Data in
A0/Data Out
YXY+
X+
IN3
IN2
IN1
IN0
1
16
15
13
12
11
9
8
STMPE811
I2C device address:0x88
EXP_IO1
EXP_IO2
EXP_IO3
EXP_IO4
EXP_IO5
EXP_IO6
EXP_IO7
EXP_IO8
R58
100K
+3V3
AM08497v1
50/58
Doc ID 18209 Rev 1
I/O peripherals
AN3311
9.7
Figure 32. I/O peripherals
U15
CN11
VB334
PD7
LED1
C91
2
LD2
Orange
1
2
LED2
R107
10K
R95
PD3
R96
1
2
1
2
100nF
100nF
C56
LD4
Blue
PD4
LED4
R97
680
EEPROM_SCK
EEPROM_SDA
+3V3
+3V3
+3V3 U16
1
VDD_IO
CS
6
VDD
SDO
100nF
3
Reserved
GND
PB7
13
SDA
GND
PB6
14
SCL
GND
8
INT1
GND
9
INT2
Reserved
MEMS
MEMS_SDA
MEMS_SCK
MEMS_INT1
MEMS_INT2
To IO expander
R114
4K7
P C 13
2
RV1
10K
100
B4
Tamper
4
1
C57
100nF
B2
WKUP
C59
[N/A]
51/58
R110
R111
100
100
C58
100nF
WAKEUP
PA0 R116
330
R117
220K
AM08516v1
Schematics
4
Button
R105
0
2
3
2
1K
R109
3
Anti_Tamper
B3
USER
R86
0
+3V3
R115
4K7
0
R103
C60
10nF
+3V3
R104
PC4
LIS302DL
+3V3
1
Potentiometer
7
12
2
10
5
4
11
3
Potentiometer
R106
10K
C92
User_Button
100nF
LEDs
680
M24C64-WMN6
PB 9
Joystick
680
LED3
JP17
MT008-A
330
PD13
LD3
Red
100nF
8
VCC
7
WC
6 PB6
SCL
5 PB7
SDA
DWON
LEFT
RIGHT
UP
1
E0
E1
E2
VSS
LD1
Green
1
4
1
2
3
4
+3V3
R94
3
Doc ID 18209 Rev 1
U17
3
1
4
6
2
EEPROM
Selection
1
CN10
VB334
0
0
0
0
0
5
4
3
2
1
5
4
3
2
1
BNC
R98
R99
R100
R101
R102
C55
To IO expander
JOY_SEL
JOY_DOWN
JOY_LEFT
JOY_RIGHT
JOY_UP
C54
PA7
PB0
BNC1
BNC2
COMMON
2
R89
10K
R90
10K
R91
10K
R92
10K
R93
10K
50
100nF
R113
5
100
+3V3
100nF
50
C53
SB4
R108
R112
C52
SB3
Schematics
9.8
AN3311
Extension connector
Figure 33. Extension connector
Pin assignmentf i x ed
P i n assignmentfixed
Pin assignmentf i x ed
P i n assignmentfixed
L ef t
R i ght
CN8
PC 7
PC9
PA 9
PA0
SB1
PC14
P A 12
SB2
PC15
P C 10
Open by default
PC12
PD 1
PD 3
PD 5
PD7
PB 3
PB 5
PB7
PE 2
PE 4
PB 8
PE6
D5V
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
CN9
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
PC6
PD14
PD12
PD10
PC 8
PA8
P A 10
R87
R88
PC13
RESET#
PA11
P A 13
PA14
PB15
PB13
PB11
P C 11
PA15
PD0
PD 2
PD 4
PD 6
D5V
PE14
PE12
PE10
PE8
PE7
PB1
PC5
PA7
PB 4
PB 6
PE0
PE1
PE 3
PE 5
PB 9
+3V3
Header 25X2
PA4
PA2
PC3
PC1
PC13
820
820
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
PD15
PD13
PD11
PD9
PD8
PB14
PB12
PB10
PE15
PE13
PE11
PE9
PB2
PB0
PC4
PA6
PA5
PA3
PA1
PC2
PC0
Header 25X2
PA[0..15]
PB[0..15]
PC[0..15]
PD[0..15]
PE[0..15]
RESET#
PA[0..15]
PB[0..15]
PC[0..15]
PD[0..15]
PE[0..15]
RESET#
AM08505v1
52/58
Doc ID 18209 Rev 1
AN3311
9.9
Schematics
JTAG and trace
Figure 34. JTAG and trace
+3V3
JP20
R121 R122 R123
10K 10K 10K
R124
10K
PA13
PA14
PB3
PA15
PB4
TMS/SWDIO
TCK/SWCLK
TDO/SWO
TDI
TRST
RESET#
R125
10K
CN12
FTSH-110-01-L-DV
+3V3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
TRACE_D3
TRACE_D2
TRACE_D1
TRACE_D0
TRACE_CK
CN13
JTAG
KEY
R129 0
R119 [N/A]
R130 0
R120 [N/A]
PE6
PE5
PE4
PE3
PE2
+3V3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+3V3
R118
[N/A]
R126
10K
R127
10K
R128
10K
JTAG connector
Trace connector
AM08506v1
Doc ID 18209 Rev 1
53/58
+3V3
1
3
2
BEAD
L1
JP24
BT1
CR1220 holder
VDD_MCU
+3V3
1
VREF+
R157
47
R155
S
4
0
0
R151
20K(1%)
R163
R150
10K(1%)
R154
PC5
1K(1%)
From IO expander
VBAT_DIV
VBAT_Voltage
C82
100nF
20
19
49
74
99
27
10
VREF-
C83
100nF
VDD_MCU
BARRACUDA_256K
VREFVSSA
VSS_1
VSS_2
VSS_3
VSS_4
VSS_5
100nF
1uF
C86
+3V3
T2
STT5PF20V
C27
VREF+
VDDA
VDD_1
VDD_2
VDD_3
VDD_4
VDD_5
VBAT
U9B
VREF
TP13
G
D
C81
100nF
21
22
50
C87
75
100nF 100
28
11
VDD_MCU
6
C76
1uF
2
VDDA
1(1%)
4
1
2
3
R156
3
5
1
2
6
C84
100nF
C85
100nF
R147
0
5
3
3
+5V
+5V
3
C79
220uF
DC-10B
CN18
3
1
Vin
1
2
3
4
5
6
7
8
VCC
Q10
Q8
Q9
CLR
CI
CO
CO
Vout
2
Vin
Vout
C51
10uF
+2V5
U19
LD1086D2M33
3
2
C88
1nF
4
R158
15K
C48
100nF
R153
30K
C75
10uF
C77
100nF
+3V3
C80
100nF
TP10
3V3
Z1
SMAJ5.0A-TR
PA0
+3V3
PA6
2
1
LP_WAKEUP
CG1
CG2
CG3
CV
D5V
4
5
6
3
USB_VBUS
E5V
BNX002-01
SG
SV
red
6
4
2
1
C74
10uF
JP25
LD7
2
IDD_Measurement
IDD_CNT_EN
U20
R152
10K
PC13
+3V3
Oscillator frequency30KHz
TP5
2V5
16
15
14
13
12
11
10
9
+3V3
S
5
1
2
6
STT5PF20V
3
0
T1
M74HC4060TTR
Q12
Q13
Q14
Q6
Q5
Q7
Q4
GND
U24
+3V3
R79
4K7
C78
0.47uF
R149
U18
ZEN056V130A24LS
U27
LD1117S25TR
1
2
3
5
2
C79_1
220uF
VCC
O/I
74H1G66STR
I/O
C
GND
U22
U23
74LX1G04CTR
1
4
3
U21
MAX9938FEUK+
4
2
5
2
JP23
1
GND
Doc ID 18209 Rev 1
1
54/58
G
5
3
1
1K5
R148
E5V
TP11
5V
+5V
TP12
Ground
9.10
D
VDD_MCU
Schematics
AN3311
Power
Figure 35. Power
AM08517v1
AN3311
Schematics
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
CN1
CS
RS
WR
RD
#RESET
1
2
3
4
5
CS
RS
WR/SCL
RD
RESET
PD1
PD2
PD3
PD4
PD5
PD6
PD7
PD8
BLGND
BL_Control
VDD
BLVDD
SDO
SDI
22
23
24
25
26
27
28
29
30
PD10
PD11
PD12
PD13
PD14
PD15
PD16
PD17
BL_GND
BL_Control
VDD
VCI
GND
GND
BL_VDD
SDO
SDI
6
7
8
9
10
11
12
13
PD1
PD2
PD3
PD4
PD5
PD6
PD7
PD8
14
15
16
17
18
19
20
21
PD10
PD11
PD12
PD13
PD14
PD15
PD16
PD17
31
32
33
34
XL
XR
YD
YU
Soldered for i80-system 16-bit interface
SDO
SDI
R4
LCD board connector to mother board
CS
WR
RD
RS
31
34
35
33
SDO
SDI
10
12
#RESET
32
VDD
4.7uH(1A)
L1
BL_Control
STPS1L40M
C1
4.7uF/50V
U1
8
1
7
3
9
0
SW
Vo
Vi
NC
EN
GND
FB
PGND Rset
STLD40DPMR
BLGND
VSYNC
HSYNC
DOTCLK
ENABLE
NC
CS
WR/SCL
RD
RS
SDO
SDI
RESET
40
41
VCC
VCC
Z1
A
K
R5
36
37
38
39
11
The 34-pin connector to motherboard for both
serial and 16 - bit interface. Compatible with
MB694 with touchscreen signals added on
pin 31-34.
BLGND
6
5
BLGND
4
2
44
43
6
42
45
1
LED_A
LED_K
VSS
VSS
VSS
VSS
IM1
IM3
IM0/ID
YU
YD
XR
XL
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
D10
D11
D12
D13
D14
D15
D16
D17
8
9
7
5
4
3
2
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
YU
YD
XR
XL
PD0
PD1
PD2
PD3
PD4
PD5
PD6
PD7
PD8
PD9
PD10
PD11
PD12
PD13
PD14
PD15
PD16
PD17
VDD
0
PD16
PD14
PD12
PD10
10K
RP2
PD8
PD6
PD4
PD2
10K
RP3
PD9
PD0
RS
RD
10K
RP4
PD17
PD15
PD13
PD11
FF0245SS1
AM-240320D4TOQW-T00H(R)
R6
100K
10K
RP5
R7
10
PD7
PD5
PD3
PD1
RP6
R8
do not fit
4K7
4K7
RP1
VDD
BLVDD
R2
R3
CN2
VSYNC
HSYNC
DotClk
Enable
XL
XR
YD
YU
C2
2.2uF
10K
Soldered for Serial interface only
3.2LCD_connector
BLVDD
R1
BLGND
HSYNC
Enable
VSYNC
DotClk
C3
1uF/50V
10K
10K
AM08509v1
Doc ID 18209 Rev 1
55/58
References
10
AN3311
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.
56/58
Doc ID 18209 Rev 1
AN3311
11
Revision history
Revision history
Table 16.
Document revision history
Date
Revision
14-Dec-2010
1
Changes
Initial release.
Doc ID 18209 Rev 1
57/58
AN3311
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.
© 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
58/58
Doc ID 18209 Rev 1
Similar pages