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.
This document uses the conventions described in the sections below.
1.1 Acronyms
Ta bl e 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
SPISerial to parallel interface
OOP Object oriented programming
6/58Doc ID 18209 Rev 1
AN3311ZigBee 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 I
2
C/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 17/58
ZigBee smartplugAN3311
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 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
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.
®
devices.
8/58Doc ID 18209 Rev 1
AN3311Multi-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 I
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.
2
C digital serial interface which allows the user to
Refer to the STMPE811 datasheet for more information on the register concerning the data
of the touched points on the touchscreen.
Figure 3.I/O expander hardware configuration on the STM3210C-EVAL
+3V
C8
100n
IO_Expander_SCK
IO_Expander_SDA
IO_Expander_INT
VC
14
Vio
10
GN
SCLK
B1
R15
+3V
R160
10
+3V
+3V
R3
10
C9
100n
R164
10
+3V
SDAT
Data
A0/Data
Out
ST
devic
address:0x8
VC
14
Vio
10
GN
SCLK
SDAT
Data
A0/Data
Out
R5
ST
10
devic
address:0x8
16
15
13
12
11
16
15
13
12
11
TouchScreen_Y-
TouchScreen_XTouchScreen_Y+
TouchScreen_X+
EXP
EXP
EXP
EXP
R5
100
EXP
EXP
EXP
EXP
EXP
EXP
EXP
EXP
R5
100
AM08449v1
10/58Doc ID 18209 Rev 1
AN3311STM3210C-EVAL demonstration board
4 STM3210C-EVAL demonstration board
Figure 4.STM3210C-EVAL demonstration board
Doc ID 18209 Rev 111/58
STM3210C-EVAL demonstration boardAN3311
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
2
●I
C 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, 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.
For more details of calibration parameters, refer to the STPM01 datasheet on www.st.com.
Doc ID 18209 Rev 113/58
STM3210C-EVAL demonstration boardAN3311
Figure 6.STM3210C-EVAL demonstration board layout
&1&1%1&
&1
&$1
&1
&$1
&1&1([WHQVLRQKHDGHU
8
)9&7
670
&10RWRUFRQWURO
&1
5-
FRQQHFWRU
&1
56
&1
86%0LFUR$%
FRQQHFWRU
&1
9SRZHU
&1
$XGLR MDFN
&1
0LFUR6'FDUG
&1
6PDUWFDUG
%
5HVHW
4.3 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:
●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).
%:DNHXS
%7DPSHU8-R\VWLFN
&1
7U D F H
&1
-7$*
&1
&RORU/&'
8
,U'$
59
3RWHQW LR PHWH
%
8VHUNH\
U
!-V
14/58Doc ID 18209 Rev 1
AN3311STM3210C-EVAL demonstration board
The power supply is configured by setting the related jumpers JP24 and JP25, as described
in Ta bl e 2 .
Table 2.Power related jumpers
JumperDescriptionConfiguration
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):
bat is connected to 3.3 V power when JP24 is set as shown: (Default)
V
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 115/58
STM3210C-EVAL demonstration boardAN3311
Table 3.Boot related switches
SwitchBoot fromConfiguration
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.
●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 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.Reset related jumper
JumperDescription
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.
16/58Doc ID 18209 Rev 1
AN3311STM3210C-EVAL demonstration board
4.7 Joystick
The joystick is four-directional and includes a selection key.
4.8 Pushbuttons
The 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 memory
The ZigBee adapter has a 64-Kbit I2C/RF dual interface memory (M24LR64-r) on board,
and it is connected to the I
2
The I
C 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).
2
C1 peripheral of the MCU.
4.10 Development and debug support
The 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 CoreSight
TM
debug tools
4.11 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
Pin on CN14DescriptionPin connection
1CSPB2
2RS-
3WR/SCLPC10
4RD -
3.2" TFT LCD with touchscreen
CN14 (default)
Doc ID 18209 Rev 117/58
STM3210C-EVAL demonstration boardAN3311
Table 5.LCD module (continued)
3.2" TFT LCD with touchscreen
CN14 (default)
Pin on CN14DescriptionPin connection
5RESETRESET#
22BL_GNDGND
23BL_Control+5 V
24VDD3.3 V
25VCI3.3 V
26GNDGND
27GNDGND
28BL_VDD+5 V
29SDOPC11
30SDIPC12
31XLI/O Expander
32XRI/O Expander
33YDI/O Expander
34YUI/O Expander
4.12 JTAG debugging connector CN13
Figure 7.JTAG debugging connector CN13 viewed from above the PCB
Table 6.JTAG debugging connector CN13
Pin numberDescriptionPin numberDescription
13.3 V power23.3 V power
3PB44GND
5PA156GND
7PA138GND
9PA1410GND
!-V
18/58Doc ID 18209 Rev 1
Loading...
+ 40 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.